add initial team functionality

pull/1/head
parent bfcbe09965
commit 3a3fe3edef

@ -0,0 +1,13 @@
{% extends "base.html" %}
{% block title %}Help!{% endblock %}
{% block body %}
{% if helper%}
Hallo {{helper.name}}
{%else%}
<a href="{%url 'register'%}">Anmelden</a>
{%endif%}
<div id="content">
{% block content %}{% endblock %}
</div>
{% endblock %}

@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "helper_base.html" %}
{% block title %}Registrierung{% endblock %}
{% block content %}

@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "helper_base.html" %}
{% block title %}Schichtansicht{% endblock %}
{% block content %}

@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "helper_base.html" %}
{% block title %}Freie Schichten{% endblock %}
{% block content %}

@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "helper_base.html" %}
{% block title %}Registrierung{% endblock %}
{% block content %}

@ -0,0 +1,13 @@
{% extends "team_base.html" %}
{% block title %}Schichtdetails{% endblock %}
{% block content %}
<h2>{{helper.name}}</h2>
Telefon: <a href="tel:{{helper.phone}}">{{helper.phone}}</a>
<h2>Schichten:</h2>
<ul>
{% for reg in helper.shiftregistration_set.all %}
<li>{{ reg.shift.room.name }} {{reg.shift.start_at}}({{reg.shift.shiftregistration_set.count}}/{{reg.shift.room.required_helpers}})<a href="{%url 'team:shift' reg.shift.id%}">Details</a></li>
{%endfor%}
</ul>
{% endblock %}

@ -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}})
<h2>Helfer</h2>
<ul>
{% for reg in shift.shiftregistration_set.all %}
<li><a href="{%url 'team:helper' reg.helper.pk%}">{{reg.helper.name}}</a> <a href="tel:{{reg.helper.phone}}">📞</a></li>
{%endfor%}
</ul>
{% endblock %}

@ -0,0 +1,12 @@
{% extends "team_base.html" %}
{% block title %}Alle Schichten{% endblock %}
{% block content %}
<h2>Schichten</h2>
<ul>
{%for shift in object_list%}
<li>{{ shift.room.name }} {{shift.start_at}}({{shift.shiftregistration_set.count}}/{{shift.room.required_helpers}})<a href="{%url 'team:shift' shift.id%}">Details</a></li>
{%endfor%}
</ul>
{% endblock %}

@ -0,0 +1,17 @@
{% extends "team_base.html" %}
{% block title %}Schichtuebersicht{% endblock %}
{% block content %}
{%if running_shifts%}
<h2>Laufende Schichten</h2>
<ul>
{%for shift in running_shifts%}
<li>{{ shift.room.name }} {{shift.start_at}}({{shift.shiftregistration_set.count}}/{{shift.room.required_helpers}})<a href="{%url 'team:shift' shift.id%}">Details</a></li>
{%endfor%}
</ul>
{%endif%}
<h2>Naechste Schichten</h2>
{%for shift in next_shifts%}
<li>{{ shift.room.name }} {{shift.start_at}}({{shift.shiftregistration_set.count}}/{{shift.room.required_helpers}})<a href="{%url 'team:shift' shift.id%}">Details</a></li>
{%endfor%}
{% endblock %}

@ -0,0 +1,12 @@
{% extends "base.html" %}
{% block title %}Team{% endblock %}
{% block body %}
<nav>
<a href="{%url 'team:shift_overview'%}">Schichtuebersicht</a>
<a href="{%url 'team:shift_all'%}">Alle Schichten</a>
</nav><hr>
<div id="content">
{% block content %}{% endblock %}
</div>
{% endblock %}

@ -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/<int:pk>', views.ShiftDetail.as_view(), name='shift'),
path('helper/<int:pk>', views.HelperDetail.as_view(), name='helper'),
]

@ -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
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

@ -1,17 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<html lang="de">
<head>
<title>{% block title %}Help!{% endblock %}</title>
</head>
<body>
{% if helper%}
Hallo {{helper.name}}
{%else%}
<a href="{%url 'register'%}">Anmelden</a>
{%endif%}
<div id="content">
{% block content %}{% endblock %}
</div>
{%block body%}
{%endblock%}
</body>
</html>
Loading…
Cancel
Save