mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 23:43:47 +00:00
uniform and more detailed error messages for protectederror
This commit is contained in:
parent
40c60405d4
commit
f6b48905bf
5 changed files with 52 additions and 141 deletions
|
@ -46,7 +46,7 @@ from users.models import User
|
||||||
from re2o.settings import LOGO_PATH
|
from re2o.settings import LOGO_PATH
|
||||||
from re2o import settings
|
from re2o import settings
|
||||||
from re2o.views import form
|
from re2o.views import form
|
||||||
from re2o.utils import SortTable, re2o_paginator
|
from re2o.utils import SortTable, re2o_paginator, messages_protected_error
|
||||||
from re2o.acl import (
|
from re2o.acl import (
|
||||||
can_create,
|
can_create,
|
||||||
can_edit,
|
can_edit,
|
||||||
|
@ -528,14 +528,8 @@ def del_paiement(request, instances):
|
||||||
'method_name': payment_del
|
'method_name': payment_del
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, payment_del, err)
|
||||||
request,
|
|
||||||
_("The payment method %(method_name)s can't be deleted \
|
|
||||||
because there are invoices using it.") % {
|
|
||||||
'method_name': payment_del
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return redirect(reverse('cotisations:index-paiement'))
|
return redirect(reverse('cotisations:index-paiement'))
|
||||||
return form({
|
return form({
|
||||||
'factureform': payment,
|
'factureform': payment,
|
||||||
|
@ -606,14 +600,8 @@ def del_banque(request, instances):
|
||||||
'bank_name': bank_del
|
'bank_name': bank_del
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, bank_del, err)
|
||||||
request,
|
|
||||||
_("The bank %(bank_name)s can't be deleted \
|
|
||||||
because there are invoices using it.") % {
|
|
||||||
'bank_name': bank_del
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return redirect(reverse('cotisations:index-banque'))
|
return redirect(reverse('cotisations:index-banque'))
|
||||||
return form({
|
return form({
|
||||||
'factureform': bank,
|
'factureform': bank,
|
||||||
|
|
|
@ -39,6 +39,8 @@ from django.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.db.models import ProtectedError, F
|
from django.db.models import ProtectedError, F
|
||||||
from django.forms import modelformset_factory
|
from django.forms import modelformset_factory
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
|
|
||||||
from rest_framework.renderers import JSONRenderer
|
from rest_framework.renderers import JSONRenderer
|
||||||
|
|
||||||
|
@ -49,6 +51,7 @@ from re2o.utils import (
|
||||||
filter_active_interfaces,
|
filter_active_interfaces,
|
||||||
SortTable,
|
SortTable,
|
||||||
re2o_paginator,
|
re2o_paginator,
|
||||||
|
messages_protected_error,
|
||||||
)
|
)
|
||||||
from re2o.acl import (
|
from re2o.acl import (
|
||||||
can_create,
|
can_create,
|
||||||
|
@ -504,12 +507,8 @@ def del_iptype(request, instances):
|
||||||
try:
|
try:
|
||||||
iptype_del.delete()
|
iptype_del.delete()
|
||||||
messages.success(request, "Le type d'ip a été supprimé")
|
messages.success(request, "Le type d'ip a été supprimé")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, iptype_del, err)
|
||||||
request,
|
|
||||||
("Le type d'ip %s est affectée à au moins une machine, "
|
|
||||||
"vous ne pouvez pas le supprimer" % iptype_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse('machines:index-iptype'))
|
return redirect(reverse('machines:index-iptype'))
|
||||||
return form(
|
return form(
|
||||||
{'iptypeform': iptype, 'action_name': 'Supprimer'},
|
{'iptypeform': iptype, 'action_name': 'Supprimer'},
|
||||||
|
@ -565,13 +564,8 @@ def del_machinetype(request, instances):
|
||||||
try:
|
try:
|
||||||
machinetype_del.delete()
|
machinetype_del.delete()
|
||||||
messages.success(request, "Le type de machine a été supprimé")
|
messages.success(request, "Le type de machine a été supprimé")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, machinetype_del, err)
|
||||||
request,
|
|
||||||
("Le type de machine %s est affectée à au moins une "
|
|
||||||
"machine, vous ne pouvez pas le supprimer"
|
|
||||||
% machinetype_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse('machines:index-machinetype'))
|
return redirect(reverse('machines:index-machinetype'))
|
||||||
return form(
|
return form(
|
||||||
{'machinetypeform': machinetype, 'action_name': 'Supprimer'},
|
{'machinetypeform': machinetype, 'action_name': 'Supprimer'},
|
||||||
|
@ -627,13 +621,8 @@ def del_extension(request, instances):
|
||||||
try:
|
try:
|
||||||
extension_del.delete()
|
extension_del.delete()
|
||||||
messages.success(request, "L'extension a été supprimée")
|
messages.success(request, "L'extension a été supprimée")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, extension_del, err)
|
||||||
request,
|
|
||||||
("L'extension %s est affectée à au moins un type de "
|
|
||||||
"machine, vous ne pouvez pas la supprimer"
|
|
||||||
% extension_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
return form(
|
return form(
|
||||||
{'extensionform': extension, 'action_name': 'Supprimer'},
|
{'extensionform': extension, 'action_name': 'Supprimer'},
|
||||||
|
@ -686,12 +675,8 @@ def del_soa(request, instances):
|
||||||
try:
|
try:
|
||||||
soa_del.delete()
|
soa_del.delete()
|
||||||
messages.success(request, "Le SOA a été supprimée")
|
messages.success(request, "Le SOA a été supprimée")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, soa_del, err)
|
||||||
request,
|
|
||||||
("Erreur le SOA suivant %s ne peut être supprimé"
|
|
||||||
% soa_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
return form(
|
return form(
|
||||||
{'soaform': soa, 'action_name': 'Supprimer'},
|
{'soaform': soa, 'action_name': 'Supprimer'},
|
||||||
|
@ -744,12 +729,8 @@ def del_mx(request, instances):
|
||||||
try:
|
try:
|
||||||
mx_del.delete()
|
mx_del.delete()
|
||||||
messages.success(request, "L'mx a été supprimée")
|
messages.success(request, "L'mx a été supprimée")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, mx_del, err)
|
||||||
request,
|
|
||||||
("Erreur le Mx suivant %s ne peut être supprimé"
|
|
||||||
% mx_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
return form(
|
return form(
|
||||||
{'mxform': mx, 'action_name': 'Supprimer'},
|
{'mxform': mx, 'action_name': 'Supprimer'},
|
||||||
|
@ -802,12 +783,8 @@ def del_ns(request, instances):
|
||||||
try:
|
try:
|
||||||
ns_del.delete()
|
ns_del.delete()
|
||||||
messages.success(request, "Le ns a été supprimée")
|
messages.success(request, "Le ns a été supprimée")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, ns_del, err)
|
||||||
request,
|
|
||||||
("Erreur le Ns suivant %s ne peut être supprimé"
|
|
||||||
% ns_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
return form(
|
return form(
|
||||||
{'nsform': ns, 'action_name': 'Supprimer'},
|
{'nsform': ns, 'action_name': 'Supprimer'},
|
||||||
|
@ -860,12 +837,8 @@ def del_txt(request, instances):
|
||||||
try:
|
try:
|
||||||
txt_del.delete()
|
txt_del.delete()
|
||||||
messages.success(request, "Le txt a été supprimé")
|
messages.success(request, "Le txt a été supprimé")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, txt_del, err)
|
||||||
request,
|
|
||||||
("Erreur le Txt suivant %s ne peut être supprimé"
|
|
||||||
% txt_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
return form(
|
return form(
|
||||||
{'txtform': txt, 'action_name': 'Supprimer'},
|
{'txtform': txt, 'action_name': 'Supprimer'},
|
||||||
|
@ -918,12 +891,8 @@ def del_srv(request, instances):
|
||||||
try:
|
try:
|
||||||
srv_del.delete()
|
srv_del.delete()
|
||||||
messages.success(request, "L'srv a été supprimée")
|
messages.success(request, "L'srv a été supprimée")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, srv_del, err)
|
||||||
request,
|
|
||||||
("Erreur le Srv suivant %s ne peut être supprimé"
|
|
||||||
% srv_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
return form(
|
return form(
|
||||||
{'srvform': srv, 'action_name': 'Supprimer'},
|
{'srvform': srv, 'action_name': 'Supprimer'},
|
||||||
|
@ -994,12 +963,8 @@ def del_alias(request, interface, interfaceid):
|
||||||
request,
|
request,
|
||||||
"L'alias %s a été supprimé" % alias_del
|
"L'alias %s a été supprimé" % alias_del
|
||||||
)
|
)
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, alias_del, err)
|
||||||
request,
|
|
||||||
("Erreur l'alias suivant %s ne peut être supprimé"
|
|
||||||
% alias_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
'machines:index-alias',
|
'machines:index-alias',
|
||||||
kwargs={'interfaceid': str(interfaceid)}
|
kwargs={'interfaceid': str(interfaceid)}
|
||||||
|
@ -1055,12 +1020,8 @@ def del_service(request, instances):
|
||||||
try:
|
try:
|
||||||
service_del.delete()
|
service_del.delete()
|
||||||
messages.success(request, "Le service a été supprimée")
|
messages.success(request, "Le service a été supprimée")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, service_del, err)
|
||||||
request,
|
|
||||||
("Erreur le service suivant %s ne peut être supprimé"
|
|
||||||
% service_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse('machines:index-service'))
|
return redirect(reverse('machines:index-service'))
|
||||||
return form(
|
return form(
|
||||||
{'serviceform': service, 'action_name': 'Supprimer'},
|
{'serviceform': service, 'action_name': 'Supprimer'},
|
||||||
|
@ -1113,12 +1074,8 @@ def del_vlan(request, instances):
|
||||||
try:
|
try:
|
||||||
vlan_del.delete()
|
vlan_del.delete()
|
||||||
messages.success(request, "Le vlan a été supprimée")
|
messages.success(request, "Le vlan a été supprimée")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, vlan_del, err)
|
||||||
request,
|
|
||||||
("Erreur le Vlan suivant %s ne peut être supprimé"
|
|
||||||
% vlan_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse('machines:index-vlan'))
|
return redirect(reverse('machines:index-vlan'))
|
||||||
return form(
|
return form(
|
||||||
{'vlanform': vlan, 'action_name': 'Supprimer'},
|
{'vlanform': vlan, 'action_name': 'Supprimer'},
|
||||||
|
@ -1171,12 +1128,8 @@ def del_nas(request, instances):
|
||||||
try:
|
try:
|
||||||
nas_del.delete()
|
nas_del.delete()
|
||||||
messages.success(request, "Le nas a été supprimé")
|
messages.success(request, "Le nas a été supprimé")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, nas_del, err)
|
||||||
request,
|
|
||||||
("Erreur le Nas suivant %s ne peut être supprimé"
|
|
||||||
% nas_del)
|
|
||||||
)
|
|
||||||
return redirect(reverse('machines:index-nas'))
|
return redirect(reverse('machines:index-nas'))
|
||||||
return form(
|
return form(
|
||||||
{'nasform': nas, 'action_name': 'Supprimer'},
|
{'nasform': nas, 'action_name': 'Supprimer'},
|
||||||
|
|
|
@ -36,11 +36,13 @@ from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db.models import ProtectedError
|
from django.db.models import ProtectedError
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
|
|
||||||
from re2o.views import form
|
from re2o.views import form
|
||||||
from re2o.acl import can_create, can_edit, can_delete_set, can_view_all
|
from re2o.acl import can_create, can_edit, can_delete_set, can_view_all
|
||||||
|
from re2o.utils import messages_protected_error
|
||||||
|
|
||||||
from .forms import ServiceForm, DelServiceForm
|
from .forms import ServiceForm, DelServiceForm
|
||||||
from .models import (
|
from .models import (
|
||||||
|
@ -180,9 +182,8 @@ def del_services(request, instances):
|
||||||
services_del.delete()
|
services_del.delete()
|
||||||
reversion.set_user(request.user)
|
reversion.set_user(request.user)
|
||||||
messages.success(request, "Le service a été supprimée")
|
messages.success(request, "Le service a été supprimée")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(request, "Erreur le service\
|
messages_protected_error(messages, request, service_del, err)
|
||||||
suivant %s ne peut être supprimé" % services_del)
|
|
||||||
return redirect(reverse('preferences:display-options'))
|
return redirect(reverse('preferences:display-options'))
|
||||||
return form(
|
return form(
|
||||||
{'preferenceform': services, 'action_name': 'Supprimer'},
|
{'preferenceform': services, 'action_name': 'Supprimer'},
|
||||||
|
|
|
@ -47,11 +47,12 @@ from django.template.loader import get_template
|
||||||
from django.template import Context, Template, loader
|
from django.template import Context, Template, loader
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from users.views import form
|
from users.views import form
|
||||||
from re2o.utils import re2o_paginator, SortTable
|
from re2o.utils import re2o_paginator, SortTable, messages_protected_error
|
||||||
from re2o.acl import (
|
from re2o.acl import (
|
||||||
can_create,
|
can_create,
|
||||||
can_edit,
|
can_edit,
|
||||||
|
@ -350,12 +351,8 @@ def del_port(request, port, **_kwargs):
|
||||||
try:
|
try:
|
||||||
port.delete()
|
port.delete()
|
||||||
messages.success(request, "Le port a été détruit")
|
messages.success(request, "Le port a été détruit")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, port, err)
|
||||||
request,
|
|
||||||
("Le port %s est affecté à un autre objet, impossible "
|
|
||||||
"de le supprimer" % port)
|
|
||||||
)
|
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
'topologie:index-port',
|
'topologie:index-port',
|
||||||
kwargs={'switchid': str(port.switch.id)}
|
kwargs={'switchid': str(port.switch.id)}
|
||||||
|
@ -404,11 +401,7 @@ def del_stack(request, stack, **_kwargs):
|
||||||
stack.delete()
|
stack.delete()
|
||||||
messages.success(request, "La stack a eté détruite")
|
messages.success(request, "La stack a eté détruite")
|
||||||
except ProtectedError:
|
except ProtectedError:
|
||||||
messages.error(
|
messages_protected_error(messages, request, satck, err)
|
||||||
request,
|
|
||||||
("La stack %s est affectée à un autre objet, impossible "
|
|
||||||
"de la supprimer" % stack)
|
|
||||||
)
|
|
||||||
return redirect(reverse('topologie:index-physical-grouping'))
|
return redirect(reverse('topologie:index-physical-grouping'))
|
||||||
return form({'objet': stack}, 'topologie/delete.html', request)
|
return form({'objet': stack}, 'topologie/delete.html', request)
|
||||||
|
|
||||||
|
@ -715,11 +708,7 @@ def del_room(request, room, **_kwargs):
|
||||||
room.delete()
|
room.delete()
|
||||||
messages.success(request, "La chambre/prise a été détruite")
|
messages.success(request, "La chambre/prise a été détruite")
|
||||||
except ProtectedError:
|
except ProtectedError:
|
||||||
messages.error(
|
messages_protected_error(messages, request, room, err)
|
||||||
request,
|
|
||||||
("La chambre %s est affectée à un autre objet, impossible "
|
|
||||||
"de la supprimer (switch ou user)" % room)
|
|
||||||
)
|
|
||||||
return redirect(reverse('topologie:index-room'))
|
return redirect(reverse('topologie:index-room'))
|
||||||
return form(
|
return form(
|
||||||
{'objet': room, 'objet_name': 'Chambre'},
|
{'objet': room, 'objet_name': 'Chambre'},
|
||||||
|
@ -774,11 +763,7 @@ def del_model_switch(request, model_switch, **_kwargs):
|
||||||
model_switch.delete()
|
model_switch.delete()
|
||||||
messages.success(request, "Le modèle a été détruit")
|
messages.success(request, "Le modèle a été détruit")
|
||||||
except ProtectedError:
|
except ProtectedError:
|
||||||
messages.error(
|
messages_protected_error(messages, request, model_switch, err)
|
||||||
request,
|
|
||||||
("Le modèle %s est affectée à un autre objet, impossible "
|
|
||||||
"de la supprimer (switch ou user)" % model_switch)
|
|
||||||
)
|
|
||||||
return redirect(reverse('topologie:index-model-switch'))
|
return redirect(reverse('topologie:index-model-switch'))
|
||||||
return form(
|
return form(
|
||||||
{'objet': model_switch, 'objet_name': 'Modèle de switch'},
|
{'objet': model_switch, 'objet_name': 'Modèle de switch'},
|
||||||
|
@ -829,11 +814,7 @@ def del_switch_bay(request, switch_bay, **_kwargs):
|
||||||
switch_bay.delete()
|
switch_bay.delete()
|
||||||
messages.success(request, "La baie a été détruite")
|
messages.success(request, "La baie a été détruite")
|
||||||
except ProtectedError:
|
except ProtectedError:
|
||||||
messages.error(
|
messages_protected_error(messages, request, switch_bay, err)
|
||||||
request,
|
|
||||||
("La baie %s est affecté à un autre objet, impossible "
|
|
||||||
"de la supprimer (switch ou user)" % switch_bay)
|
|
||||||
)
|
|
||||||
return redirect(reverse('topologie:index-physical-grouping'))
|
return redirect(reverse('topologie:index-physical-grouping'))
|
||||||
return form(
|
return form(
|
||||||
{'objet': switch_bay, 'objet_name': 'Baie de switch'},
|
{'objet': switch_bay, 'objet_name': 'Baie de switch'},
|
||||||
|
@ -883,12 +864,8 @@ def del_building(request, building, **_kwargs):
|
||||||
try:
|
try:
|
||||||
building.delete()
|
building.delete()
|
||||||
messages.success(request, "La batiment a été détruit")
|
messages.success(request, "La batiment a été détruit")
|
||||||
except ProtectedError:
|
except ProtectedError as err:
|
||||||
messages.error(
|
messages_protected_error(messages, request, building, err)
|
||||||
request,
|
|
||||||
("Le batiment %s est affecté à un autre objet, impossible "
|
|
||||||
"de la supprimer (switch ou user)" % building)
|
|
||||||
)
|
|
||||||
return redirect(reverse('topologie:index-physical-grouping'))
|
return redirect(reverse('topologie:index-physical-grouping'))
|
||||||
return form(
|
return form(
|
||||||
{'objet': building, 'objet_name': 'Bâtiment'},
|
{'objet': building, 'objet_name': 'Bâtiment'},
|
||||||
|
@ -943,11 +920,7 @@ def del_constructor_switch(request, constructor_switch, **_kwargs):
|
||||||
constructor_switch.delete()
|
constructor_switch.delete()
|
||||||
messages.success(request, "Le constructeur a été détruit")
|
messages.success(request, "Le constructeur a été détruit")
|
||||||
except ProtectedError:
|
except ProtectedError:
|
||||||
messages.error(
|
messages_protected_error(messages, request, constructor_switch, err)
|
||||||
request,
|
|
||||||
("Le constructeur %s est affecté à un autre objet, impossible "
|
|
||||||
"de la supprimer (switch ou user)" % constructor_switch)
|
|
||||||
)
|
|
||||||
return redirect(reverse('topologie:index-model-switch'))
|
return redirect(reverse('topologie:index-model-switch'))
|
||||||
return form({
|
return form({
|
||||||
'objet': constructor_switch,
|
'objet': constructor_switch,
|
||||||
|
|
|
@ -45,6 +45,7 @@ from django.db import transaction
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from rest_framework.renderers import JSONRenderer
|
from rest_framework.renderers import JSONRenderer
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
|
@ -56,7 +57,8 @@ from re2o.views import form
|
||||||
from re2o.utils import (
|
from re2o.utils import (
|
||||||
all_has_access,
|
all_has_access,
|
||||||
SortTable,
|
SortTable,
|
||||||
re2o_paginator
|
re2o_paginator,
|
||||||
|
messages_protected_error
|
||||||
)
|
)
|
||||||
from re2o.acl import (
|
from re2o.acl import (
|
||||||
can_create,
|
can_create,
|
||||||
|
@ -510,10 +512,7 @@ def del_school(request, instances):
|
||||||
school_del.delete()
|
school_del.delete()
|
||||||
messages.success(request, "L'établissement a été supprimé")
|
messages.success(request, "L'établissement a été supprimé")
|
||||||
except ProtectedError:
|
except ProtectedError:
|
||||||
messages.error(
|
messages_protected_error(messages, request, school_del, err)
|
||||||
request,
|
|
||||||
"L'établissement %s est affecté à au moins un user, \
|
|
||||||
vous ne pouvez pas le supprimer" % school_del)
|
|
||||||
return redirect(reverse('users:index-school'))
|
return redirect(reverse('users:index-school'))
|
||||||
return form(
|
return form(
|
||||||
{'userform': school, 'action_name': 'Supprimer'},
|
{'userform': school, 'action_name': 'Supprimer'},
|
||||||
|
@ -621,10 +620,7 @@ def del_listright(request, instances):
|
||||||
listright_del.delete()
|
listright_del.delete()
|
||||||
messages.success(request, "Le droit/groupe a été supprimé")
|
messages.success(request, "Le droit/groupe a été supprimé")
|
||||||
except ProtectedError:
|
except ProtectedError:
|
||||||
messages.error(
|
messages_protected_error(messages, request, listright_del, err)
|
||||||
request,
|
|
||||||
"Le groupe %s est affecté à au moins un user, \
|
|
||||||
vous ne pouvez pas le supprimer" % listright_del)
|
|
||||||
return redirect(reverse('users:index-listright'))
|
return redirect(reverse('users:index-listright'))
|
||||||
return form(
|
return form(
|
||||||
{'userform': listright, 'action_name': 'Supprimer'},
|
{'userform': listright, 'action_name': 'Supprimer'},
|
||||||
|
|
Loading…
Reference in a new issue