From 74607111e8b102b73c98fa231b4e8777b4fdb705 Mon Sep 17 00:00:00 2001 From: MMcLovin Date: Fri, 24 Nov 2023 13:37:58 -0300 Subject: [PATCH 01/14] fix: removed FINISHED from is_accessible conditions --- apps/tasks/models.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/tasks/models.py b/apps/tasks/models.py index 3443d00..f5e608c 100644 --- a/apps/tasks/models.py +++ b/apps/tasks/models.py @@ -25,7 +25,4 @@ def __str__(self) -> str: @property def is_accessible(self) -> bool: - return self.contest.status in ( - ContestStatus.RUNNING, - ContestStatus.FINISHED, - ) + return self.contest.status in (ContestStatus.RUNNING,) From 07d6e7c57729a32d838c4e5ba694effc49e9dc51 Mon Sep 17 00:00:00 2001 From: MMcLovin <122990047+MMcLovin@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:48:51 -0300 Subject: [PATCH 02/14] Revert "fix: removed FINISHED from is_accessible conditions" This reverts commit 74607111e8b102b73c98fa231b4e8777b4fdb705. --- apps/tasks/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/tasks/models.py b/apps/tasks/models.py index f5e608c..3443d00 100644 --- a/apps/tasks/models.py +++ b/apps/tasks/models.py @@ -25,4 +25,7 @@ def __str__(self) -> str: @property def is_accessible(self) -> bool: - return self.contest.status in (ContestStatus.RUNNING,) + return self.contest.status in ( + ContestStatus.RUNNING, + ContestStatus.FINISHED, + ) From bb5cca41975924ba240268def7c7577b99f4da7c Mon Sep 17 00:00:00 2001 From: HladczukLe Date: Sun, 26 Nov 2023 17:26:04 -0300 Subject: [PATCH 03/14] feat: add others users page --- apps/users/models.py | 2 ++ apps/users/views.py | 9 ++++++++- templates/base.html | 6 +++--- templates/users/profile.html | 23 +++++++++++++---------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/apps/users/models.py b/apps/users/models.py index 542ad76..2de4491 100644 --- a/apps/users/models.py +++ b/apps/users/models.py @@ -19,6 +19,8 @@ class User(AbstractBaseUser, PermissionsMixin, TimestampedModel): email = EmailField(db_index=True, max_length=256, unique=True) username = CharField(db_index=True, max_length=128, unique=True) + score = 0 + contest = 0 # When a user no longer wishes to use our platform, they may try to # delete there account. That's a problem for us because the data we diff --git a/apps/users/views.py b/apps/users/views.py index abadc59..fa23b21 100644 --- a/apps/users/views.py +++ b/apps/users/views.py @@ -33,4 +33,11 @@ class ProfileView(View): def get(self, request: HttpRequest, user_username: str) -> HttpResponse: user = get_object_or_404(User, username=user_username) - return render(request, self.template_name, {"user": user}) + + is_own_profile = user == request.user + + return render( + request, + self.template_name, + {"user": user, "is_own_profile": is_own_profile}, + ) diff --git a/templates/base.html b/templates/base.html index 506bc82..ebbd635 100644 --- a/templates/base.html +++ b/templates/base.html @@ -71,7 +71,7 @@ - {% if user.is_authenticated %} + {% if request.user.is_authenticated %}