示例#1
0
文件: episode.py 项目: fk-lx/mygpo
def episode_for_slug_id(p_slug_id, e_slug_id):
    """ Returns the Episode for Podcast Slug/Id and Episode Slug/Id """

    if not p_slug_id:
        raise QueryParameterMissing('p_slug_id')

    if not e_slug_id:
        raise QueryParameterMissing('e_slug_id')


    # The Episode-Id is unique, so take that
    if is_couchdb_id(e_slug_id):
        return episode_by_id(e_slug_id)

    # If we search using a slug, we need the Podcast's Id
    if is_couchdb_id(p_slug_id):
        p_id = p_slug_id
    else:
        podcast = podcast_for_slug_id(p_slug_id)

        if podcast is None:
            return None

        p_id = podcast.get_id()

    return episode_for_slug(p_id, e_slug_id)
示例#2
0
文件: podcast.py 项目: fk-lx/mygpo
    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)