diff --git a/shiftregister/app/templates/helper_base.html b/shiftregister/app/templates/helper_base.html new file mode 100644 index 0000000..fc19041 --- /dev/null +++ b/shiftregister/app/templates/helper_base.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} + +{% block title %}Help!{% endblock %} +{% block body %} +{% if helper%} +Hallo {{helper.name}} +{%else%} +Anmelden +{%endif%} +
+ {% block content %}{% endblock %} +
+{% endblock %} \ No newline at end of file diff --git a/shiftregister/app/templates/register.html b/shiftregister/app/templates/register.html index dd28b9d..8e91ff8 100644 --- a/shiftregister/app/templates/register.html +++ b/shiftregister/app/templates/register.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "helper_base.html" %} {% block title %}Registrierung{% endblock %} {% block content %} diff --git a/shiftregister/app/templates/shift.html b/shiftregister/app/templates/shift.html index 63d7ff7..e22f991 100644 --- a/shiftregister/app/templates/shift.html +++ b/shiftregister/app/templates/shift.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "helper_base.html" %} {% block title %}Schichtansicht{% endblock %} {% block content %} diff --git a/shiftregister/app/templates/shiftlist.html b/shiftregister/app/templates/shiftlist.html index 2348d5c..68447e2 100644 --- a/shiftregister/app/templates/shiftlist.html +++ b/shiftregister/app/templates/shiftlist.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "helper_base.html" %} {% block title %}Freie Schichten{% endblock %} {% block content %} diff --git a/shiftregister/app/templates/wait_confirmation.html b/shiftregister/app/templates/wait_confirmation.html index b53dad5..8f167d2 100644 --- a/shiftregister/app/templates/wait_confirmation.html +++ b/shiftregister/app/templates/wait_confirmation.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "helper_base.html" %} {% block title %}Registrierung{% endblock %} {% block content %} diff --git a/shiftregister/team/templates/helper_detail.html b/shiftregister/team/templates/helper_detail.html new file mode 100644 index 0000000..124ab24 --- /dev/null +++ b/shiftregister/team/templates/helper_detail.html @@ -0,0 +1,13 @@ +{% extends "team_base.html" %} + +{% block title %}Schichtdetails{% endblock %} +{% block content %} +

{{helper.name}}

+Telefon: {{helper.phone}} +

Schichten:

+ +{% endblock %} \ No newline at end of file diff --git a/shiftregister/team/templates/shift_detail.html b/shiftregister/team/templates/shift_detail.html new file mode 100644 index 0000000..67da4e0 --- /dev/null +++ b/shiftregister/team/templates/shift_detail.html @@ -0,0 +1,12 @@ +{% extends "team_base.html" %} + +{% block title %}Schichtdetails{% endblock %} +{% block content %} +{{ shift.room.name }} {{shift.start_at}}({{shift.shiftregistration_set.count}}/{{shift.room.required_helpers}}) +

Helfer

+ +{% endblock %} \ No newline at end of file diff --git a/shiftregister/team/templates/shift_list.html b/shiftregister/team/templates/shift_list.html new file mode 100644 index 0000000..64a17b1 --- /dev/null +++ b/shiftregister/team/templates/shift_list.html @@ -0,0 +1,12 @@ +{% extends "team_base.html" %} + +{% block title %}Alle Schichten{% endblock %} +{% block content %} +

Schichten

+ + +{% endblock %} diff --git a/shiftregister/team/templates/shift_overview.html b/shiftregister/team/templates/shift_overview.html new file mode 100644 index 0000000..c9e9129 --- /dev/null +++ b/shiftregister/team/templates/shift_overview.html @@ -0,0 +1,17 @@ +{% extends "team_base.html" %} + +{% block title %}Schichtuebersicht{% endblock %} +{% block content %} +{%if running_shifts%} +

Laufende Schichten

+ +{%endif%} +

Naechste Schichten

+{%for shift in next_shifts%} +
  • {{ shift.room.name }} {{shift.start_at}}({{shift.shiftregistration_set.count}}/{{shift.room.required_helpers}})Details
  • +{%endfor%} +{% endblock %} \ No newline at end of file diff --git a/shiftregister/team/templates/team_base.html b/shiftregister/team/templates/team_base.html new file mode 100644 index 0000000..c1c4d54 --- /dev/null +++ b/shiftregister/team/templates/team_base.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} + +{% block title %}Team{% endblock %} +{% block body %} +
    +
    + {% block content %}{% endblock %} +
    +{% endblock %} \ No newline at end of file diff --git a/shiftregister/team/urls.py b/shiftregister/team/urls.py index 88a9cac..437eb5d 100644 --- a/shiftregister/team/urls.py +++ b/shiftregister/team/urls.py @@ -1,7 +1,11 @@ from django.urls import path from . import views - +app_name = 'team' urlpatterns = [ - path('', views.index, name='index'), + path('', views.shift_overview, name='index'), + path('overview/', views.shift_overview, name='shift_overview'), + path('shifts/', views.ShiftList.as_view(), name='shift_all'), + path('shift/', views.ShiftDetail.as_view(), name='shift'), + path('helper/', views.HelperDetail.as_view(), name='helper'), ] diff --git a/shiftregister/team/views.py b/shiftregister/team/views.py index 2179b81..37253f9 100644 --- a/shiftregister/team/views.py +++ b/shiftregister/team/views.py @@ -1,5 +1,33 @@ -from django.shortcuts import render +from django.shortcuts import render, get_object_or_404 +from django.contrib.auth.decorators import login_required +from django.utils import timezone +from django.db.models.fields import DateTimeField +from django.db.models import F, Count, Q, ExpressionWrapper +from .models import ShiftRegistration, Room, Shift, Helper +from django.views.generic import DetailView, ListView # Create your views here. def index(request): - pass \ No newline at end of file + pass + +@login_required +def shift_overview(request): + context = {} + context['running_shifts'] = (reg.shift for reg in ShiftRegistration.objects.annotate(shift_end=ExpressionWrapper(F('shift__start_at')+F('shift__duration'), output_field=DateTimeField())).filter(shift__start_at__lte=timezone.now(), shift_end__gte=timezone.now()).order_by('shift__start_at')) + + # probably can do some distinct/group by stuff but not sure how tih django queries + context['next_shifts'] = (next(iter(Shift.objects.filter(room=room, start_at__gt=timezone.now()).order_by('start_at'))) for room in Room.objects.all()) + + return render(request, 'shift_overview.html', context) + +class ShiftDetail(DetailView): + template_name = "shift_detail.html" + model= Shift + +class HelperDetail(DetailView): + template_name = "helper_detail.html" + model= Helper + +class ShiftList(ListView): + template_name = "shift_list.html" + model= Shift \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 7cd4ace..1a9c68c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,17 +1,11 @@ - + {% block title %}Help!{% endblock %} - {% if helper%} - Hallo {{helper.name}} - {%else%} - Anmelden - {%endif%} -
    - {% block content %}{% endblock %} -
    +{%block body%} +{%endblock%} \ No newline at end of file