Skip to content

Commit

Permalink
Remove shift streak display logic from about page and simplify contex…
Browse files Browse the repository at this point in the history
…t data retrieval
  • Loading branch information
AndersSeverinsen committed Dec 23, 2024
1 parent 9e27013 commit ae6a6b1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
21 changes: 0 additions & 21 deletions web/templates/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,6 @@ <h3>{% translate "Åbningstider" %}</h3>
{% translate "Pt. har baren været åben" %} <b><i>{{ shift_streak }}{% bs_icon 'fire' size='0.8em' %}</i></b> {% blocktranslate count c=shift_streak %}uge{% plural %}uger{% endblocktranslate %} {% translate "i streg, som startede" %} <b>{% translate "d." context "d. 1. i 1." %} {{ shift_streak_start_date }}</b>.
</p>

{% if shift_streaks %}
<table class="table table-striped tablesorter" id="items">
<thead>
<tr>
<th>{% translate "Placering" %}</th>
<th>{% translate "Streak" %}</th>
<th>{% translate "Start - Slut" %}</th>
</tr>
</thead>
<tbody>
{% for streak in shift_streaks %}
<tr>
<td class="col-md-1">{{ forloop.counter }}</td>
<td class="col-md-1">{{ streak.0}}{% if forloop.counter == shift_placement %}{% bs_icon 'fire' size='0.8em' %}{% endif%}</td>
<td>{{ streak.1| date:"d M, Y" }} - {{ streak.2| date:"d M, Y" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}

<hr>

<h2>{% translate "Direktion" %}</h2>
Expand Down
21 changes: 0 additions & 21 deletions web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ae6a6b1

Please sign in to comment.