当前位置: 首页>>代码示例>>Python>>正文


Python Film.get_films_to_rate方法代码示例

本文整理汇总了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'),
    })
开发者ID:yangjiandong,项目名称:filmaster,代码行数:16,代码来源:film_views.py

示例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,
    })
开发者ID:thuvh,项目名称:filmmaster,代码行数:19,代码来源:film_views.py

示例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))
开发者ID:thuvh,项目名称:filmmaster,代码行数:55,代码来源:test_rate_films.py

示例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)
开发者ID:yangjiandong,项目名称:filmaster,代码行数:33,代码来源:film_views.py


注:本文中的film20.core.models.Film.get_films_to_rate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。