mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-16 08:23:12 +00:00
patch
This commit is contained in:
parent
a96a2f50fa
commit
ba9d5211b9
1 changed files with 15 additions and 9 deletions
|
@ -96,7 +96,8 @@ def edit_options_template_function(request, section, forms, models):
|
||||||
return redirect(reverse("preferences:display-options"))
|
return redirect(reverse("preferences:display-options"))
|
||||||
|
|
||||||
options_instance, _created = model.objects.get_or_create()
|
options_instance, _created = model.objects.get_or_create()
|
||||||
_is_allowed_to_edit, msg, permissions = options_instance.can_edit(request.user)
|
_is_allowed_to_edit, msg, permissions = options_instance.can_edit(
|
||||||
|
request.user)
|
||||||
if not _is_allowed_to_edit:
|
if not _is_allowed_to_edit:
|
||||||
messages.error(request, acl_error_message(msg, permissions))
|
messages.error(request, acl_error_message(msg, permissions))
|
||||||
return redirect(reverse("index"))
|
return redirect(reverse("index"))
|
||||||
|
@ -150,7 +151,7 @@ def display_options(request):
|
||||||
optionnal_templates_list = [
|
optionnal_templates_list = [
|
||||||
app.preferences.views.aff_preferences(request)
|
app.preferences.views.aff_preferences(request)
|
||||||
for app in optionnal_apps
|
for app in optionnal_apps
|
||||||
if hasattr(app.preferences.views, "aff_preferences")
|
if hasattr(app, "preferences") and hasattr(app.preferences.views, "aff_preferences")
|
||||||
]
|
]
|
||||||
|
|
||||||
return form(
|
return form(
|
||||||
|
@ -301,7 +302,8 @@ def add_radiuskey(request):
|
||||||
@can_edit(RadiusKey)
|
@can_edit(RadiusKey)
|
||||||
def edit_radiuskey(request, radiuskey_instance, **_kwargs):
|
def edit_radiuskey(request, radiuskey_instance, **_kwargs):
|
||||||
"""View used to edit RADIUS keys."""
|
"""View used to edit RADIUS keys."""
|
||||||
radiuskey = RadiusKeyForm(request.POST or None, instance=radiuskey_instance)
|
radiuskey = RadiusKeyForm(request.POST or None,
|
||||||
|
instance=radiuskey_instance)
|
||||||
if radiuskey.is_valid():
|
if radiuskey.is_valid():
|
||||||
radiuskey.save()
|
radiuskey.save()
|
||||||
messages.success(request, _("The RADIUS key was edited."))
|
messages.success(request, _("The RADIUS key was edited."))
|
||||||
|
@ -344,10 +346,11 @@ def add_switchmanagementcred(request):
|
||||||
switchmanagementcred = SwitchManagementCredForm(request.POST or None)
|
switchmanagementcred = SwitchManagementCredForm(request.POST or None)
|
||||||
if switchmanagementcred.is_valid():
|
if switchmanagementcred.is_valid():
|
||||||
switchmanagementcred.save()
|
switchmanagementcred.save()
|
||||||
messages.success(request, _("The switch management credentials were added."))
|
messages.success(request, _(
|
||||||
|
"The switch management credentials were added."))
|
||||||
return redirect(reverse("preferences:display-options"))
|
return redirect(reverse("preferences:display-options"))
|
||||||
return form(
|
return form(
|
||||||
{"preferenceform": switchmanagementcred, "action_name": _("Add"),},
|
{"preferenceform": switchmanagementcred, "action_name": _("Add"), },
|
||||||
"preferences/preferences.html",
|
"preferences/preferences.html",
|
||||||
request,
|
request,
|
||||||
)
|
)
|
||||||
|
@ -361,7 +364,8 @@ def edit_switchmanagementcred(request, switchmanagementcred_instance, **_kwargs)
|
||||||
)
|
)
|
||||||
if switchmanagementcred.is_valid():
|
if switchmanagementcred.is_valid():
|
||||||
switchmanagementcred.save()
|
switchmanagementcred.save()
|
||||||
messages.success(request, _("The switch management credentials were edited."))
|
messages.success(request, _(
|
||||||
|
"The switch management credentials were edited."))
|
||||||
return redirect(reverse("preferences:display-options"))
|
return redirect(reverse("preferences:display-options"))
|
||||||
return form(
|
return form(
|
||||||
{"preferenceform": switchmanagementcred, "action_name": _("Edit")},
|
{"preferenceform": switchmanagementcred, "action_name": _("Edit")},
|
||||||
|
@ -410,7 +414,7 @@ def add_mailcontact(request):
|
||||||
messages.success(request, _("The contact email address was created."))
|
messages.success(request, _("The contact email address was created."))
|
||||||
return redirect(reverse("preferences:display-options"))
|
return redirect(reverse("preferences:display-options"))
|
||||||
return form(
|
return form(
|
||||||
{"preferenceform": mailcontact, "action_name": _("Add"),},
|
{"preferenceform": mailcontact, "action_name": _("Add"), },
|
||||||
"preferences/preferences.html",
|
"preferences/preferences.html",
|
||||||
request,
|
request,
|
||||||
)
|
)
|
||||||
|
@ -438,12 +442,14 @@ def edit_mailcontact(request, mailcontact_instance, **_kwargs):
|
||||||
@can_delete_set(MailContact)
|
@can_delete_set(MailContact)
|
||||||
def del_mailcontact(request, instances):
|
def del_mailcontact(request, instances):
|
||||||
"""View used to delete one or several contact email addresses."""
|
"""View used to delete one or several contact email addresses."""
|
||||||
mailcontacts = DelMailContactForm(request.POST or None, instances=instances)
|
mailcontacts = DelMailContactForm(
|
||||||
|
request.POST or None, instances=instances)
|
||||||
if mailcontacts.is_valid():
|
if mailcontacts.is_valid():
|
||||||
mailcontacts_dels = mailcontacts.cleaned_data["mailcontacts"]
|
mailcontacts_dels = mailcontacts.cleaned_data["mailcontacts"]
|
||||||
for mailcontacts_del in mailcontacts_dels:
|
for mailcontacts_del in mailcontacts_dels:
|
||||||
mailcontacts_del.delete()
|
mailcontacts_del.delete()
|
||||||
messages.success(request, _("The contact email adress was deleted."))
|
messages.success(request, _(
|
||||||
|
"The contact email adress was deleted."))
|
||||||
return redirect(reverse("preferences:display-options"))
|
return redirect(reverse("preferences:display-options"))
|
||||||
return form(
|
return form(
|
||||||
{"preferenceform": mailcontacts, "action_name": _("Delete")},
|
{"preferenceform": mailcontacts, "action_name": _("Delete")},
|
||||||
|
|
Loading…
Reference in a new issue