From e7be7e1a2c21a5b7a6d6b12b2642e828e1bf5ac9 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 1 Apr 2018 20:44:23 +0200 Subject: [PATCH] Fix service users + stack --- topologie/views.py | 2 +- users/urls.py | 4 ++-- users/views.py | 22 +++++++++++----------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/topologie/views.py b/topologie/views.py index 97b01ebb..b57a5255 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -211,7 +211,7 @@ def index_ap(request): def index_stack(request): """Affichage de la liste des stacks (affiche l'ensemble des switches)""" stack_list = Stack.objects\ - .prefetch_related('switch_set__domain__extension') + .prefetch_related('switch_set__interface_set__domain__extension') stack_list = SortTable.sort( stack_list, request.GET.get('col'), diff --git a/users/urls.py b/users/urls.py index fac55e44..b8f428b0 100644 --- a/users/urls.py +++ b/users/urls.py @@ -45,12 +45,12 @@ urlpatterns = [ url(r'^del_group/(?P[0-9]+)/(?P[0-9]+)$', views.del_group, name='del-group'), url(r'^new_serviceuser/$', views.new_serviceuser, name='new-serviceuser'), url( - r'^edit_serviceuser/(?P[0-9]+)$', + r'^edit_serviceuser/(?P[0-9]+)$', views.edit_serviceuser, name='edit-serviceuser' ), url( - r'^del_serviceuser/(?P[0-9]+)$', + r'^del_serviceuser/(?P[0-9]+)$', views.del_serviceuser, name='del-serviceuser' ), diff --git a/users/views.py b/users/views.py index 73332e8b..8eb23bbf 100644 --- a/users/views.py +++ b/users/views.py @@ -305,36 +305,36 @@ def new_serviceuser(request): @login_required @can_edit(ServiceUser) -def edit_serviceuser(request, user, userid): +def edit_serviceuser(request, serviceuser, serviceuserid): """ Edit a ServiceUser """ - user = EditServiceUserForm(request.POST or None, instance=user) - if user.is_valid(): - user_object = user.save(commit=False) + serviceuser = EditServiceUserForm(request.POST or None, instance=serviceuser) + if serviceuser.is_valid(): + user_object = serviceuser.save(commit=False) with transaction.atomic(), reversion.create_revision(): - if user.cleaned_data['password']: - user_object.set_password(user.cleaned_data['password']) + if serviceuser.cleaned_data['password']: + user_object.set_password(serviceuser.cleaned_data['password']) user_object.save() reversion.set_user(request.user) reversion.set_comment("Champs modifié(s) : %s" % ', '.join( - field for field in user.changed_data + field for field in serviceuser.changed_data )) messages.success(request, "L'user a bien été modifié") return redirect(reverse('users:index-serviceusers')) - return form({'userform': user, 'action_name':'Editer un serviceuser'}, 'users/user.html', request) + return form({'userform': serviceuser, 'action_name':'Editer un serviceuser'}, 'users/user.html', request) @login_required @can_delete(ServiceUser) -def del_serviceuser(request, user, userid): +def del_serviceuser(request, serviceuser, serviceuserid): """Suppression d'un ou plusieurs serviceusers""" if request.method == "POST": with transaction.atomic(), reversion.create_revision(): - user.delete() + serviceuser.delete() reversion.set_user(request.user) messages.success(request, "L'user a été détruite") return redirect(reverse('users:index-serviceusers')) return form( - {'objet': user, 'objet_name': 'serviceuser'}, + {'objet': serviceuser, 'objet_name': 'serviceuser'}, 'users/delete.html', request )