8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-25 00:13:45 +00:00

Fix le prb de destruction de droits

This commit is contained in:
Gabriel Detraz 2016-10-31 17:52:16 +01:00
parent 7726374cf8
commit 7faa61dff3
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,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')