Commit 6af40d9e authored by chirac's avatar chirac

Fix le prb de destruction de droits

parent 02e03073
......@@ -44,7 +44,7 @@ class ListRightAdmin(VersionAdmin):
class ListShellAdmin(VersionAdmin):
list_display = ('shell',)
class RightAdmin(admin.ModelAdmin):
class RightAdmin(VersionAdmin):
list_display = ('user', 'right')
class RequestAdmin(admin.ModelAdmin):
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0037_auto_20161028_1906'),
]
operations = [
migrations.AlterField(
model_name='ldapserviceuser',
name='dn',
field=models.CharField(max_length=200),
),
migrations.AlterField(
model_name='ldapuser',
name='dn',
field=models.CharField(max_length=200),
),
migrations.AlterField(
model_name='ldapusergroup',
name='dn',
field=models.CharField(max_length=200),
),
]
......@@ -173,7 +173,10 @@ def add_right(request, userid):
right = right.save(commit=False)
right.user = user
try:
right.save()
with transaction.atomic(), reversion.create_revision():
reversion.set_user(request.user)
reversion.set_comment("Ajout du droit %s" % right.right)
right.save()
messages.success(request, "Droit ajouté")
except IntegrityError:
pass
......@@ -184,13 +187,15 @@ def add_right(request, userid):
@permission_required('bureau')
def del_right(request):
user_right_list = DelRightForm(request.POST or None)
right_list = ListRight.objects.all()
if user_right_list.is_valid():
right_del = user_right_list.cleaned_data['rights']
right_del.delete()
with transaction.atomic(), reversion.create_revision():
reversion.set_user(request.user)
reversion.set_comment("Retrait des droit %s" % ','.join(str(deleted_right) for deleted_right in right_del))
right_del.delete()
messages.success(request, "Droit retiré avec succès")
return redirect("/users/")
return form({'user_right_list': user_right_list, 'right_list': right_list}, 'users/index_rights.html', request)
return form({'userform': user_right_list}, 'users/user.html', request)
@login_required
@permission_required('bofh')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment