From dfe15ec23d3028870e6f2665795ec20f17b9c6f7 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sat, 21 Sep 2019 16:25:05 +0200 Subject: [PATCH] Button to remove port of a room --- multi_op/templates/multi_op/aff_room_state.html | 8 +++++++- multi_op/urls.py | 2 +- multi_op/views.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/multi_op/templates/multi_op/aff_room_state.html b/multi_op/templates/multi_op/aff_room_state.html index de25171b..75ca027c 100644 --- a/multi_op/templates/multi_op/aff_room_state.html +++ b/multi_op/templates/multi_op/aff_room_state.html @@ -42,6 +42,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% trans "Details" %} {% trans "End of subscription on" %} {% trans "Internet access" %} + {% trans "Action" %} {% for room in room_list %} @@ -51,7 +52,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if room.port_set.all %}AURORE{% else %}{% trans "Other operator" %}{% endif %} {% if room.adherent %}{{ room.adherent }}{% else %} {% trans "Aucun" %}{% endif %} {{ room.details }} - {% if room.adherent.is_adherent %}{{ room.adherent.end_adhesion }}{% else %}{% trans "Not a member" %}{% endif %} + {% if room.adherent.is_adherent %}{% else %}{% endif %}{% if room.adherent.end_adhesion %}{{ room.adherent.end_adhesion}}{% else %}{% trans "No member" %}{% endif %} {% if room.adherent.has_access == True %} {% trans "Active" %} @@ -59,6 +60,11 @@ with this program; if not, write to the Free Software Foundation, Inc., {% trans "Disabled" %} {% endif %} + + {% if room.port_set.all %} + + {% endif %} + {% endfor %} diff --git a/multi_op/urls.py b/multi_op/urls.py index 0dbb0ca8..866de712 100644 --- a/multi_op/urls.py +++ b/multi_op/urls.py @@ -34,5 +34,5 @@ urlpatterns = [ url(r'^(?P[0-9]+)$', views.aff_state_dormitory, name='aff-state-dormitory'), url(r'^pending-connection$', views.aff_pending_connection, name='aff-pending-connection'), url(r'^pending-disconnection$', views.aff_pending_disconnection, name='aff-pending-disconnection'), - # url(r'^multi_op/edit-preferences-multiop$', views.edit_preferences, name='edit-preferences-multiop'), + url(r'^disconnect-room/(?P[0-9]+)$', views.disconnect_room, name='disconnect-room'), ] diff --git a/multi_op/views.py b/multi_op/views.py index 75811a0d..7b94a158 100644 --- a/multi_op/views.py +++ b/multi_op/views.py @@ -142,6 +142,18 @@ def aff_pending_disconnection(request): ) +@login_required +@can_edit(Room) +def disconnect_room(request, room, roomid): + """Action of disconnecting a room""" + room.port_set.clear() + room.save() + messages.success(request,'Room %s disconnected' % room) + return redirect(reverse( + 'multi_op:aff-pending-disconnection' + )) + + def edit_preferences(request): """ View to edit the settings of the tickets """