Skip to content

Commit

Permalink
Update context data to include latest tab update and handle guide pat…
Browse files Browse the repository at this point in the history
…h availability
  • Loading branch information
AndersSeverinsen committed Dec 30, 2024
1 parent 01c3487 commit 97da154
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 73 deletions.
12 changes: 10 additions & 2 deletions bartab/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,20 @@ def get_context():
for user in BarTabUser.objects.exclude(hidden_from_tab=True):
tab_parts[not user.is_active][0].append(user)

latest_tab_update = BarTabSnapshot.objects.first()
guide_path = settings.MEDIA_ROOT + f"guides/krydsliste.pdf"
try:
with open(guide_path, "rb") as f:
pass
except FileNotFoundError:
guide_path = None

return {
"tab_parts": tab_parts,
"pizza_lines": range(33),
"latest_shift": BarTabSnapshot.objects.first().date,
"latest_tab_update": latest_tab_update,
"logo_path": settings.STATIC_ROOT + f"images/logo_gray.png",
"guide_path": settings.MEDIA_ROOT + f"guides/krydsliste.pdf",
"guide_path": guide_path,
}


Expand Down
6 changes: 5 additions & 1 deletion bartab/templates/bartab.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

<h2>{% translate "Krydslisteaktivitet" %}</h2>

<p>{% translate "Krydslisten er gjort op til og med barvagten d." %} {{ update_date }}.</p>
{% if latest_tab_update %}
<p>{% translate "Krydslisten er gjort op til og med barvagten d." %} {{ latest_tab_update.date }}.</p>
{% else %}
<p>{% translate "Krydslisten er endnu ikke opdateret." %}</p>
{% endif %}

{% if object %}
<h3>{% translate "Saldo" %}: {{ object.balance_str }}</h3>
Expand Down
22 changes: 12 additions & 10 deletions bartab/templates/bartab/bartab.tex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
\savebox\innertable{%
\begin{tabu}{r}
{\Large Genereret: {% now "j. F Y" %} } \\
{\Large Opgjort til og med vagt: {{ latest_shift|date:"j. F Y" }} }
{% if latest_tab_update %}
{\Large Opgjort til og med vagt: {{ latest_tab_update.date|date:"j. F Y" }} }
{% else %}
{\Large Endnu ikke opgjort }
{% endif %}
\end{tabu}%
}
{% else %}\newpage{% endif %}
Expand All @@ -64,9 +68,7 @@
{% endfor %}
% Make sure Pizza list is on a even page
\mbox{~}
\clearpage
% Make sure guide is on an even page
\strictpagechecktrue
\checkoddpage
Expand All @@ -80,7 +82,11 @@
\begin{landscape}
\iffalse
{% if guide_path %}
\includepdf[pages=1, angle=90]{
{{ guide_path }}
}
{% else %}
\LARGE
\section*{Pizzabestilling}
\begin{tabu} to \linewidth{| X[1] | X[14] |}
Expand All @@ -90,11 +96,7 @@ \section*{Pizzabestilling}
{% for i in pizza_lines %}& \\ \hline{% endfor %}
\end{tabu}
\fi
\includepdf[pages=1, angle=90]{
{{ guide_path }}
}
{% endif %}
\end{landscape}
Expand Down
2 changes: 1 addition & 1 deletion bartab/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_object(self):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)

context["update_date"] = BarTabSnapshot.objects.first().date
context["latest_tab_update"] = BarTabSnapshot.objects.first()
context["credit_hold_limit"] = BarTabUser.CREDIT_HOLD_LIMIT

if not self.object:
Expand Down
2 changes: 2 additions & 0 deletions fredagscafeen/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
messages.ERROR: "alert-danger",
}

TIMEOUT = 600

# SECURITY WARNING: don't run with debug turned on in production!

# ALLOWED_HOSTS = ['*']
Expand Down
50 changes: 27 additions & 23 deletions locale/da/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-27 23:29+0100\n"
"POT-Creation-Date: 2024-12-30 13:04+0100\n"
"PO-Revision-Date: 2024-12-23 21:27+0050\n"
"Last-Translator: <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -39,11 +39,11 @@ msgstr "Skal have enten bartendervagt eller tilpasset datetime"
msgid "Kontant?"
msgstr "Kontant?"

#: bartab/models.py:138 bartab/templates/bartab.html:20
#: bartab/models.py:138 bartab/templates/bartab.html:24
msgid "Indsat"
msgstr "Indsat"

#: bartab/models.py:139 bartab/templates/bartab.html:21
#: bartab/models.py:139 bartab/templates/bartab.html:25
msgid "Køb"
msgstr "Køb"

Expand All @@ -59,24 +59,28 @@ msgstr "Invalid sum"
msgid "Krydslisteaktivitet"
msgstr "Krydslisteaktivitet"

#: bartab/templates/bartab.html:10
#: bartab/templates/bartab.html:11
msgid "Krydslisten er gjort op til og med barvagten d."
msgstr "Krydslisten er gjort op til og med barvagten d."

#: bartab/templates/bartab.html:13 bartab/templates/bartab.html:22
#: bartab/templates/bartab.html:13
msgid "Krydslisten er endnu ikke opdateret."
msgstr ""

#: bartab/templates/bartab.html:17 bartab/templates/bartab.html:26
msgid "Saldo"
msgstr "Saldo"

#: bartab/templates/bartab.html:14
#: bartab/templates/bartab.html:18
msgid "Total forbrug"
msgstr "Total forbrug"

#: bartab/templates/bartab.html:19 bartenders/templates/barplan.html:31
#: bartab/templates/bartab.html:23 bartenders/templates/barplan.html:31
#: gallery/models.py:101
msgid "Dato"
msgstr "Dato"

#: bartab/templates/bartab.html:37
#: bartab/templates/bartab.html:41
msgid "er ikke på krydslisten."
msgstr "er ikke på krydslisten."

Expand Down Expand Up @@ -299,7 +303,7 @@ msgstr ""
msgid "Tidligere"
msgstr ""

#: bartenders/templates/board.html:30 web/templates/base.html:91
#: bartenders/templates/board.html:30 web/templates/base.html:90
msgid "Bestyrelsen"
msgstr ""

Expand Down Expand Up @@ -515,11 +519,11 @@ msgstr "Ja"
msgid "No"
msgstr "Nej"

#: fredagscafeen/settings/base.py:271
#: fredagscafeen/settings/base.py:273
msgid "Danish"
msgstr "Dansk"

#: fredagscafeen/settings/base.py:272
#: fredagscafeen/settings/base.py:274
msgid "English"
msgstr "Engelsk"

Expand Down Expand Up @@ -1401,6 +1405,10 @@ msgstr ""
msgid "Forside"
msgstr ""

#: web/templates/base.html:77 web/templates/base.html:93
msgid "Sortiment"
msgstr ""

#: web/templates/base.html:80
msgid "Udlejning"
msgstr ""
Expand All @@ -1421,43 +1429,39 @@ msgstr ""
msgid "Udlejning af højtalere"
msgstr ""

#: web/templates/base.html:92
#: web/templates/base.html:91
msgid "Events"
msgstr ""

#: web/templates/base.html:93
#: web/templates/base.html:92
msgid "Gallery"
msgstr "Galleri"

#: web/templates/base.html:94
msgid "Sortiment"
msgstr ""

#: web/templates/base.html:95
msgid "Om baren"
msgstr ""

#: web/templates/base.html:97
#: web/templates/base.html:96
msgid "Profil"
msgstr ""

#: web/templates/base.html:99
#: web/templates/base.html:98
msgid "Krydlistestatus"
msgstr ""

#: web/templates/base.html:101
#: web/templates/base.html:100
msgid "Bartenderprofil"
msgstr ""

#: web/templates/base.html:104
#: web/templates/base.html:103
msgid "Admin"
msgstr ""

#: web/templates/base.html:109
#: web/templates/base.html:108
msgid "Log ud"
msgstr ""

#: web/templates/base.html:148
#: web/templates/base.html:146
msgid "er en fredagsbar for datalogi og IT på Aarhus Universitet."
msgstr ""

Expand Down
Binary file modified locale/en/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 97da154

Please sign in to comment.