Skip to content
Snippets Groups Projects
Verified Commit 1e6cffa5 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Add lesson substitution deletion.

parent e9202b9a
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,16 @@ ...@@ -8,6 +8,16 @@
{% block page_title %}{% blocktrans %}Edit substitution{% endblocktrans %}{% endblock %} {% block page_title %}{% blocktrans %}Edit substitution{% endblocktrans %}{% endblock %}
{% block content %} {% block content %}
<div class="d-flex justify-content-between">
<div class="btn-group" role="group" aria-label="Day actions">
{% if substitution %}
<a href="{% url 'delete_substitution' substitution.lesson_period.id substitution.week %}" class="btn btn-danger">
{% fa 'trash-o' %}
</a>
{% endif %}
</div>
</div>
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
{% bootstrap_form edit_substitution_form %} {% bootstrap_form edit_substitution_form %}
......
...@@ -9,4 +9,5 @@ urlpatterns = [ ...@@ -9,4 +9,5 @@ urlpatterns = [
path('lessons', views.lessons_day, name='lessons_day'), path('lessons', views.lessons_day, name='lessons_day'),
path('lessons/<when>', views.lessons_day, name='lessons_day_by_date'), path('lessons/<when>', views.lessons_day, name='lessons_day_by_date'),
path('lessons/<int:id_>/<int:week>/substition', views.edit_substitution, name='edit_substitution') path('lessons/<int:id_>/<int:week>/substition', views.edit_substitution, name='edit_substitution')
path('lessons/<int:id_>/<int:week>/substition/delete', views.delete_substitution, name='delete_substitution')
] ]
...@@ -158,3 +158,14 @@ def edit_substitution(request: HttpRequest, id_: int, week: int) -> HttpResponse ...@@ -158,3 +158,14 @@ def edit_substitution(request: HttpRequest, id_: int, week: int) -> HttpResponse
context['edit_substitution_form'] = edit_substitution_form context['edit_substitution_form'] = edit_substitution_form
return render(request, 'chronos/edit_substitution.html', context) return render(request, 'chronos/edit_substitution.html', context)
@admin_required
def edit_substitution(request: HttpRequest, id_: int, week: int) -> HttpResponse:
context = {}
LessonSubstitution.objects.filter(
week=week, lesson_period__id=id_
).delete()
return redirect('edit_substitution', week, id_)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment