def user_password_change(request): is_follow = False form = UserPasswordChangeForm2(request.user, request.POST or None) user = get_object_or_404(User, username=request.user.username) foll_count = Following.get_fol_count(user) follower_count = foll_count["followers"] followed_count = foll_count["followeds"] ppform = PhotoForm() cpform = CoverPhotoForm() activities = UserLog.objects.filter( is_active=True, user=request.user).order_by("-activity_date")[:5] if user != request.user: is_follow = Following.is_follow_user(follower=request.user, followed=user) if request.method == "POST": if form.is_valid(): user = form.save(commit=True) update_session_auth_hash(request, user) messages.success(request, 'Tebrikler Şifreniz Başarıyla Güncellendi') return redirect(request.user.userprofile.get_user_url()) else: messages.warning(request, "Lütfen aşağıdaki uyarılara dikkat edin.") return render(request, "user/passchange.html", context={ "activities": activities, "cpform": cpform, "ppform": ppform, "follower_count": follower_count, "followed_count": followed_count, "is_follow": is_follow, "form": form }) search_form = SearchForm(data=request.GET or None) if search_form.is_valid(): arama = search_form.cleaned_data.get("search", None) if arama: return redirect( reverse('pie_thing:index') + '?search={}'.format(arama)) return render(request, "user/passchange.html", context={ "activities": activities, "search_form": search_form, "cpform": cpform, "ppform": ppform, "follower_count": follower_count, "followed_count": followed_count, "is_follow": is_follow, "form": form })
def user_settings(request): is_follow = False gender = request.user.userprofile.gender bio = request.user.userprofile.bio birth_date = request.user.userprofile.birth_date initial = {"gender": gender, "bio": bio, "birth_date": birth_date} form = UserProfileUpdateForm(request.POST or None, request.FILES or None, instance=request.user, initial=initial) ppform = PhotoForm() cpform = CoverPhotoForm() activities = UserLog.objects.filter( is_active=True, user=request.user).order_by("-activity_date")[:5] if form.is_valid(): user = form.save(commit=True) gender = form.cleaned_data.get("gender", None) bio = form.cleaned_data.get("bio", None) birth_date = form.cleaned_data.get("birth_date", None) user.userprofile.gender = gender user.userprofile.bio = bio user.userprofile.birth_date = birth_date user.userprofile.save() messages.success(request, "Tebrikler profiliniz başarıyla güncellendi") return redirect(user.userprofile.get_user_url()) user = get_object_or_404(User, username=request.user.username) foll_count = Following.get_fol_count(user) follower_count = foll_count["followers"] followed_count = foll_count["followeds"] if user != request.user: is_follow = Following.is_follow_user(follower=request.user, followed=user) search_form = SearchForm(data=request.GET or None) if search_form.is_valid(): arama = search_form.cleaned_data.get("search", None) if arama: return redirect( reverse('pie_thing:index') + '?search={}'.format(arama)) return render(request, "user/settings.html", context={ "activities": activities, "cpform": cpform, "ppform": ppform, "search_form": search_form, "follower_count": follower_count, "followed_count": followed_count, "is_follow": is_follow, "form": form })
def userProfile(request, username): response = HttpResponseRedirect('/') response.delete_cookie('_gat', domain='pencilpie.com') response.delete_cookie('_ga', domain='pencilpie.com') response.delete_cookie('_gid', domain='pencilpie.com') is_follow = False search_form = SearchForm(data=request.GET or None) usero = get_object_or_404(User, username=username) activities = UserLog.objects.filter( is_active=True, user=usero).order_by("-activity_date")[:5] ppform = PhotoForm() cpform = CoverPhotoForm() repost_form = RepostForm() report_form = ReportForm() thing_form = ThingForm() user = get_object_or_404(User, username=username) follower = Following.is_follow_user(request.user, user) is_follow_me = Following.is_follow_user(user, request.user) foll_count = Following.get_fol_count(user) follower_count = foll_count["followers"] followed_count = foll_count["followeds"] if user != request.user: is_follow = Following.is_follow_user(follower=request.user, followed=user) if search_form.is_valid(): arama = search_form.cleaned_data.get("search", None) if arama: return redirect( reverse('pie_thing:index') + '?search={}'.format(arama)) return render(request, "user/profile.html", context={ "activities": activities, "search_form": search_form, "is_follow_me": is_follow_me, "isfollow": follower, "thing_form": thing_form, "repost_form": repost_form, "report_form": report_form, "cpform": cpform, "ppform": ppform, "follower_count": follower_count, "followed_count": followed_count, "is_follow": is_follow, "user": user })
def user_river(request, username): is_follow = False user = get_object_or_404(User, username=username) foll_count = Following.get_fol_count(user) follower_count = foll_count["followers"] followed_count = foll_count["followeds"] if user != request.user: is_follow = Following.is_follow_user(follower=request.user, followed=user) return render(request, "user/river.html", context={ "follower_count": follower_count, "followed_count": followed_count, "is_follow": is_follow, "user": user })
def get_followed_count(self): foll_count = Following.get_fol_count(self.user) followed_count = foll_count["followeds"] return followed_count