integrate team backup more closely into team views
This commit is contained in:
parent
9aeee34e7c
commit
e18101e85a
|
@ -6,5 +6,6 @@ app_name = "signage"
|
|||
urlpatterns = [
|
||||
path("team/worklist", views.worklist, name="worklist"),
|
||||
path("team/worklist/add/<int:shiftid>", views.add_teammember, name="work_add"),
|
||||
path("team/worklist/remove/<int:pk>", views.remove_teammember, name="work_remove"),
|
||||
path("team/terminal", views.terminal, name="terminal"),
|
||||
]
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
<div class="content">
|
||||
<em>{{ shift.description|linebreaksbr }}</em>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if shift.teambackup_set.all.count %}<br>
|
||||
<strong>Backup Teammitglied(er): {%for member in shift.teambackup_set.all%}{{member.name}}, {%endfor%}</strong>
|
||||
{% endif %}
|
||||
{% if shift.shiftregistration_set.all %}
|
||||
<h5 class="subtitle">Helfer*innen</h5>
|
||||
|
@ -60,4 +57,38 @@
|
|||
{% endfor %}
|
||||
<button class="button is-link" type="submit">Hinzufügen</button>
|
||||
</form>
|
||||
<hr>
|
||||
{% if shift.teambackup_set.all.count %}<br>
|
||||
<strong>Backup Teammitglied(er):</strong>
|
||||
<ul>
|
||||
{%for member in shift.teambackup_set.all%}
|
||||
<li>{{member.name}} <a class="button is-danger is-small" href="{%url 'signage:work_remove' member.pk%}">entfernen</a></li>
|
||||
{%endfor%}
|
||||
</ul>
|
||||
{% endif %}
|
||||
<form action="{%url 'signage:work_add' shift.pk%}?redir={{request.path}}" method="post">
|
||||
{% csrf_token %}
|
||||
{% for field in backup_form%}
|
||||
<div class="field">
|
||||
{% if field.widget_type == 'checkbox' %}
|
||||
<div class="control">
|
||||
<label class="checkbox" for="{{ field.id_for_label }}">{{ field }} {{ field.label }}</label>
|
||||
</div>
|
||||
{% else %}
|
||||
<label class="label" for="{{ field.id_for_label }}">{{ field.label }}</label>
|
||||
<div class="control">
|
||||
{{ field }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% for error in field.errors %}
|
||||
<p class="help is-danger">{{ error }}</p>
|
||||
{% endfor %}
|
||||
{% if field.help_text %}
|
||||
<p class="help">{{ field.help_text }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<button class="button is-link" type="submit">Team hinzufuegen</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue