Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nounous
re2o
Commits
c92b6887
Commit
c92b6887
authored
Jan 11, 2019
by
Hugo LEVY-FALK
Committed by
chirac
Jan 11, 2019
Browse files
Fix radius options, force to set a vlan when adding a policy which requires it.
parent
3443965e
Changes
1
Hide whitespace changes
Inline
Side-by-side
preferences/forms.py
View file @
c92b6887
...
...
@@ -231,6 +231,27 @@ class EditRadiusOptionForm(ModelForm):
model
=
RadiusOption
fields
=
'__all__'
def
clean
(
self
):
cleaned_data
=
super
().
clean
()
ignored
=
(
'radius_general_policy'
,
'vlan_decision_ok'
)
fields
=
(
f
for
f
in
self
.
fields
.
keys
()
if
'vlan'
not
in
f
and
f
not
in
ignored
)
for
f
in
fields
:
choice
=
cleaned_data
.
get
(
f
)
vlan
=
cleaned_data
.
get
(
f
+
'_vlan'
)
if
choice
==
RadiusOption
.
SET_VLAN
and
vlan
is
None
:
self
.
add_error
(
f
,
_
(
"You chose to set vlan but did not set any VLAN."
),
)
self
.
add_error
(
f
+
'_vlan'
,
_
(
"Please, choose a VLAN."
),
)
return
cleaned_data
class
ServiceForm
(
ModelForm
):
"""Edition, ajout de services sur la page d'accueil"""
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment