8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02:26 +00:00

Fix le prb de destruction de droits

This commit is contained in:
chirac 2016-10-31 17:52:16 +01:00
parent 02e0307340
commit 6af40d9e6c
3 changed files with 39 additions and 5 deletions

View file

@ -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):

View file

@ -0,0 +1,29 @@
# -*- 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),
),
]

View file

@ -173,6 +173,9 @@ def add_right(request, userid):
right = right.save(commit=False)
right.user = user
try:
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:
@ -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']
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')