diff --git a/biscuit/apps/chronos/templates/chronos/edit_substitution.html b/biscuit/apps/chronos/templates/chronos/edit_substitution.html index 9ca274356e4dc0cb4911de981b534e4eb92496f3..88a0342548ffa658ce6e8d1ada70784232caa58d 100644 --- a/biscuit/apps/chronos/templates/chronos/edit_substitution.html +++ b/biscuit/apps/chronos/templates/chronos/edit_substitution.html @@ -8,6 +8,16 @@ {% block page_title %}{% blocktrans %}Edit substitution{% endblocktrans %}{% endblock %} {% 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"> {% csrf_token %} {% bootstrap_form edit_substitution_form %} diff --git a/biscuit/apps/chronos/urls.py b/biscuit/apps/chronos/urls.py index e3a9751a63ef7207abe49fcfb5277dde07143fb9..f9f4e7765d5832814bc2f82c13a5f3e1fe00729c 100644 --- a/biscuit/apps/chronos/urls.py +++ b/biscuit/apps/chronos/urls.py @@ -9,4 +9,5 @@ urlpatterns = [ path('lessons', views.lessons_day, name='lessons_day'), 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/delete', views.delete_substitution, name='delete_substitution') ] diff --git a/biscuit/apps/chronos/views.py b/biscuit/apps/chronos/views.py index 78508d42254b5e16ac7b150cc1a6773a72b46e13..7acc740fc0456df7c675065e8f3d150d35b564e1 100644 --- a/biscuit/apps/chronos/views.py +++ b/biscuit/apps/chronos/views.py @@ -158,3 +158,14 @@ def edit_substitution(request: HttpRequest, id_: int, week: int) -> HttpResponse context['edit_substitution_form'] = edit_substitution_form 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_)