diff --git a/shiftregister/signage/urls.py b/shiftregister/signage/urls.py index 3bd3a8f..04d41f1 100644 --- a/shiftregister/signage/urls.py +++ b/shiftregister/signage/urls.py @@ -6,5 +6,6 @@ app_name = "signage" urlpatterns = [ path("team/worklist", views.worklist, name="worklist"), path("team/worklist/add/", views.add_teammember, name="work_add"), + path("team/worklist/remove/", views.remove_teammember, name="work_remove"), path("team/terminal", views.terminal, name="terminal"), ] diff --git a/shiftregister/signage/views.py b/shiftregister/signage/views.py index a506c6e..ec19b52 100644 --- a/shiftregister/signage/views.py +++ b/shiftregister/signage/views.py @@ -46,8 +46,17 @@ def add_teammember(request, shiftid): shift = get_object_or_404(Shift, pk=shiftid) o = TeamBackup(shift=shift, name=form.cleaned_data["name"]) o.save() + p = request.GET.get("redir", None) + if p: + return redirect(p) return redirect("signage:worklist") +@login_required +def remove_teammember(request, pk): + obj = get_object_or_404(TeamBackup, pk=pk) + sid = obj.shift.pk + obj.delete() + return redirect("team:shift", sid) def terminal(request): help_wanted = Q(required_helpers__gt=F("reg_count")) | Q(required_helpers=0) & Q( diff --git a/shiftregister/team/templates/shift_detail.html b/shiftregister/team/templates/shift_detail.html index 9ffd4c6..5ce2c08 100644 --- a/shiftregister/team/templates/shift_detail.html +++ b/shiftregister/team/templates/shift_detail.html @@ -8,9 +8,6 @@ {{ shift.description|linebreaksbr }} {% endif %} - {% if shift.teambackup_set.all.count %}
- Backup Teammitglied(er): {%for member in shift.teambackup_set.all%}{{member.name}}, {%endfor%} - {% endif %} {% if shift.shiftregistration_set.all %}
Helfer*innen
@@ -60,4 +57,38 @@ {% endfor %} +
+ {% if shift.teambackup_set.all.count %}
+ Backup Teammitglied(er): +
    + {%for member in shift.teambackup_set.all%} +
  • {{member.name}} entfernen
  • + {%endfor%} +
+ {% endif %} +
+ {% csrf_token %} + {% for field in backup_form%} +
+ {% if field.widget_type == 'checkbox' %} +
+ +
+ {% else %} + +
+ {{ field }} +
+ {% endif %} + {% for error in field.errors %} +

{{ error }}

+ {% endfor %} + {% if field.help_text %} +

{{ field.help_text }}

+ {% endif %} +
+ {% endfor %} + +
+
{% endblock %} diff --git a/shiftregister/team/views.py b/shiftregister/team/views.py index 8c0dbec..53aa3b3 100644 --- a/shiftregister/team/views.py +++ b/shiftregister/team/views.py @@ -70,9 +70,12 @@ def shift_detail(request, pk): "Helfer ist bereits für diese Schicht angemeldet", ) return redirect("team:shift", pk=shift.pk) + # break potential cyclic imports + from shiftregister.signage.forms import TeamBackupForm context = { "shift": shift, "add_helper_form": form, + "backup_form": TeamBackupForm(), } return render(request, "shift_detail.html", context)