|
|
@@ -1,6 +1,6 @@
|
|
|
from django.shortcuts import render, redirect, get_object_or_404
|
|
|
from .forms import MultipleShiftForm, ShiftForm, EventForm
|
|
|
-from .models import Shift, Employee, Location, Event
|
|
|
+from .models import Shift, Employee, Location, Event, Helper
|
|
|
from django.utils.timezone import datetime, timedelta
|
|
|
from django.utils import timezone
|
|
|
from django.contrib.auth.decorators import user_passes_test
|
|
|
@@ -99,8 +99,10 @@ def current_week_shifts(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)}
|
|
|
@@ -108,12 +110,16 @@ def current_week_shifts(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])
|
|
|
|
|
|
- print(events)
|
|
|
+ helpers = Helper.objects.filter(date__range=[start_of_week, end_of_week])
|
|
|
+
|
|
|
# Fülle das Dictionary mit den Schichtdaten
|
|
|
for shift in shifts:
|
|
|
employee = shift.employee
|
|
|
@@ -125,6 +131,10 @@ def current_week_shifts(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']
|
|
|
@@ -133,6 +143,7 @@ def current_week_shifts(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,
|
|
|
@@ -141,8 +152,9 @@ def current_week_shifts(request):
|
|
|
'next_week': next_week.strftime('%Y-%m-%d'),
|
|
|
'calendar_week': calendar_week,
|
|
|
}
|
|
|
- print(shifts_by_employee)
|
|
|
- print(events_by_location)
|
|
|
+ #print(shifts_by_employee)
|
|
|
+ #print(events_by_location)
|
|
|
+ #print(helpers_by_date)
|
|
|
return render(request, 'main/current_week_shifts.html', context)
|
|
|
|
|
|
|