Skip to content

Commit

Permalink
resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tsu-ki committed Dec 26, 2024
1 parent 249ad50 commit 81afff7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions blt/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<int:user_id>/", recommend_user, name="recommend_user"),
path("recommend/<str:username>/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(
Expand All @@ -633,8 +635,6 @@
name="user_sizzle_report",
),
path("delete_time_entry/", delete_time_entry, name="delete_time_entry"),
path("recommend/<int:user_id>/", recommend_user, name="recommend_user"),
path("recommend/<str:username>/blurb/", recommend_via_blurb, name="recommend_via_blurb"),
]

if settings.DEBUG:
Expand Down
31 changes: 15 additions & 16 deletions website/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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"})
Expand All @@ -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:
Expand Down Expand Up @@ -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."})
Expand All @@ -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:
Expand All @@ -402,7 +400,8 @@ def recommend_via_blurb(request, username):
"success": True,
"action": action,
"total_count": total_count,
})
}
)


class UserProfileDetailsView(DetailView):
Expand Down Expand Up @@ -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"})
Expand All @@ -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"})
Expand Down

0 comments on commit 81afff7

Please sign in to comment.