mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 03:13:12 +00:00
Merge branch 'fix_divers_acl' into 'master'
Fix service users + stack See merge request federez/re2o!110
This commit is contained in:
commit
22143e8a3e
3 changed files with 14 additions and 14 deletions
|
@ -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'),
|
||||
|
|
|
@ -45,12 +45,12 @@ urlpatterns = [
|
|||
url(r'^del_group/(?P<userid>[0-9]+)/(?P<listrightid>[0-9]+)$', views.del_group, name='del-group'),
|
||||
url(r'^new_serviceuser/$', views.new_serviceuser, name='new-serviceuser'),
|
||||
url(
|
||||
r'^edit_serviceuser/(?P<userid>[0-9]+)$',
|
||||
r'^edit_serviceuser/(?P<serviceuserid>[0-9]+)$',
|
||||
views.edit_serviceuser,
|
||||
name='edit-serviceuser'
|
||||
),
|
||||
url(
|
||||
r'^del_serviceuser/(?P<userid>[0-9]+)$',
|
||||
r'^del_serviceuser/(?P<serviceuserid>[0-9]+)$',
|
||||
views.del_serviceuser,
|
||||
name='del-serviceuser'
|
||||
),
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue