diff --git a/db.sqlite3 b/db.sqlite3 index f2574ce..e42d6e9 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/mensa_app/__pycache__/__init__.cpython-314.pyc b/mensa_app/__pycache__/__init__.cpython-314.pyc index ac18d10..46c3669 100644 Binary files a/mensa_app/__pycache__/__init__.cpython-314.pyc and b/mensa_app/__pycache__/__init__.cpython-314.pyc differ diff --git a/mensa_app/__pycache__/admin.cpython-314.pyc b/mensa_app/__pycache__/admin.cpython-314.pyc index de80568..a5ef4df 100644 Binary files a/mensa_app/__pycache__/admin.cpython-314.pyc and b/mensa_app/__pycache__/admin.cpython-314.pyc differ diff --git a/mensa_app/__pycache__/apps.cpython-314.pyc b/mensa_app/__pycache__/apps.cpython-314.pyc index 7d5b56e..13e3337 100644 Binary files a/mensa_app/__pycache__/apps.cpython-314.pyc and b/mensa_app/__pycache__/apps.cpython-314.pyc differ diff --git a/mensa_app/__pycache__/models.cpython-314.pyc b/mensa_app/__pycache__/models.cpython-314.pyc index e0fd0fa..010479e 100644 Binary files a/mensa_app/__pycache__/models.cpython-314.pyc and b/mensa_app/__pycache__/models.cpython-314.pyc differ diff --git a/mensa_app/__pycache__/urls.cpython-314.pyc b/mensa_app/__pycache__/urls.cpython-314.pyc new file mode 100644 index 0000000..b35e61b Binary files /dev/null and b/mensa_app/__pycache__/urls.cpython-314.pyc differ diff --git a/mensa_app/__pycache__/views.cpython-314.pyc b/mensa_app/__pycache__/views.cpython-314.pyc new file mode 100644 index 0000000..22b19f4 Binary files /dev/null and b/mensa_app/__pycache__/views.cpython-314.pyc differ diff --git a/mensa_app/migrations/__pycache__/0001_initial.cpython-314.pyc b/mensa_app/migrations/__pycache__/0001_initial.cpython-314.pyc index 42952ee..190f65f 100644 Binary files a/mensa_app/migrations/__pycache__/0001_initial.cpython-314.pyc and b/mensa_app/migrations/__pycache__/0001_initial.cpython-314.pyc differ diff --git a/mensa_app/migrations/__pycache__/0002_alter_bestellung_options_alter_gericht_options_and_more.cpython-314.pyc b/mensa_app/migrations/__pycache__/0002_alter_bestellung_options_alter_gericht_options_and_more.cpython-314.pyc index 973cd09..cae7689 100644 Binary files a/mensa_app/migrations/__pycache__/0002_alter_bestellung_options_alter_gericht_options_and_more.cpython-314.pyc and b/mensa_app/migrations/__pycache__/0002_alter_bestellung_options_alter_gericht_options_and_more.cpython-314.pyc differ diff --git a/mensa_app/migrations/__pycache__/0003_schulwoche_alter_gericht_time_creation_and_more.cpython-314.pyc b/mensa_app/migrations/__pycache__/0003_schulwoche_alter_gericht_time_creation_and_more.cpython-314.pyc index a82d32d..680e53d 100644 Binary files a/mensa_app/migrations/__pycache__/0003_schulwoche_alter_gericht_time_creation_and_more.cpython-314.pyc and b/mensa_app/migrations/__pycache__/0003_schulwoche_alter_gericht_time_creation_and_more.cpython-314.pyc differ diff --git a/mensa_app/migrations/__pycache__/0004_alter_gericht_time_creation_and_more.cpython-314.pyc b/mensa_app/migrations/__pycache__/0004_alter_gericht_time_creation_and_more.cpython-314.pyc index f97feed..c33415e 100644 Binary files a/mensa_app/migrations/__pycache__/0004_alter_gericht_time_creation_and_more.cpython-314.pyc and b/mensa_app/migrations/__pycache__/0004_alter_gericht_time_creation_and_more.cpython-314.pyc differ diff --git a/mensa_app/migrations/__pycache__/__init__.cpython-314.pyc b/mensa_app/migrations/__pycache__/__init__.cpython-314.pyc index 2acbc8d..cc7d1ea 100644 Binary files a/mensa_app/migrations/__pycache__/__init__.cpython-314.pyc and b/mensa_app/migrations/__pycache__/__init__.cpython-314.pyc differ diff --git a/mensa_app/templates/mensa_app/gericht_list.html b/mensa_app/templates/mensa_app/gericht_list.html new file mode 100644 index 0000000..788bf21 --- /dev/null +++ b/mensa_app/templates/mensa_app/gericht_list.html @@ -0,0 +1,55 @@ + + + + + + Mensa-Speisekarte + + + + + +
+
+
+
+
+

