diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 55621a41..0b7a19b0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ exclude: 'static/.*' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: check-merge-conflict - id: check-added-large-files - repo: https://github.com/psf/black - rev: 24.3.0 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/PyCQA/isort @@ -16,6 +16,6 @@ repos: hooks: - id: isort - repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 + rev: 7.1.1 hooks: - id: flake8 diff --git a/nablapps/core/views.py b/nablapps/core/views.py index 5bf94169..e3ca6db3 100644 --- a/nablapps/core/views.py +++ b/nablapps/core/views.py @@ -15,7 +15,7 @@ from nablapps.blog.models import BlogPost from ..accounts.models import FysmatClass -from ..events.models import Event +from ..events.models import Event, EventRegistration from ..nabladet.models import Nablad from ..nablaforum.models import Channel, Message, Thread from ..news.models import FrontPageNews @@ -67,6 +67,11 @@ def get_context_data(self, **kwargs): context["logged_in"] = True if self.request.user.is_authenticated else False # Uncomment when fadderperiode to display new student popup. # context["newuser_popup"] = False if self.request.user.is_authenticated else True + + # TODO: fiks SQL query + context["bedpres_leaderboard"] = EventRegistration.objects.raw( + """SELECT COUNT(attendance_registration), username from EventRegistration JOIN users WHERE EventRegistration.userId = users.id JOIN event where EventRegistration.eventId = event.id WHERE EventRegistration.date > "2024 - 08 - 10" AND EventRegistration.date < "2025 - 06 - 20" AND event.is_bedpres GROUP BY userId LIMIT 10""" + ) return context def _add_news(self, context): diff --git a/static/css/front_page.css b/static/css/front_page.css index e72b1b4c..3495cb5d 100644 --- a/static/css/front_page.css +++ b/static/css/front_page.css @@ -157,6 +157,10 @@ grid-area: poll; } +.leaderboard { + grid-area: leaderboard; +} + .latest-podcast { grid-area: latest-podcast; } diff --git a/templates/front_page.html b/templates/front_page.html index c2c1369d..0cc3676f 100644 --- a/templates/front_page.html +++ b/templates/front_page.html @@ -68,7 +68,16 @@
Bruker | Antall Bedpres |
---|---|
{{t.user.get_full_name}} | +{{t.length}} | +