add checkin button to team backend

pull/1/head
parent 6b80322a6e
commit 046189d93c

@ -149,6 +149,9 @@ class ShiftRegistration(models.Model):
def __str__(self): def __str__(self):
return f"{self.helper.name}: {self.shift}" return f"{self.helper.name}: {self.shift}"
def is_checked_in(self):
return self.state==self.RegState.CHECKED_IN
class Message(models.Model): class Message(models.Model):

@ -16,6 +16,11 @@
<div class="box is-flex is-align-items-center is-justify-content-space-between"> <div class="box is-flex is-align-items-center is-justify-content-space-between">
<a class="is-block is-size-4" href="{% url 'team:helper' reg.helper.pk %}">{{ reg.helper.name }}</a> <a class="is-block is-size-4" href="{% url 'team:helper' reg.helper.pk %}">{{ reg.helper.name }}</a>
<a class="button is-link is-small" href="tel:{{ reg.helper.phone }}">📞</a> <a class="button is-link is-small" href="tel:{{ reg.helper.phone }}">📞</a>
{% if not reg.is_checked_in %}
<a class="button is-warning is-small" href="{%url 'team:checkin' reg.pk%}">als angekommen markieren</a>
{% else %}
<div class="button is-success"></div>
{% endif %}
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

@ -11,4 +11,5 @@ urlpatterns = [
path("shift/<int:pk>", views.shift_detail, name="shift"), path("shift/<int:pk>", views.shift_detail, name="shift"),
path("helper/<int:pk>", views.HelperDetail.as_view(), name="helper"), path("helper/<int:pk>", views.HelperDetail.as_view(), name="helper"),
path("message/", views.bulk_message, name="bulk_message"), path("message/", views.bulk_message, name="bulk_message"),
path("checkin/<int:pk>", views.checkin, name="checkin" ),
] ]

@ -148,3 +148,10 @@ class FreeShiftList(ShiftList):
) )
.order_by("start_at", "room_id") .order_by("start_at", "room_id")
) )
@login_required
def checkin(request, pk):
reg = get_object_or_404(ShiftRegistration, pk=pk)
reg.state = reg.RegState.CHECKED_IN
reg.save()
return redirect("team:shift", pk=reg.shift.pk)
Loading…
Cancel
Save