From ae6a6b14510c31c2e760e90242f922ab54a04251 Mon Sep 17 00:00:00 2001
From: Anders Bruun Severinsen <202204885@post.au.dk>
Date: Mon, 23 Dec 2024 22:04:35 +0100
Subject: [PATCH] Remove shift streak display logic from about page and
simplify context data retrieval
---
web/templates/about.html | 21 ---------------------
web/views.py | 21 ---------------------
2 files changed, 42 deletions(-)
diff --git a/web/templates/about.html b/web/templates/about.html
index 14d7b98..a7f0daa 100644
--- a/web/templates/about.html
+++ b/web/templates/about.html
@@ -27,27 +27,6 @@
{% translate "Åbningstider" %}
{% translate "Pt. har baren været åben" %} {{ shift_streak }}{% bs_icon 'fire' size='0.8em' %} {% blocktranslate count c=shift_streak %}uge{% plural %}uger{% endblocktranslate %} {% translate "i streg, som startede" %} {% translate "d." context "d. 1. i 1." %} {{ shift_streak_start_date }}.
- {% if shift_streaks %}
-
-
-
- {% translate "Placering" %} |
- {% translate "Streak" %} |
- {% translate "Start - Slut" %} |
-
-
-
- {% for streak in shift_streaks %}
-
- {{ forloop.counter }} |
- {{ streak.0}}{% if forloop.counter == shift_placement %}{% bs_icon 'fire' size='0.8em' %}{% endif%} |
- {{ streak.1| date:"d M, Y" }} - {{ streak.2| date:"d M, Y" }} |
-
- {% endfor %}
-
-
- {% endif %}
-
{% translate "Direktion" %}
diff --git a/web/views.py b/web/views.py
index a25d137..a46794d 100644
--- a/web/views.py
+++ b/web/views.py
@@ -61,34 +61,13 @@ class About(TemplateView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
shifts = BartenderShift.objects.all().filter(end_datetime__lte=timezone.now())
- shift_streaks = []
- for shift in shifts:
- shift_streaks.append(shift.streak())
- sorted_shift_streaks = sorted(shift_streaks, key=lambda x: x[0], reverse=True)
- sorted_shift_streaks_short = []
- for shift in sorted_shift_streaks:
- found = False
- for sorted_shift in sorted_shift_streaks_short:
- if shift[1] == sorted_shift[1]:
- found = True
- break
- if not found:
- sorted_shift_streaks_short.append(shift)
- context["shift_streaks"] = sorted_shift_streaks_short[:5]
current_shift = shifts.filter(
start_datetime__lte=timezone.now() + datetime.timedelta(days=2),
end_datetime__gte=timezone.now() - datetime.timedelta(days=5),
)
if current_shift:
shift_streak, start_date, _ = current_shift[0].streak()
-
- shift_placement = 0
- for i, shift in enumerate(sorted_shift_streaks):
- if shift[2] == current_shift[0].end_datetime:
- shift_placement = i + 1
- break
context["shift_streak"] = shift_streak
context["shift_streak_start_date"] = start_date.date()
- context["shift_placement"] = shift_placement
return context