mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 11:53:12 +00:00
Fix le prb de destruction de droits
This commit is contained in:
parent
7726374cf8
commit
7faa61dff3
3 changed files with 39 additions and 5 deletions
|
@ -44,7 +44,7 @@ class ListRightAdmin(VersionAdmin):
|
||||||
class ListShellAdmin(VersionAdmin):
|
class ListShellAdmin(VersionAdmin):
|
||||||
list_display = ('shell',)
|
list_display = ('shell',)
|
||||||
|
|
||||||
class RightAdmin(admin.ModelAdmin):
|
class RightAdmin(VersionAdmin):
|
||||||
list_display = ('user', 'right')
|
list_display = ('user', 'right')
|
||||||
|
|
||||||
class RequestAdmin(admin.ModelAdmin):
|
class RequestAdmin(admin.ModelAdmin):
|
||||||
|
|
29
users/migrations/0038_auto_20161031_0258.py
Normal file
29
users/migrations/0038_auto_20161031_0258.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -173,7 +173,10 @@ def add_right(request, userid):
|
||||||
right = right.save(commit=False)
|
right = right.save(commit=False)
|
||||||
right.user = user
|
right.user = user
|
||||||
try:
|
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é")
|
messages.success(request, "Droit ajouté")
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
pass
|
pass
|
||||||
|
@ -184,13 +187,15 @@ def add_right(request, userid):
|
||||||
@permission_required('bureau')
|
@permission_required('bureau')
|
||||||
def del_right(request):
|
def del_right(request):
|
||||||
user_right_list = DelRightForm(request.POST or None)
|
user_right_list = DelRightForm(request.POST or None)
|
||||||
right_list = ListRight.objects.all()
|
|
||||||
if user_right_list.is_valid():
|
if user_right_list.is_valid():
|
||||||
right_del = user_right_list.cleaned_data['rights']
|
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")
|
messages.success(request, "Droit retiré avec succès")
|
||||||
return redirect("/users/")
|
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
|
@login_required
|
||||||
@permission_required('bofh')
|
@permission_required('bofh')
|
||||||
|
|
Loading…
Reference in a new issue