root 1 年間 前
コミット
0bd47eb1f2
8 ファイル変更60 行追加16 行削除
  1. 12 0
      .idea/dataSources.xml
  2. 1 1
      .idea/misc.xml
  3. 1 1
      AD/settings.py
  4. BIN
      db.sqlite3
  5. 2 2
      main/urls.py
  6. 12 0
      main/views.py
  7. 12 11
      templates/main/current_week_shifts.html
  8. 20 1
      templates/main/public.html

+ 12 - 0
.idea/dataSources.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="DataSourceManagerImpl" format="xml" multifile-model="true">
+    <data-source source="LOCAL" name="db" uuid="d5ffd040-e2e0-46ca-b68d-327adb4093dc">
+      <driver-ref>sqlite.xerial</driver-ref>
+      <synchronize>true</synchronize>
+      <jdbc-driver>org.sqlite.JDBC</jdbc-driver>
+      <jdbc-url>jdbc:sqlite:$PROJECT_DIR$/db.sqlite3</jdbc-url>
+      <working-dir>$ProjectFileDir$</working-dir>
+    </data-source>
+  </component>
+</project>

+ 1 - 1
.idea/misc.xml

@@ -3,5 +3,5 @@
   <component name="Black">
     <option name="sdkName" value="Python 3.12 (AD)" />
   </component>
-  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (AD)" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (AD)" project-jdk-type="Python SDK" />
 </project>

+ 1 - 1
AD/settings.py

@@ -130,4 +130,4 @@ STATICFILES_DIRS = [
 DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
 
 LOGIN_REDIRECT_URL = '/current-week-shifts/'
-LOGOUT_REDIRECT_URL = '/public'
+LOGOUT_REDIRECT_URL = '/'

BIN
db.sqlite3


+ 2 - 2
main/urls.py

@@ -19,6 +19,6 @@ urlpatterns = [
     path('edit-event/<int:pk>/', edit_event, name='edit_event'),
     path('delete-event/<int:pk>/', delete_event, name='delete_event'),
     path('login/', auth_views.LoginView.as_view(template_name='registration/login.html'), name='login'),
-    path('logout/', auth_views.LogoutView.as_view(next_page='/public'), name='logout'),
-    path('public/', public, name='public'),
+    path('logout/', auth_views.LogoutView.as_view(next_page='/'), name='logout'),
+    path('', public, name='public'),
 ]

+ 12 - 0
main/views.py

@@ -199,8 +199,10 @@ def public(request):
     # Initialisiere ein Dictionary für die Schichten der Mitarbeiter
     shifts_by_employee = {}
     events_by_location = {}
+    helpers_by_date = {}
     employees = Employee.objects.all()
     locations = Location.objects.all()
+    helpers = Helper.objects.all()
 
     for employee in employees:
         shifts_by_employee[employee] = {day: None for day in range(7)}
@@ -208,11 +210,16 @@ def public(request):
     for location in locations:
         events_by_location[location] = {day: None for day in range(7)}
 
+    for helper in helpers:
+        helpers_by_date = {day: None for day in range(7)}
+
         # Hole alle Schichten für die aktuelle Woche
     shifts = Shift.objects.filter(date__range=[start_of_week, end_of_week])
 
     events = Event.objects.filter(date__range=[start_of_week, end_of_week])
 
+    helpers = Helper.objects.filter(date__range=[start_of_week, end_of_week])
+
     print(events)
     # Fülle das Dictionary mit den Schichtdaten
     for shift in shifts:
@@ -225,6 +232,10 @@ def public(request):
         day_of_week = (event.date - start_of_week).days
         events_by_location[location][day_of_week] = event
 
+    for helper in helpers:
+        day_of_week = (helper.date - start_of_week).days
+        helpers_by_date[day_of_week] = helper
+
     # Bereite die Daten der Woche für das Template vor
     week_dates = [(start_of_week + timedelta(days=i)).strftime("%d.%m.%Y") for i in range(7)]
     days_of_week = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']
@@ -233,6 +244,7 @@ def public(request):
     context = {
         'shifts_by_employee': shifts_by_employee,
         'events_by_location': events_by_location,
+        'helpers_by_date': helpers_by_date,
         'start_of_week': start_of_week,
         'end_of_week': end_of_week,
         'days_with_dates': days_with_dates,

+ 12 - 11
templates/main/current_week_shifts.html

@@ -79,17 +79,18 @@
     </style>
 </head>
 <body>
-    <div class="buttons-container">
-        <a href="?start_date={{ previous_week }}" class="btn btn-primary">Eine Woche zurück</a>
-        <a href="/current-week-shifts/" class="btn btn-primary">Aktuelle Woche</a>
-        <form method="post" action="{% url 'logout' %}" style="display: inline;">
-            {% csrf_token %}
-            <button type="submit" class="btn btn-secondary">Logout</button>
-        </form>
-        <a href="?start_date={{ next_week }}" class="btn btn-primary">Eine Woche vorwärts</a>
-    </div>
-    <div class="container-fluid">
-        <h4 class="custom-heading">Dienstplan für KW {{ calendar_week }}</h4>
+      <div class="container-fluid">
+        <h4 class="custom-heading">Dienstplan für KW {{ calendar_week }}
+
+            <a href="?start_date={{ previous_week }}" class="btn btn-primary">Eine Woche zurück</a>
+            <a href="/current-week-shifts/" class="btn btn-primary">Aktuelle Woche</a>
+            <form method="post" action="{% url 'logout' %}" style="display: inline;">
+             {% csrf_token %}
+                <button type="submit" class="btn btn-secondary">Logout</button>
+            </form>
+            <a href="?start_date={{ next_week }}" class="btn btn-primary">Eine Woche vorwärts</a></h4>
+
+
         <div class="table-responsive">
             <table class="table table-bordered table-striped table-hover w-100">
                 <thead class="table-dark">

+ 20 - 1
templates/main/public.html

@@ -6,7 +6,7 @@
 <html lang="de">
 <head>
     <meta charset="UTF-8">
-    <meta http-equiv="refresh" content="120; URL=/public/" >
+    <meta http-equiv="refresh" content="120; URL=/" >
     <title>Schichten der aktuellen Woche</title>
     <link rel="icon" href="{% static 'favicon.png' %}">
     {% bootstrap_css %}
@@ -117,6 +117,25 @@
                         {% endfor %}
                     </tr>
                     {% endfor %}
+                    <tr>
+                        <td class="employee-name">Helfer</td>
+                        {% for day in range_days %}
+                            {% if helpers_by_date|default_if_none:None %}
+                                {% if helpers_by_date|get_item:day %}
+                                    {% with helper=helpers_by_date|get_item:day %}
+                                        <td class="shift-none" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-html="true" title="Benötigt: {{ helper.ben }}<br> Bestellt: {{ helper.best }}<br> Info: {{ helper.info }}">
+                                            {{ helper.ben }}/{{ helper.best }}
+                                        </td>
+                                    {% endwith %}
+                                {% else %}
+                                    <td class="shift-none" >--</td>
+                                {% endif %}
+                            {% else %}
+                                <td class="shift-none" >--</td>
+                            {% endif %}
+                        {% endfor %}
+                    </tr>
+
                 </tbody>
                 <tbody>
                     <tr class="table-dark">