From bb6b19f5742f47cac7f5ad923e62bb203b3b8cb5 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sat, 7 Apr 2018 22:13:41 +0200 Subject: [PATCH] Fix le changement d'etat de l'user --- users/views.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/users/views.py b/users/views.py index 12e6740e..26b1e0e7 100644 --- a/users/views.py +++ b/users/views.py @@ -198,14 +198,12 @@ def state(request, user, userid): need droit bureau """ state = StateForm(request.POST or None, instance=user) if state.is_valid(): - if state.cleaned_data['state'] == User.STATE_ARCHIVE: - user.archive() - elif state.cleaned_data['state'] == User.STATE_ACTIVE: - user.unarchive() - elif state.cleaned_data['state'] == User.STATE_DISABLED: - user.state = User.STATE_DISABLED - if user.changed_data: - user.save() + if state.changed_data: + if state.cleaned_data['state'] == User.STATE_ARCHIVE: + user.archive() + elif state.cleaned_data['state'] == User.STATE_ACTIVE: + user.unarchive() + state.save() messages.success(request, "Etat changé avec succès") return redirect(reverse( 'users:profil',