本文整理汇总了Python中film20.core.models.Film.get_next_film_to_rate方法的典型用法代码示例。如果您正苦于以下问题:Python Film.get_next_film_to_rate方法的具体用法?Python Film.get_next_film_to_rate怎么用?Python Film.get_next_film_to_rate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类film20.core.models.Film
的用法示例。
在下文中一共展示了Film.get_next_film_to_rate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: random_film_to_rate
# 需要导入模块: from film20.core.models import Film [as 别名]
# 或者: from film20.core.models.Film import get_next_film_to_rate [as 别名]
def random_film_to_rate(request):
"""
Widget for main page (for not logged in users)
displaying a film to rate, selected from
the list of 10 most popular films.
"""
user = request.user
if user.is_authenticated():
film = Film.get_next_film_to_rate(user)
else:
key = cache.Key("popular_films_list")
popular_films = cache.get(key)
if popular_films is None:
fhelper = FilmHelper()
lang = getattr(settings, 'LANGUAGE_CODE', 'en')
if lang == 'en':
popular_films = fhelper.get_popular_films(exclude_nonEnglish=True)
else:
popular_films = fhelper.get_popular_films()
cache.set(key, popular_films)
film = popular_films and random.choice(popular_films) or None
return {
'film': film,
}
示例2: next_film_to_rate_url
# 需要导入模块: from film20.core.models import Film [as 别名]
# 或者: from film20.core.models.Film import get_next_film_to_rate [as 别名]
def next_film_to_rate_url(user):
if settings.NEW_RATING_SYSTEM:
films = BasketsRatingHelper.get_films_to_rate(user, 1)
film = films and films[0] or None
else:
film = Film.get_next_film_to_rate(user)
if film:
return reverse('show_film', args=(film.permalink, ))
else:
return ''
示例3: next_film_to_rate_url
# 需要导入模块: from film20.core.models import Film [as 别名]
# 或者: from film20.core.models.Film import get_next_film_to_rate [as 别名]
def next_film_to_rate_url(context, user):
request = context['request']
if settings.NEW_RATING_SYSTEM:
rater = rating_helper.get_rater(request)
films = rater.get_films_to_rate(1)
film = films and films[0] or None
else:
film = Film.get_next_film_to_rate(user)
if film:
return film.get_absolute_path()
else:
return ''
示例4: next_film_to_rate
# 需要导入模块: from film20.core.models import Film [as 别名]
# 或者: from film20.core.models.Film import get_next_film_to_rate [as 别名]
def next_film_to_rate(request):
film = Film.get_next_film_to_rate(request.user)
if film:
return HttpResponseRedirect(film.get_absolute_url())
else:
return render(request, "movies/no_more_to_rate.html")
示例5: next_film_to_rate
# 需要导入模块: from film20.core.models import Film [as 别名]
# 或者: from film20.core.models.Film import get_next_film_to_rate [as 别名]
def next_film_to_rate(request):
film = Film.get_next_film_to_rate(request.user)
if film:
return HttpResponseRedirect(reverse(show_film, args=[film.permalink]))
else:
return render(request, "movies/no_more_to_rate.html")