mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 09:26:27 +00:00
Merge branch 'service_user_del' into 'master'
Fix del/edit serviceuser See merge request federez/re2o!119
This commit is contained in:
commit
5a6acb5941
1 changed files with 7 additions and 7 deletions
|
@ -275,12 +275,12 @@ def new_serviceuser(request):
|
||||||
@can_edit(ServiceUser)
|
@can_edit(ServiceUser)
|
||||||
def edit_serviceuser(request, serviceuser, serviceuserid):
|
def edit_serviceuser(request, serviceuser, serviceuserid):
|
||||||
""" Edit a ServiceUser """
|
""" Edit a ServiceUser """
|
||||||
user = EditServiceUserForm(request.POST or None, instance=user)
|
serviceuser = EditServiceUserForm(request.POST or None, instance=serviceuser)
|
||||||
if user.is_valid():
|
if serviceuser.is_valid():
|
||||||
user_object = user.save(commit=False)
|
user_object = serviceuser.save(commit=False)
|
||||||
if user.cleaned_data['password']:
|
if serviceuser.cleaned_data['password']:
|
||||||
user_object.set_password(user.cleaned_data['password'])
|
user_object.set_password(serviceuser.cleaned_data['password'])
|
||||||
if user.changed_data:
|
if serviceuser.changed_data:
|
||||||
user_object.save()
|
user_object.save()
|
||||||
messages.success(request, "L'user a bien été modifié")
|
messages.success(request, "L'user a bien été modifié")
|
||||||
return redirect(reverse('users:index-serviceusers'))
|
return redirect(reverse('users:index-serviceusers'))
|
||||||
|
@ -292,7 +292,7 @@ def edit_serviceuser(request, serviceuser, serviceuserid):
|
||||||
def del_serviceuser(request, serviceuser, serviceuserid):
|
def del_serviceuser(request, serviceuser, serviceuserid):
|
||||||
"""Suppression d'un ou plusieurs serviceusers"""
|
"""Suppression d'un ou plusieurs serviceusers"""
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
user.delete()
|
serviceuser.delete()
|
||||||
messages.success(request, "L'user a été détruite")
|
messages.success(request, "L'user a été détruite")
|
||||||
return redirect(reverse('users:index-serviceusers'))
|
return redirect(reverse('users:index-serviceusers'))
|
||||||
return form(
|
return form(
|
||||||
|
|
Loading…
Reference in a new issue