mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-22 23:13:46 +00:00
Merge branch 'fix_radius_option_validation' into 'dev'
Fix radius options, force to set a vlan when adding a policy which requires it. See merge request federez/re2o!392
This commit is contained in:
commit
54a5dca858
1 changed files with 21 additions and 0 deletions
|
@ -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"""
|
||||
|
|
Loading…
Reference in a new issue