本文整理汇总了Python中film20.core.models.Film.get_films_to_rate方法的典型用法代码示例。如果您正苦于以下问题:Python Film.get_films_to_rate方法的具体用法?Python Film.get_films_to_rate怎么用?Python Film.get_films_to_rate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类film20.core.models.Film
的用法示例。
在下文中一共展示了Film.get_films_to_rate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rate_next_film
# 需要导入模块: from film20.core.models import Film [as 别名]
# 或者: from film20.core.models.Film import get_films_to_rate [as 别名]
def rate_next_film(request, tag=None):
mark_prev_films_as_seen(request)
if settings.NEW_RATING_SYSTEM:
rater = rating_helper.get_rater(request)
films = rater.get_films_to_rate(1, tag)
else:
films = Film.get_films_to_rate(user, 1, tag)
return render(request, "movies/rating/single_film_special.html", {
'film': films[0] if len( films ) else None,
'tag':tag,
'rater':request.GET.get('rater'),
})
示例2: rate_films
# 需要导入模块: from film20.core.models import Film [as 别名]
# 或者: from film20.core.models.Film import get_films_to_rate [as 别名]
def rate_films(request, tag=None):
if settings.NEW_RATING_SYSTEM:
films = BasketsRatingHelper.get_films_to_rate(request.user,
settings.RATING_FILMS_NUMBER, tag)
else:
films = Film.get_films_to_rate(request.user,
settings.RATING_FILMS_NUMBER, tag)
if 'ajax' in request.GET:
template = "movies/rate_movies_ajax.html"
else:
template = "movies/rate_movies.html"
return render(request, template, {
'films':films,
'tag':tag,
'mark_as_seen':True,
})
示例3: test_rate_films
# 需要导入模块: from film20.core.models import Film [as 别名]
# 或者: from film20.core.models.Film import get_films_to_rate [as 别名]
def test_rate_films(self):
cache.set('test', True)
self.assertTrue(cache.get('test'))
cache.clear()
self.assertTrue(cache.get('test') is None)
settings.RATING_BASKET_SIZE = 20
all_films = set()
films = Film.get_films_to_rate(self.user, 20)
all_films.update(f.id for f in films)
logger.info("film ids: %r", [f.id for f in films])
self.assertTrue(all(self.film_pos[f.id]<=20 for f in films))
films[0].mark_as_seen(self.user)
BasketItem.objects.create(film=films[1], wishlist=1,
user=self.user)
Rating.objects.create(type=1, film=films[2], rating=5,
parent=films[2], user=self.user)
films = Film.get_films_to_rate(self.user, 17)
for f in films:
f.mark_as_seen(self.user)
# second basket
films = Film.get_films_to_rate(self.user, 10)
all_films.update(f.id for f in films)
logger.info("film ids: %r", [f.id for f in films])
self.assertTrue(all(self.film_pos[f.id]>20 and self.film_pos[f.id]<=40 for f in films))
for f in films:
f.mark_as_seen(self.user)
cache.clear()
films = Film.get_films_to_rate(self.user, 10)
all_films.update(f.id for f in films)
self.assertTrue(all(self.film_pos[f.id]>20 and self.film_pos[f.id]<=40 for f in films))
for f in films:
f.mark_as_seen(self.user)
films = Film.get_films_to_rate(self.user, 100)
all_films.update(f.id for f in films)
for f in films:
f.mark_as_seen(self.user)
self.assertEquals(len(films), 60)
self.assertEquals(len(all_films), 100)
self.assertFalse(Film.get_films_to_rate(self.user, 1))
示例4: rate_films
# 需要导入模块: from film20.core.models import Film [as 别名]
# 或者: from film20.core.models.Film import get_films_to_rate [as 别名]
def rate_films(request, tag=None):
if not request.user.is_authenticated():
request.unique_user.make_unique()
mark_prev_films_as_seen(request)
try:
films_nr = int(request.GET.get('films_nr', 0))
except ValueError, e:
pass
films_nr = films_nr or settings.RATING_FILMS_NUMBER
if settings.NEW_RATING_SYSTEM:
rater = rating_helper.get_rater(request)
films = rater.get_films_to_rate(films_nr, tag)
else:
films = Film.get_films_to_rate(user, films_nr, tag)
if 'ajax' in request.GET:
template = "movies/rate_movies_ajax.html"
else:
template = "movies/rate_movies.html"
response = render(request, template, {
'films':films or [],
'tag':tag,
'rater': request.GET.get('rater'),
})
return response
@never_cache
def rate_next_film(request, tag=None):
mark_prev_films_as_seen(request)