From e8575d559e592b9cce54f5628aad67721e5d0f3f Mon Sep 17 00:00:00 2001 From: Starthur Date: Tue, 29 Mar 2022 18:46:19 +0200 Subject: [PATCH 1/4] Add campuses scoreboard --- src/scoreboard/templates/scoreboard/scoreboard.html | 7 +++++++ src/scoreboard/urls.py | 3 ++- src/scoreboard/views.py | 9 ++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/scoreboard/templates/scoreboard/scoreboard.html b/src/scoreboard/templates/scoreboard/scoreboard.html index c00c8d1..ff3064f 100644 --- a/src/scoreboard/templates/scoreboard/scoreboard.html +++ b/src/scoreboard/templates/scoreboard/scoreboard.html @@ -12,6 +12,7 @@ {% trans "Rank" %} {% trans "Username" %} {% trans "Website" %} + {% trans "Campus" %} {% trans "Score" %} @@ -26,6 +27,12 @@ {{ s.user.userprofileinfo.portfolio_site }} {% endif %} + + {% if s.user.userprofileinfo.intra42_campus %} + + {{ s.user.userprofileinfo.intra42_campus }} + + {% endif %} {{ s.user.userprofileinfo.score }} {% endfor %} diff --git a/src/scoreboard/urls.py b/src/scoreboard/urls.py index ee31136..5f95344 100644 --- a/src/scoreboard/urls.py +++ b/src/scoreboard/urls.py @@ -4,5 +4,6 @@ from . import views app_name = "scoreboard" urlpatterns = [ - path('', views.scoreboard, name='scoreboard') + path('', views.scoreboard, name='scoreboard'), + path('campus/', views.campus, name='campus') ] diff --git a/src/scoreboard/views.py b/src/scoreboard/views.py index edeb925..1aeb356 100644 --- a/src/scoreboard/views.py +++ b/src/scoreboard/views.py @@ -8,5 +8,12 @@ def scoreboard(request): page = request.GET.get('page') scores_p = paginator.get_page(page) return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p}) - + +def campus(request, campus): + scores = UserProfileInfo.objects.filter(score__gt=0, intra42_campus__exact=campus).select_related().order_by('-score', 'last_submission_date', 'user__username') + paginator = Paginator(scores, 20) + page = request.GET.get('page') + scores_p = paginator.get_page(page) + return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p}) + # Create your views here. From 3991dda7d3852dde27538adcd176056aa9a214af Mon Sep 17 00:00:00 2001 From: Starthur Date: Tue, 29 Mar 2022 18:55:54 +0200 Subject: [PATCH 2/4] HTML typo --- src/scoreboard/templates/scoreboard/scoreboard.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scoreboard/templates/scoreboard/scoreboard.html b/src/scoreboard/templates/scoreboard/scoreboard.html index ff3064f..af7442b 100644 --- a/src/scoreboard/templates/scoreboard/scoreboard.html +++ b/src/scoreboard/templates/scoreboard/scoreboard.html @@ -29,10 +29,11 @@ {% if s.user.userprofileinfo.intra42_campus %} - - {{ s.user.userprofileinfo.intra42_campus }} - + + {{ s.user.userprofileinfo.intra42_campus }} + {% endif %} + {{ s.user.userprofileinfo.score }} {% endfor %} From 978dd24a0055d9be45135e461cedc1206702ed4b Mon Sep 17 00:00:00 2001 From: Starthur Date: Tue, 29 Mar 2022 18:46:19 +0200 Subject: [PATCH 3/4] Add campuses scoreboard --- src/scoreboard/templates/scoreboard/scoreboard.html | 7 +++++++ src/scoreboard/urls.py | 3 ++- src/scoreboard/views.py | 9 ++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/scoreboard/templates/scoreboard/scoreboard.html b/src/scoreboard/templates/scoreboard/scoreboard.html index c00c8d1..ff3064f 100644 --- a/src/scoreboard/templates/scoreboard/scoreboard.html +++ b/src/scoreboard/templates/scoreboard/scoreboard.html @@ -12,6 +12,7 @@ {% trans "Rank" %} {% trans "Username" %} {% trans "Website" %} + {% trans "Campus" %} {% trans "Score" %} @@ -26,6 +27,12 @@ {{ s.user.userprofileinfo.portfolio_site }} {% endif %} + + {% if s.user.userprofileinfo.intra42_campus %} + + {{ s.user.userprofileinfo.intra42_campus }} + + {% endif %} {{ s.user.userprofileinfo.score }} {% endfor %} diff --git a/src/scoreboard/urls.py b/src/scoreboard/urls.py index ee31136..5f95344 100644 --- a/src/scoreboard/urls.py +++ b/src/scoreboard/urls.py @@ -4,5 +4,6 @@ from . import views app_name = "scoreboard" urlpatterns = [ - path('', views.scoreboard, name='scoreboard') + path('', views.scoreboard, name='scoreboard'), + path('campus/', views.campus, name='campus') ] diff --git a/src/scoreboard/views.py b/src/scoreboard/views.py index edeb925..1aeb356 100644 --- a/src/scoreboard/views.py +++ b/src/scoreboard/views.py @@ -8,5 +8,12 @@ def scoreboard(request): page = request.GET.get('page') scores_p = paginator.get_page(page) return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p}) - + +def campus(request, campus): + scores = UserProfileInfo.objects.filter(score__gt=0, intra42_campus__exact=campus).select_related().order_by('-score', 'last_submission_date', 'user__username') + paginator = Paginator(scores, 20) + page = request.GET.get('page') + scores_p = paginator.get_page(page) + return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p}) + # Create your views here. From e23d6d7f4980c1ce216488489beb88fe96a8a5dd Mon Sep 17 00:00:00 2001 From: Starthur Date: Tue, 29 Mar 2022 18:55:54 +0200 Subject: [PATCH 4/4] HTML typo --- src/scoreboard/templates/scoreboard/scoreboard.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scoreboard/templates/scoreboard/scoreboard.html b/src/scoreboard/templates/scoreboard/scoreboard.html index ff3064f..af7442b 100644 --- a/src/scoreboard/templates/scoreboard/scoreboard.html +++ b/src/scoreboard/templates/scoreboard/scoreboard.html @@ -29,10 +29,11 @@ {% if s.user.userprofileinfo.intra42_campus %} - - {{ s.user.userprofileinfo.intra42_campus }} - + + {{ s.user.userprofileinfo.intra42_campus }} + {% endif %} + {{ s.user.userprofileinfo.score }} {% endfor %}