def process_vote(request): if not request.unique_user.id: return http.HttpResponse('error') form = RecommendationVoteForm(request.POST, request.unique_user) if form.is_valid(): film_id = form.cleaned_data['film_id'] kw = dict() # recommendations = vue.get_all_recommendations(request.unique_user, similar=False, limit=False) # v = recommendations.get_by_film_id(film_id) # if v is not None: # v = str(v) # kw['ratings_based_prediction'] = v recommendations = vue.get_vue_recommendations(request.unique_user, similar=False, limit=False) v = recommendations.get_by_film_id(film_id) if v is not None: v = str(v) kw['traits_based_prediction'] = v vote = form.save(**kw) else: return http.HttpResponse('error') return http.HttpResponse('ok')
def main(request): if request.user.is_anonymous(): request.unique_user.make_unique('vue') if not 'rater_class' in request.session: from .rater import VueRater request.session['rater_class'] = VueRater vue_recommendations = vue.get_vue_recommendations(request.unique_user) similar_debug = getattr(vue_recommendations, 'similar_debug', ()) all_recommendations = get_top(vue.get_all_recommendations(request.unique_user)) vue_recommendations = get_top(vue_recommendations) vue_rater = request.session['rater_class']( request ) rated_movies = len( vue_rater.get_rated_films() ) movies_to_rate = 15 - rated_movies rating_progress = ( rated_movies * 100 ) / 15 context = { 'all_recommendations': all_recommendations, 'vue_recommendations': vue_recommendations, 'similar_debug': similar_debug, 'moods': vue.MOODS, 'rating_progress': rating_progress, 'movies_to_rate': movies_to_rate, 'rated_movies': rated_movies, } return render(request, 'vue/index.html', context)
def get_recommendations(self, mood): return vue.get_vue_recommendations(self.request.unique_user, mood)