本文整理汇总了Python中mygpo.web.utils.get_podcast_link_target函数的典型用法代码示例。如果您正苦于以下问题:Python get_podcast_link_target函数的具体用法?Python get_podcast_link_target怎么用?Python get_podcast_link_target使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_podcast_link_target函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _decorator
def _decorator(request, podcast_id, *args, **kwargs):
try:
podcast = Podcast.objects.filter(id=podcast_id)
podcast = podcast.prefetch_related('slugs', 'urls').get()
# if the podcast has a slug, redirect to its canonical URL
if podcast.slug:
return HttpResponseRedirect(get_podcast_link_target(podcast))
return f(request, podcast, *args, **kwargs)
except Podcast.DoesNotExist:
podcast = get_object_or_404(Podcast, merged_uuids__uuid=podcast_id)
return HttpResponseRedirect(get_podcast_link_target(podcast))
示例2: podcast_data
def podcast_data(obj, domain, scaled_logo_size=64):
if obj is None:
raise ValueError('podcast should not be None')
if isinstance(obj, SubscribedPodcast):
url = obj.ref_url
podcast = obj.podcast
else:
podcast = obj
url = podcast.url
subscribers = podcast.subscribers
last_subscribers = podcast.subscribers
scaled_logo_url = get_logo_url(podcast, scaled_logo_size)
return {
"url": url,
"title": podcast.title,
"description": podcast.description,
"subscribers": subscribers,
"subscribers_last_week": last_subscribers,
"logo_url": podcast.logo_url,
"scaled_logo_url": 'http://%s%s' % (domain, scaled_logo_url),
"website": podcast.link,
"mygpo_link": 'http://%s%s' % (domain, get_podcast_link_target(podcast)),
}
示例3: podcast_data
def podcast_data(obj, domain, scaled_logo_size=64):
if obj is None:
raise ValueError('podcast should not be None')
if isinstance(obj, Podcast):
podcast = obj
elif isinstance(obj, PodcastGroup):
podcast = obj.get_podcast()
subscribers = obj.subscriber_count()
last_subscribers = obj.prev_subscriber_count()
scaled_logo_url = obj.get_logo_url(scaled_logo_size)
return {
"url": podcast.url,
"title": podcast.title,
"description": podcast.description,
"subscribers": subscribers,
"subscribers_last_week": last_subscribers,
"logo_url": podcast.logo_url,
"scaled_logo_url": 'http://%s%s' % (domain, scaled_logo_url),
"website": podcast.link,
"mygpo_link": 'http://%s%s' % (domain, get_podcast_link_target(obj)),
}
示例4: save_podcast
def save_podcast(request, podcast):
twitter = normalize_twitter(request.POST.get('twitter', ''))
podcast.twitter = twitter
podcast.save()
messages.success(request, _('Data updated'))
url = get_podcast_link_target(podcast, 'podcast-publisher-detail')
return HttpResponseRedirect(url)
示例5: add_tag
def add_tag(request, podcast):
tag_str = request.GET.get('tag', '')
if not tag_str:
return HttpResponseBadRequest()
user = request.user
tags = tag_str.split(',')
tags = map(str.strip, tags)
ContentType.objects.get_for_model(podcast)
for tag in tags:
Tag.objects.get_or_create(
tag=tag,
source=Tag.USER,
user=user,
content_type=ContentType.objects.get_for_model(podcast),
object_id=podcast.id,
)
if request.GET.get('next', '') == 'mytags':
return HttpResponseRedirect('/tags/')
return HttpResponseRedirect(get_podcast_link_target(podcast))
示例6: remove_tag
def remove_tag(request, podcast):
tag_str = request.GET.get('tag', '')
if not tag_str:
return HttpResponseBadRequest()
user = request.user
tags = tag_str.split(',')
tags = list(map(str.strip, tags))
ContentType.objects.get_for_model(podcast)
Tag.objects.filter(
tag__in=tags,
source=Tag.USER,
user=user,
content_type=ContentType.objects.get_for_model(podcast),
object_id=podcast.id,
).delete()
if request.GET.get('next', '') == 'mytags':
return HttpResponseRedirect('/tags/')
return HttpResponseRedirect(get_podcast_link_target(podcast))
示例7: subscribe
def subscribe(request, podcast):
if request.method == 'POST':
# multiple UIDs from the /podcast/<slug>/subscribe
device_uids = [k for (k,v) in request.POST.items() if k==v]
# single UID from /podcast/<slug>
if 'targets' in request.POST:
devices = request.POST.get('targets')
devices = devices.split(',')
device_uids.extend(devices)
for uid in device_uids:
try:
device = request.user.client_set.get(uid=uid)
subscribe_podcast(podcast, request.user, device)
except Client.DoesNotExist as e:
messages.error(request, str(e))
return HttpResponseRedirect(get_podcast_link_target(podcast))
targets = get_subscribe_targets(podcast, request.user)
return render(request, 'subscribe.html', {
'targets': targets,
'podcast': podcast,
})
示例8: subscribe
def subscribe(request, podcast):
if request.method == 'POST':
form = SyncForm(request.POST)
try:
device = request.user.get_device_by_uid(form.get_target())
podcast.subscribe(request.user, device)
except (SubscriptionException, DeviceDoesNotExist) as e:
messages.error(request, str(e))
return HttpResponseRedirect(get_podcast_link_target(podcast))
request.user.sync_all()
targets = podcast.subscribe_targets(request.user)
form = SyncForm()
form.set_targets(targets, _('Choose a device:'))
return render(request, 'subscribe.html', {
'podcast': podcast,
'can_subscribe': len(targets) > 0,
'form': form
})
示例9: podcast_link
def podcast_link(podcast, title=None):
""" Returns the link for a single Podcast """
title = title or podcast.display_title
title = strip_tags(title)
return format_html('<a href="{target}" title="{title}">{title}</a>',
target=get_podcast_link_target(podcast), title=title)
示例10: update_podcast
def update_podcast(request, podcast):
if not check_publisher_permission(request.user, podcast):
return HttpResponseForbidden()
update_podcasts( [podcast] )
url = get_podcast_link_target(podcast, 'podcast-publisher-detail')
return HttpResponseRedirect(url)
示例11: set_public
def set_public(request, podcast, public):
settings, created = UserSettings.objects.get_or_create(
user=request.user,
content_type=ContentType.objects.get_for_model(podcast),
object_id=podcast.pk,
)
settings.set_wksetting(PUBLIC_SUB_PODCAST, public)
settings.save()
return HttpResponseRedirect(get_podcast_link_target(podcast))
示例12: podcast_link
def podcast_link(podcast, title=None):
""" Returns the link for a single Podcast """
title = title or getattr(podcast, 'display_title', None) or podcast.title
title = strip_tags(title)
return '<a href="%(target)s" title="%(title)s">%(title)s</a>' % \
dict(target=get_podcast_link_target(podcast), title=title)
示例13: search_podcast
def search_podcast(request):
form = SearchPodcastForm(request.POST)
if form.is_valid():
podcast_url = form.cleaned_data['url']
podcast = get_objet_or_404(Podcast, urls__url=podcast_url)
url = get_podcast_link_target(podcast, 'podcast-publisher-detail')
else:
url = reverse('publisher')
return HttpResponseRedirect(url)
示例14: opengraph_podcast
def opengraph_podcast(podcast):
s = OPENGRAPH_STR % dict(
title = podcast.title,
type = 'episode',
image = 'http://gpodder.net%s' % podcast.get_logo_url(PODCAST_LOGO_BIG_SIZE),
url = 'http://gpodder.net%s' % get_podcast_link_target(podcast),
site_name = 'gpodder.net',
admins = '0'
)
return mark_safe(s)
示例15: update_podcast
def update_podcast(request, podcast):
if not check_publisher_permission(request.user, podcast):
return HttpResponseForbidden()
update_podcasts.delay([podcast.url])
messages.success(request, _('The update has been scheduled. It might take some time until the results are visible.'))
url = get_podcast_link_target(podcast, 'podcast-publisher-detail')
return HttpResponseRedirect(url)