Пример #1
0
def details(request):
    """Details Page."""
    showid = request.GET.get('show', False)
    if not showid or not showid.isdigit():
        return HttpResponseRedirect("/")
    data = shows.get_show_info(showid)
    if 'unfollow' in request.GET:
        showid = request.GET['unfollow']
        shows.unfollow_show(showid, request.user)
    elif 'follow' in request.GET:
        showid = request.GET['follow']
        shows.follow_show(showid, request.user)
    data['following'] = shows.user_is_following(showid, request.user)
    if 'season' in request.GET:
        season = request.GET['season']
        episode = request.GET['episode']
        if not season.isdigit() or not episode.isdigit():
            season = 1
            episode = 1
        info = shows.get_episodes_for_season(showid, season, episode)
        data['episode_info'] = info
    else:
        seasons = shows.get_seasons(showid, request.user)
        data['seasons'] = seasons
    most_rated = shows.get_most_rated_shows(request.user)
    data['recommended'] = most_rated
    return render_response(request, 'details.html', data)
Пример #2
0
def details(request):
    """Details Page."""
    showid = request.GET.get('show', False)
    if not showid or not showid.isdigit():
        return HttpResponseRedirect("/")
    data = shows.get_show_info(showid)
    if 'unfollow' in request.GET:
        showid = request.GET['unfollow']
        shows.unfollow_show(showid, request.user)
    elif 'follow' in request.GET:
        showid = request.GET['follow']
        shows.follow_show(showid, request.user)
    data['following'] = shows.user_is_following(showid, request.user)
    if 'season' in request.GET:
        season = request.GET['season']
        episode = request.GET['episode']
        if not season.isdigit() or not episode.isdigit():
            season = 1
            episode = 1
        info = shows.get_episodes_for_season(showid, season, episode)
        data['episode_info'] = info
    else:
        seasons = shows.get_seasons(showid, request.user)
        data['seasons'] = seasons
    most_rated = shows.get_most_rated_shows(request.user)
    data['recommended'] = most_rated
    return render_response(request, 'details.html', data)
Пример #3
0
def follow_show(request):
    show_data = None
    user = _validate_token(request)
    if user:
        showid = int(request.GET.get('showid', 0))
        show_data = shows.get_show_by_id(showid, user, client=True)
        shows.follow_show(showid, user)

    data = simplejson.dumps(show_data)
    return HttpResponse(data, mimetype='application/json')
Пример #4
0
def follow_show(request):
    show_data = None
    user = _validate_token(request)
    if user:
        showid = int(request.GET.get('showid', 0))
        show_data = shows.get_show_by_id(showid, user, client=True)
        shows.follow_show(showid, user)

    data = simplejson.dumps(show_data)
    return HttpResponse(data, mimetype='application/json')