2017-06-25 22:50:55 +00:00
|
|
|
# Re2o un logiciel d'administration développé initiallement au rezometz. Il
|
|
|
|
# se veut agnostique au réseau considéré, de manière à être installable en
|
|
|
|
# quelques clics.
|
|
|
|
#
|
|
|
|
# Copyright © 2017 Gabriel Détraz
|
|
|
|
# Copyright © 2017 Goulven Kermarec
|
|
|
|
# Copyright © 2017 Augustin Lemesle
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
from django.forms import ModelForm, Form, ValidationError
|
|
|
|
from django import forms
|
2017-08-26 13:10:18 +00:00
|
|
|
from .models import OptionalUser, OptionalMachine, OptionalTopologie, GeneralOption, AssoOption, Service
|
2017-06-25 22:50:55 +00:00
|
|
|
from django.db.models import Q
|
|
|
|
|
2017-08-24 19:36:59 +00:00
|
|
|
class EditOptionalUserForm(ModelForm):
|
2017-06-25 22:50:55 +00:00
|
|
|
class Meta:
|
|
|
|
model = OptionalUser
|
|
|
|
fields = '__all__'
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2017-08-24 19:36:59 +00:00
|
|
|
super(EditOptionalUserForm, self).__init__(*args, **kwargs)
|
2017-06-25 22:50:55 +00:00
|
|
|
self.fields['is_tel_mandatory'].label = 'Exiger un numéro de téléphone'
|
|
|
|
self.fields['user_solde'].label = 'Activation du solde pour les utilisateurs'
|
|
|
|
|
2017-08-24 19:36:59 +00:00
|
|
|
class EditOptionalMachineForm(ModelForm):
|
2017-06-25 22:50:55 +00:00
|
|
|
class Meta:
|
|
|
|
model = OptionalMachine
|
|
|
|
fields = '__all__'
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2017-08-24 19:36:59 +00:00
|
|
|
super(EditOptionalMachineForm, self).__init__(*args, **kwargs)
|
2017-06-25 22:50:55 +00:00
|
|
|
self.fields['password_machine'].label = "Possibilité d'attribuer un mot de passe par interface"
|
|
|
|
self.fields['max_lambdauser_interfaces'].label = "Maximum d'interfaces autorisées pour un user normal"
|
|
|
|
self.fields['max_lambdauser_aliases'].label = "Maximum d'alias dns autorisés pour un user normal"
|
|
|
|
|
2017-08-26 13:10:18 +00:00
|
|
|
class EditOptionalTopologieForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = OptionalTopologie
|
|
|
|
fields = '__all__'
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(EditOptionalTopologieForm, self).__init__(*args, **kwargs)
|
|
|
|
self.fields['vlan_decision_ok'].label = "Vlan où placer les machines après acceptation RADIUS"
|
|
|
|
self.fields['vlan_decision_nok'].label = "Vlan où placer les machines après rejet RADIUS"
|
2017-06-25 22:50:55 +00:00
|
|
|
|
2017-08-24 19:36:59 +00:00
|
|
|
class EditGeneralOptionForm(ModelForm):
|
2017-06-25 22:50:55 +00:00
|
|
|
class Meta:
|
|
|
|
model = GeneralOption
|
|
|
|
fields = '__all__'
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2017-08-24 19:36:59 +00:00
|
|
|
super(EditGeneralOptionForm, self).__init__(*args, **kwargs)
|
2017-06-25 22:50:55 +00:00
|
|
|
self.fields['search_display_page'].label = 'Resultats affichés dans une recherche'
|
|
|
|
self.fields['pagination_number'].label = 'Items par page, taille normale (ex users)'
|
|
|
|
self.fields['pagination_large_number'].label = 'Items par page, taille élevée (machines)'
|
2017-08-24 19:36:59 +00:00
|
|
|
|
|
|
|
class EditAssoOptionForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = AssoOption
|
|
|
|
fields = '__all__'
|
|
|
|
|
2017-08-25 02:35:49 +00:00
|
|
|
class ServiceForm(ModelForm):
|
2017-08-24 19:36:59 +00:00
|
|
|
class Meta:
|
|
|
|
model = Service
|
|
|
|
fields = '__all__'
|
2017-08-25 02:35:49 +00:00
|
|
|
|
|
|
|
class DelServiceForm(Form):
|
|
|
|
services = forms.ModelMultipleChoiceField(queryset=Service.objects.all(), label="Enregistrements service actuels", widget=forms.CheckboxSelectMultiple)
|