From 81afff7ba4115db31a030f43e87c0cdce0d915ea Mon Sep 17 00:00:00 2001 From: Krishna Kaushal Date: Thu, 26 Dec 2024 15:31:58 +0530 Subject: [PATCH] resolved conflicts --- blt/urls.py | 4 ++-- website/views/user.py | 31 +++++++++++++++---------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/blt/urls.py b/blt/urls.py index 0317dc1a5..11d7c23f8 100644 --- a/blt/urls.py +++ b/blt/urls.py @@ -625,6 +625,8 @@ path("sizzle-docs/", sizzle_docs, name="sizzle-docs"), path("api/timelogsreport/", TimeLogListAPIView, name="timelogsreport"), path("time-logs/", TimeLogListView, name="time_logs"), + path("recommend//", recommend_user, name="recommend_user"), + path("recommend//blurb/", recommend_via_blurb, name="recommend_via_blurb"), path("blog/", include("blog.urls")), path("sizzle-daily-log/", sizzle_daily_log, name="sizzle_daily_log"), path( @@ -633,8 +635,6 @@ name="user_sizzle_report", ), path("delete_time_entry/", delete_time_entry, name="delete_time_entry"), - path("recommend//", recommend_user, name="recommend_user"), - path("recommend//blurb/", recommend_via_blurb, name="recommend_via_blurb"), ] if settings.DEBUG: diff --git a/website/views/user.py b/website/views/user.py index b2b6c0f5b..401e74477 100644 --- a/website/views/user.py +++ b/website/views/user.py @@ -278,8 +278,8 @@ def get_context_data(self, **kwargs): ).exists() context["all_users"] = User.objects.exclude(id=self.request.user.id) context["total_recommendations"] = ( - Recommendation.objects.filter(recommended_user=user).count() - + Recommendation.objects.filter(recommender=user).count() + Recommendation.objects.filter(recommended_user=user).count() + + Recommendation.objects.filter(recommender=user).count() ) return context @@ -293,8 +293,8 @@ def post(self, request, *args, **kwargs): messages.success(request, "Profile updated successfully!") if ( - request.headers.get("X-Requested-With") == "XMLHttpRequest" - and "recommend_via_blurb" in request.POST + request.headers.get("X-Requested-With") == "XMLHttpRequest" + and "recommend_via_blurb" in request.POST ): if request.user.userprofile != user.userprofile: recommendation, created = Recommendation.objects.get_or_create( @@ -307,9 +307,9 @@ def post(self, request, *args, **kwargs): action = "removed" total_count = ( - Recommendation.objects.filter(recommended_user=user).count() - + Recommendation.objects.filter(recommender=user).count() - + (1 if user.userprofile.recommendation_blurb else 0) + Recommendation.objects.filter(recommended_user=user).count() + + Recommendation.objects.filter(recommender=user).count() + + (1 if user.userprofile.recommendation_blurb else 0) ) return JsonResponse({"success": True, "action": action, "count": total_count}) return JsonResponse({"success": False, "error": "Cannot recommend yourself"}) @@ -319,7 +319,7 @@ def post(self, request, *args, **kwargs): try: recommended_user = User.objects.get(id=recommended_user_id) if Recommendation.objects.filter( - recommender=request.user, recommended_user=recommended_user + recommender=request.user, recommended_user=recommended_user ).exists(): messages.error(request, "You have already recommended this user.") else: @@ -365,7 +365,6 @@ def recommend_user(request, user_id): @require_POST @login_required def recommend_via_blurb(request, username): - recommended_user = get_object_or_404(User, username=username) if request.user == recommended_user: return JsonResponse({"success": False, "error": "You cannot recommend yourself."}) @@ -374,8 +373,7 @@ def recommend_via_blurb(request, username): message = data.get("message", "") recommendation = Recommendation.objects.filter( - recommender=request.user, - recommended_user=recommended_user + recommender=request.user, recommended_user=recommended_user ).first() if recommendation: @@ -402,7 +400,8 @@ def recommend_via_blurb(request, username): "success": True, "action": action, "total_count": total_count, - }) + } + ) class UserProfileDetailsView(DetailView): @@ -820,9 +819,9 @@ def withdraw(request): account_links = stripe.AccountLink.create( account=account, return_url=f"http://{settings.DOMAIN_NAME}:{settings.PORT}/dashboard/user/stripe/connected/" - + request.user.username, + + request.user.username, refresh_url=f"http://{settings.DOMAIN_NAME}:{settings.PORT}/dashboard/user/profile/" - + request.user.username, + + request.user.username, type="account_onboarding", ) return JsonResponse({"redirect": account_links.url, "status": "success"}) @@ -835,9 +834,9 @@ def withdraw(request): account_links = stripe.AccountLink.create( account=account, return_url=f"http://{settings.DOMAIN_NAME}:{settings.PORT}/dashboard/user/stripe/connected/" - + request.user.username, + + request.user.username, refresh_url=f"http://{settings.DOMAIN_NAME}:{settings.PORT}/dashboard/user/profile/" - + request.user.username, + + request.user.username, type="account_onboarding", ) return JsonResponse({"redirect": account_links.url, "status": "success"})