From 1fc632f2e60d7111fff9ea087e0a84b0093747bd Mon Sep 17 00:00:00 2001 From: VishalMinj Date: Mon, 21 Oct 2024 02:13:10 +0530 Subject: [PATCH] Update: Added very-easy problem list --- .../templates/user_profile/issue_card.html | 27 +++++++++++++++++++ .../templates/user_profile/profile.html | 3 +++ user_profile/views.py | 13 ++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 user_profile/templates/user_profile/issue_card.html diff --git a/user_profile/templates/user_profile/issue_card.html b/user_profile/templates/user_profile/issue_card.html new file mode 100644 index 0000000..de390f2 --- /dev/null +++ b/user_profile/templates/user_profile/issue_card.html @@ -0,0 +1,27 @@ +
+
+
Total Issues Solved:
+

+ +

{{ totalProblemsSolved }}
+

+
+ +
+
+
+
Very-easy Issue.: {{ veasyProblems }}
+
+
+
Easy Issue: {{ easyProblems }}
+
+
+
Medium Issue: {{ mediumProblems }}
+
+
+
Hard Issue: {{ hardProblems }}
+
+
+
+
+ diff --git a/user_profile/templates/user_profile/profile.html b/user_profile/templates/user_profile/profile.html index 6aab79a..5904645 100644 --- a/user_profile/templates/user_profile/profile.html +++ b/user_profile/templates/user_profile/profile.html @@ -24,6 +24,9 @@ {% if user.is_authenticated %} {% include "user_profile/profile-card.html" %} + {% include "user_profile/issue_card.html" %} + + {% comment %} In Django templates you can use the "get_FOO_display()" method, that will return the readable alias diff --git a/user_profile/views.py b/user_profile/views.py index 4660fe0..527561b 100644 --- a/user_profile/views.py +++ b/user_profile/views.py @@ -58,6 +58,12 @@ def profile(request, username): pending_pr_requests_for_mentor = pr_requests_for_mentor.filter(state=3).order_by("submitted_at") pr_requests_for_mentor = chain(pending_pr_requests_for_mentor, accepted_pr_requests_for_mentor, rejected_pr_requests_for_mentor) + easyProblems=PullRequest.objects.filter(contributor=user,issue__level=1,state=1).count() + mediumProblems=PullRequest.objects.filter(contributor=user,issue__level=2,state=1).count() + hardProblems=PullRequest.objects.filter(contributor=user,issue__level=3,state=1).count() + veasyProblems=PullRequest.objects.filter(contributor=user,issue__level=4,state=1).count() + totalProblemsSolved = PullRequest.objects.filter(contributor=user, state=1).count() + pr_form = PRSubmissionForm() judge_form = PRJudgeForm() @@ -74,7 +80,12 @@ def profile(request, username): "assignment_requests_for_mentor": assignment_requests_for_mentor, 'pr_form': pr_form, "judge_form": judge_form, - "native_profile": native_profile + "native_profile": native_profile, + "easyProblems": easyProblems, + "mediumProblems": mediumProblems, + "hardProblems": hardProblems, + "veasyProblems": veasyProblems, + "totalProblemsSolved": totalProblemsSolved, } return render(request, 'user_profile/profile.html', context=context) else: