2
0
Fork 0

add checkin button to team backend

This commit is contained in:
Andreas (@xAndy) Zimmermann 2022-05-20 20:25:51 +02:00
parent 6b80322a6e
commit 046189d93c
4 changed files with 16 additions and 0 deletions

View File

@ -150,6 +150,9 @@ class ShiftRegistration(models.Model):
def __str__(self):
return f"{self.helper.name}: {self.shift}"
def is_checked_in(self):
return self.state==self.RegState.CHECKED_IN
class Message(models.Model):
# remove limit and send long messages in multiple messages?

View File

@ -16,6 +16,11 @@
<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="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>
{% endfor %}

View File

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

View File

@ -148,3 +148,10 @@ class FreeShiftList(ShiftList):
)
.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)