mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-22 23:13:46 +00:00
Fix : possibilité de mettre plusieurs clefs radius sans crash
This commit is contained in:
parent
c5f96fee62
commit
144119c26a
2 changed files with 28 additions and 2 deletions
20
preferences/migrations/0065_auto_20191010_1227.py
Normal file
20
preferences/migrations/0065_auto_20191010_1227.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.23 on 2019-10-10 10:27
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('preferences', '0064_auto_20191008_1335'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='radiuskey',
|
||||
name='default_switch',
|
||||
field=models.BooleanField(default=False, help_text='Default key for switches'),
|
||||
),
|
||||
]
|
|
@ -330,8 +330,7 @@ class RadiusKey(AclMixin, models.Model):
|
|||
help_text=_("Comment for this key")
|
||||
)
|
||||
default_switch = models.BooleanField(
|
||||
default=True,
|
||||
unique=True,
|
||||
default=False,
|
||||
help_text=_("Default key for switches")
|
||||
)
|
||||
|
||||
|
@ -342,6 +341,13 @@ class RadiusKey(AclMixin, models.Model):
|
|||
verbose_name = _("RADIUS key")
|
||||
verbose_name_plural = _("RADIUS keys")
|
||||
|
||||
def clean(self):
|
||||
"""Clean model:
|
||||
Check default switch is unique
|
||||
"""
|
||||
if RadiusKey.objects.filter(default_switch=True).count() > 1:
|
||||
raise ValidationError(_("Default radiuskey for switchs already exist"))
|
||||
|
||||
def __str__(self):
|
||||
return _("RADIUS key ") + str(self.id) + " " + str(self.comment)
|
||||
|
||||
|
|
Loading…
Reference in a new issue