• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.get_podcast_link_target函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
开发者ID:JeanFred,项目名称:mygpo,代码行数:15,代码来源:podcast.py


示例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)),
    }
开发者ID:gpodder,项目名称:mygpo,代码行数:27,代码来源:directory.py


示例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)),
        }
开发者ID:Mic92,项目名称:mygpo,代码行数:25,代码来源:directory.py


示例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)
开发者ID:4johndoe,项目名称:mygpo,代码行数:7,代码来源:views.py


示例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))
开发者ID:JeanFred,项目名称:mygpo,代码行数:26,代码来源:podcast.py


示例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))
开发者ID:JeanFred,项目名称:mygpo,代码行数:25,代码来源:podcast.py


示例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,
    })
开发者ID:JeanFred,项目名称:mygpo,代码行数:29,代码来源:podcast.py


示例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
    })
开发者ID:Mic92,项目名称:mygpo,代码行数:27,代码来源:podcast.py


示例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)
开发者ID:JeanFred,项目名称:mygpo,代码行数:9,代码来源:podcasts.py


示例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)
开发者ID:Mic92,项目名称:mygpo,代码行数:9,代码来源:views.py


示例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))
开发者ID:JeanFred,项目名称:mygpo,代码行数:9,代码来源:podcast.py


示例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)
开发者ID:Mic92,项目名称:mygpo,代码行数:9,代码来源:podcasts.py


示例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)
开发者ID:4johndoe,项目名称:mygpo,代码行数:10,代码来源:views.py


示例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)
开发者ID:Mic92,项目名称:mygpo,代码行数:10,代码来源:facebook.py


示例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)
开发者ID:fk-lx,项目名称:mygpo,代码行数:10,代码来源:views.py


示例16: _decorator

    def _decorator(request, slug_id, *args, **kwargs):
        podcast = podcast_for_slug_id(slug_id)

        if podcast is None:
            raise Http404

        # redirect when Id or a merged (non-cannonical) slug is used
        if podcast.slug and slug_id != podcast.slug:
            return HttpResponseRedirect(get_podcast_link_target(podcast))

        return f(request, podcast, *args, **kwargs)
开发者ID:fk-lx,项目名称:mygpo,代码行数:11,代码来源:podcast.py


示例17: remove_tag

def remove_tag(request, podcast):
    podcast_state = podcast_state_for_user_podcast(request.user, podcast)

    tag_str = request.GET.get('tag', '')
    if not tag_str:
        return HttpResponseBadRequest()

    remove_podcast_tags(podcast_state, tag_str)

    if request.GET.get('next', '') == 'mytags':
        return HttpResponseRedirect('/tags/')

    return HttpResponseRedirect(get_podcast_link_target(podcast))
开发者ID:fk-lx,项目名称:mygpo,代码行数:13,代码来源:podcast.py


示例18: search_podcast

def search_podcast(request):
    form = SearchPodcastForm(request.POST)
    if form.is_valid():
        url = form.cleaned_data['url']

        podcast = podcast_for_url(url)
        if not podcast:
            raise Http404

        url = get_podcast_link_target(podcast, 'podcast-publisher-detail')
    else:
        url = reverse('publisher')

    return HttpResponseRedirect(url)
开发者ID:fk-lx,项目名称:mygpo,代码行数:14,代码来源:views.py


示例19: subscribe_url

def subscribe_url(request):
    url = request.GET.get('url', None)

    if not url:
        raise Http404('http://my.gpodder.org/subscribe?url=http://www.example.com/podcast.xml')

    url = sanitize_url(url)

    if url == '':
        raise Http404('Please specify a valid url')

    podcast = Podcast.for_url(url, create=True)

    return HttpResponseRedirect(get_podcast_link_target(podcast, 'subscribe'))
开发者ID:Mic92,项目名称:mygpo,代码行数:14,代码来源:podcast.py


示例20: subscribe_url

def subscribe_url(request):
    url = request.GET.get('url', None)

    if not url:
        raise Http404('http://my.gpodder.org/subscribe?url=http://www.example.com/podcast.xml')

    url = normalize_feed_url(url)

    if not url:
        raise Http404('Please specify a valid url')

    podcast = Podcast.objects.get_or_create_for_url(url)

    return HttpResponseRedirect(get_podcast_link_target(podcast, 'subscribe'))
开发者ID:JeanFred,项目名称:mygpo,代码行数:14,代码来源:podcast.py



注:本文中的mygpo.web.utils.get_podcast_link_target函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python myhdl.bin函数代码示例发布时间:2022-05-27
下一篇:
Python models.User类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap