def recommend_user(request): context = {} context.update(get_form_context()) context['next'] = '/' context['user_combos'] = get_advanced_recommend_users(request.user) context['request'] = request return render(request, 'recommend_user.html', context)
def recommend_movie(request): context = {} context.update(get_form_context()) context['movie_combos'] = get_advanced_recommend_movies(request.user) context['next_page'] = '/recommend-movie' context['request'] = request return render(request, 'recommend_movie.html', context)
def home(request): context = {} context.update(get_form_context()) context['next'] = '/' context['movie_combos'] = get_in_theater_movies() context['request'] = request context['email_from'] = EmailEnterForm() context.update(get_upcoming_movies()) return render(request, 'home.html', context)
def password_change_complete(request): context = {} context.update(get_form_context()) if request.method == 'GET': return redirect('/profile/'+str(request.user.id)) change_password_form = ChangePasswordForm(request.POST) if not change_password_form.is_valid(): return redirect('not valid') user_to_edit = authenticate(username= request.user.username, password=change_password_form.cleaned_data['old_password']) if user_to_edit is None: return HttpResponse('error') user_to_edit.password = make_password(change_password_form.cleaned_data['new_password1']) user_to_edit.save() user_editted = authenticate(username= user_to_edit.username, password=change_password_form.cleaned_data['new_password1']) auto_login(request, user_editted) return render(request, 'password_change_complete.html', context)
def profile(request, user_id): if int(user_id) > max_id: raise Http404 context = {} context.update(get_form_context()) context['request'] = request context['user'] = request.user user_be_view = get_object_or_404(User,id = user_id) if request.user == user_be_view: context['view_user'] = request.user profile = get_object_or_404(Profile, user = user_be_view) intro_form = IntroForm(instance = profile) photo_form = PhotoForm(instance = profile) context['intro_form'] = intro_form context['photo_form'] = photo_form else: context['view_user'] = user_be_view context['reviews'] = Review.objects.filter(publisher = user_be_view).order_by('id').reverse() if Profile.objects.filter(user = user_be_view).count() > 0: profile = get_object_or_404(Profile, user = user_be_view) context['profile'] = profile context['search_form'] = SearchForm() user_be_followed = get_object_or_404(User, id = user_id) if request.user.username: profile_of_login_user = get_object_or_404(Profile, user = request.user) if user_be_followed in profile_of_login_user.users_followed.all(): context['follow_text'] = 'unfollow' else: context['follow_text'] = 'follow' else: context['follow_text'] = 'follow' return render(request, 'profile.html', context)
def my_password_change(request): context = {} context.update(get_form_context()) context['change_password_form'] = ChangePasswordForm() return render(request,'password_change.html',context);