diff --git a/apps/classrooms/urls.py b/apps/classrooms/urls.py index 0a7f82c..9583d39 100644 --- a/apps/classrooms/urls.py +++ b/apps/classrooms/urls.py @@ -27,6 +27,7 @@ path(r"unit/edit/", views.edit_unit, name="unit_update"), path(r"unit/delete/", views.delete_unit, name="unit_delete"), path(r"unit/activate/", views.activate_unit, name="unit_activate"), + path(r"unit/deactivate/", views.deactivate_unit, name="unit_deactivate"), path( r"addstarter//", views.add_starter, diff --git a/apps/classrooms/views.py b/apps/classrooms/views.py index e181315..e4c4987 100644 --- a/apps/classrooms/views.py +++ b/apps/classrooms/views.py @@ -176,6 +176,16 @@ def activate_unit(request, pk): return redirect(reverse("groups:group_detail", args=[unit.group.id])) +@login_required +def deactivate_unit(request, pk): + unit = get_object_or_404(Unit, pk=pk) + if not unit.group.is_host(request.user): + raise (PermissionDenied) + unit.group.current_unit = 0 + unit.group.save() + return redirect(reverse("groups:group_detail", args=[unit.group.id])) + + @login_required def add_starter(request, group_id, project_id): group = get_object_or_404(Group, id=group_id) diff --git a/templates/classrooms/group_detail.html b/templates/classrooms/group_detail.html index 35141c8..52bc29f 100644 --- a/templates/classrooms/group_detail.html +++ b/templates/classrooms/group_detail.html @@ -95,6 +95,10 @@

Projects

+ {% else %} + + + {% endif %}