Unsere Speisekarte

+
+
+ + + + + + + + + + {% for gericht in alle_gerichte %} + + + + + + {% empty %} + + + + {% endfor %} + +
GerichtKategorieStatus
{{ gericht.name }}{{ gericht.kategorie.name }} + {% if gericht.ist_dauerangebot %} + Dauerangebot + {% else %} + Tagesangebot + {% endif %} +
Keine Gerichte im System gefunden.
+
+
+
+
+
+ + + diff --git a/mensa_app/urls.py b/mensa_app/urls.py new file mode 100644 index 0000000..60835bc --- /dev/null +++ b/mensa_app/urls.py @@ -0,0 +1,8 @@ +from django.urls import path +from .views import GerichtListView +from .views import SpeiseplanView # Achte auf den neuen Klassennamen! + +urlpatterns = [ + path('speisekarte/', GerichtListView.as_view(), name='gericht_list'), + path('speiseplan/', SpeiseplanView.as_view(), name='speiseplan'), +] diff --git a/mensa_app/views.py b/mensa_app/views.py index 91ea44a..5cb7a01 100644 --- a/mensa_app/views.py +++ b/mensa_app/views.py @@ -1,3 +1,50 @@ from django.shortcuts import render # Create your views here. +from django.views.generic import ListView +from .models import Gericht + +class GerichtListView(ListView): + model = Gericht + template_name = 'mensa_app/gericht_liste.html' # Der Pfad zum Template + context_object_name = 'alle_gerichte' # Der Name, den wir im Template nutzen + +from django.views.generic import TemplateView +from django.utils import timezone +from datetime import datetime +from .models import Menue, Gericht, SpeiseplanTag + +class SpeiseplanView(TemplateView): + template_name = 'mensa_app/speiseplan.html' + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + + # 1. Datum aus der URL holen (z.B. ?datum=2023-10-27) + # Wenn kein Datum angegeben ist, nehmen wir heute. + date_str = self.request.GET.get('datum') + if date_str: + try: + target_date = datetime.strptime(date_str, '%Y-%m-%d').date() + except ValueError: + target_date = timezone.glob.now().date() + else: + target_date = timezone.now().date() + + # 2. Menüs für diesen spezifischen Tag laden + # Wir suchen alle Menüs, deren Tag das target_date hat + context['target_date'] = target_date + context['menues_day'] = Menue.objects.filter(tag__datum=target_date) + + # 3. Dauerangebote laden (unabhängig vom Tag) + context['dauerangebote'] = Gericht.objects.filter(ist_dauerangebot=True) + + # 4. Pager-Logik: Vorherigen und nächsten Tag finden + # Wir suchen in der Tabelle SpeiseplanTag nach dem Tag davor/danach + prev_tag = SpeiseplanTag.objects.filter(datum__lt=target_date).order_by('-datum').first() + next_tag = SpeiseplanTag.objects.filter(datum__gt=target_date).order_by('datum').first() + + context['prev_date'] = prev_tag.datum.strftime('%Y-%m-%d') if prev_tag else None + context['next_date'] = next_tag.datum.strftime('%Y-%m-%d') if next_tag else None + + return context diff --git a/mensa_core/__pycache__/__init__.cpython-314.pyc b/mensa_core/__pycache__/__init__.cpython-314.pyc index c6998ec..f6c0a1c 100644 Binary files a/mensa_core/__pycache__/__init__.cpython-314.pyc and b/mensa_core/__pycache__/__init__.cpython-314.pyc differ diff --git a/mensa_core/__pycache__/settings.cpython-314.pyc b/mensa_core/__pycache__/settings.cpython-314.pyc index ddbc640..4d35f6d 100644 Binary files a/mensa_core/__pycache__/settings.cpython-314.pyc and b/mensa_core/__pycache__/settings.cpython-314.pyc differ diff --git a/mensa_core/__pycache__/urls.cpython-314.pyc b/mensa_core/__pycache__/urls.cpython-314.pyc index 262e0fa..05686aa 100644 Binary files a/mensa_core/__pycache__/urls.cpython-314.pyc and b/mensa_core/__pycache__/urls.cpython-314.pyc differ diff --git a/mensa_core/__pycache__/wsgi.cpython-314.pyc b/mensa_core/__pycache__/wsgi.cpython-314.pyc index b95635b..ebd799d 100644 Binary files a/mensa_core/__pycache__/wsgi.cpython-314.pyc and b/mensa_core/__pycache__/wsgi.cpython-314.pyc differ diff --git a/mensa_core/urls.py b/mensa_core/urls.py index 29c5021..da1dfc9 100644 --- a/mensa_core/urls.py +++ b/mensa_core/urls.py @@ -15,8 +15,9 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), + path('', include('mensa_app.urls')), # Schaltet die App-URLs frei ]