Beispiel #1
0
def mark_prev_films_as_seen(request):
    prev_film_ids = request.POST.get('prev_film_ids')
    if prev_film_ids:
        if not request.unique_user.is_authenticated():
            request.unique_user.make_unique()
        prev_film_ids = map(int, prev_film_ids.split(','))
        rater = rating_helper.get_rater(request)
        rater.mark_films_as_seen(prev_film_ids)
Beispiel #2
0
def mark_prev_films_as_seen(request):
    prev_film_ids = request.POST.get('prev_film_ids')
    if prev_film_ids:
        if not request.unique_user.is_authenticated():
            request.unique_user.make_unique()
        prev_film_ids = map(int, prev_film_ids.split(','))
        rater = rating_helper.get_rater(request)
        rater.mark_films_as_seen(prev_film_ids)
Beispiel #3
0
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 ''
Beispiel #4
0
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 ''
Beispiel #5
0
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'),
    })
Beispiel #6
0
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'),
        })
Beispiel #7
0
    def test_rate_films2(self):

        TAGS_LIST = settings.BASKETS_TAGS_LIST
        settings.RATE_BASKET_SIZE = len(TAGS_LIST)
        API_VERSION = "1.1"
        username = self.user.username
        put_url = "/api/" + API_VERSION + "/user/" + username + "/ratings/film/"

        # tag films
        films = Film.objects.all()
        tag_index = 0
        tags_number = len(TAGS_LIST)
        # one film has all the tags
        for tag in TAGS_LIST:
            films[0].save_tags(tag)

        for film in films[1:]:
            film.save_tags(TAGS_LIST[tag_index])
            tag_index = (tag_index + 1) % tags_number

        request = RequestFactory().get('/')
        request.user = self.user
        request.unique_user = self.user

        rater = rating_helper.get_rater(request)

        seen_films = set()
        while True:
            films_to_rate = rater.get_films_to_rate(6)
            if films_to_rate:
                for film in films_to_rate:
                    self.assertTrue(film not in seen_films)
                    rater.rate_film(film.id, 10)
                seen_films.update(films_to_rate)
            else:
                break

        self.assertEquals(len(seen_films), Film.objects.count())
Beispiel #8
0
        return render(request, "movies/no_more_to_rate.html")

@never_cache
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
Beispiel #9
0

@never_cache
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