Ejemplo n.º 1
0
def set_guess_score(film, user):
    if user.is_authenticated():
        guess = rating_helper.guess_score(user, film.pk)
        guess = guess and guess.guess_rating
    else:
        guess = None
    return {
        'guess_score': guess,
    }
Ejemplo n.º 2
0
def film_guess_score(context, film, user, type=1):
    if user.is_authenticated():
        guess = rating_helper.guess_score(user, film.pk)
        guess = guess and guess.guess_rating
    else:
        guess = None
    return {
        'film':film,
        'perms':context.get('perms'),
        'guess':guess,
        'type':type,
    }
Ejemplo n.º 3
0
    }

@register.inclusion_tag('movies/movie/rating_for_user.html', takes_context=True)
def film_rating_for_user(context, film, user, type=''):
    request = context['request']
    rating = None
    guess = None
    try:
        rating = Rating.objects.get(film=film.id,
                user=user, rating__isnull=False, type=Rating.TYPE_FILM)
    except Rating.DoesNotExist, e:
        rating = None

    if not rating:
        if user.is_authenticated():
            guess = rating_helper.guess_score(user, film.pk)
            guess = guess and guess.guess_rating
        else:
            guess = None

    return {
        'film':film,
        'rating':rating,
        'guess': guess,
        'request': request
    }

@register.inclusion_tag('movies/movie/guess_score.html', takes_context=True)
def film_guess_score(context, film, user, type=1):
    if user.is_authenticated():
        guess = rating_helper.guess_score(user, film.pk)