free shifts in team view, eye candy
This commit is contained in:
parent
bf3b276e39
commit
4048c7d9ac
|
@ -0,0 +1,3 @@
|
|||
<li class="box"><b>{{ shift.room.name }}</b> {{ shift.start_at }} ({{ shift.shiftregistration_set.count }}/{{ shift.room.required_helpers }})
|
||||
<a class="button is-info is-small" href="{% url 'team:shift' shift.id %}">Details</a>
|
||||
</li>
|
|
@ -1,11 +1,11 @@
|
|||
{% extends "team_base.html" %}
|
||||
|
||||
{% block title %}Alle Schichten{% endblock %}
|
||||
{% block title %}{{title}}{% endblock %}
|
||||
{% block content %}
|
||||
<h2>Schichten</h2>
|
||||
<h3 class="title is-3">{{title}}</h3>
|
||||
<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>
|
||||
{% include "partials/shift_list_item.html" %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
|
|
@ -3,17 +3,18 @@
|
|||
{% block title %}Schichtübersicht{% endblock %}
|
||||
{% block content %}
|
||||
{% if running_shifts %}
|
||||
<h2>Laufende Schichten</h2>
|
||||
<h3 class="title is-3">Laufende Schichten</h3>
|
||||
<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>
|
||||
{% include "partials/shift_list_item.html" %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
<h2>Nächste Schichten</h2>
|
||||
<hr/>
|
||||
<h3 class="title is-3">Nächste Schichten pro Raum</h3>
|
||||
<ul>
|
||||
{% 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>
|
||||
{% include "partials/shift_list_item.html" %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
{% block navbar %}
|
||||
<a class="navbar-item" href="{% url 'team:shift_overview' %}">Schichtübersicht</a>
|
||||
<a class="navbar-item" href="{% url 'team:shift_free' %}">Freie Schichten</a>
|
||||
<a class="navbar-item" href="{% url 'team:shift_all' %}">Alle Schichten</a>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ urlpatterns = [
|
|||
path("", views.shift_overview, name="index"),
|
||||
path("overview/", views.shift_overview, name="shift_overview"),
|
||||
path("shifts/", views.ShiftList.as_view(), name="shift_all"),
|
||||
path("free_shifts/", views.FreeShiftList.as_view(), name="shift_free"),
|
||||
path("shift/<int:pk>", views.ShiftDetail.as_view(), name="shift"),
|
||||
path("helper/<int:pk>", views.HelperDetail.as_view(), name="helper"),
|
||||
]
|
||||
|
|
|
@ -51,3 +51,21 @@ class HelperDetail(LoginRequiredMixin, DetailView):
|
|||
class ShiftList(LoginRequiredMixin, ListView):
|
||||
template_name = "shift_list.html"
|
||||
model = Shift
|
||||
title = "Alle Schichten"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["title"] = self.title
|
||||
return context
|
||||
|
||||
def get_ordering(self):
|
||||
return ("start_at", "room_id")
|
||||
|
||||
|
||||
class FreeShiftList(ShiftList):
|
||||
title = "Freie Schichten"
|
||||
|
||||
def get_queryset(self):
|
||||
return Shift.objects.annotate(reg_count=Count("shiftregistration")).filter(
|
||||
start_at__gt=timezone.now(), room__required_helpers__gt=F("reg_count")
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue