mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-09-12 01:03:09 +00:00
Merge branch 'fix_duplicate_id_n_name' into 'master'
Evite les doublons dans les id et les names des forms See merge request rezo/re2o!14
This commit is contained in:
commit
5cd5af5b1f
7 changed files with 149 additions and 49 deletions
|
@ -30,7 +30,8 @@ from .models import Article, Paiement, Facture, Banque, Vente
|
|||
|
||||
class NewFactureForm(ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(NewFactureForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(NewFactureForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['cheque'].required = False
|
||||
self.fields['banque'].required = False
|
||||
self.fields['cheque'].label = 'Numero de chèque'
|
||||
|
@ -102,7 +103,8 @@ class ArticleForm(ModelForm):
|
|||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ArticleForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(ArticleForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['name'].label = "Désignation de l'article"
|
||||
|
||||
class DelArticleForm(Form):
|
||||
|
@ -114,7 +116,8 @@ class PaiementForm(ModelForm):
|
|||
fields = ['moyen', 'type_paiement']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PaiementForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(PaiementForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['moyen'].label = 'Moyen de paiement à ajouter'
|
||||
self.fields['type_paiement'].label = 'Type de paiement à ajouter'
|
||||
|
||||
|
@ -127,7 +130,8 @@ class BanqueForm(ModelForm):
|
|||
fields = ['name']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BanqueForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(BanqueForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['name'].label = 'Banque à ajouter'
|
||||
|
||||
class DelBanqueForm(Form):
|
||||
|
|
|
@ -40,7 +40,8 @@ class EditMachineForm(ModelForm):
|
|||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditMachineForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditMachineForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['name'].label = 'Nom de la machine'
|
||||
|
||||
class NewMachineForm(EditMachineForm):
|
||||
|
@ -57,7 +58,8 @@ class EditInterfaceForm(ModelForm):
|
|||
fields = ['machine', 'type', 'ipv4', 'mac_address', 'details']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditInterfaceForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditInterfaceForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['mac_address'].label = 'Adresse mac'
|
||||
self.fields['type'].label = 'Type de machine'
|
||||
self.fields['type'].empty_label = "Séléctionner un type de machine"
|
||||
|
@ -110,9 +112,10 @@ class AliasForm(ModelForm):
|
|||
fields = ['name','extension']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
if 'infra' in kwargs:
|
||||
infra = kwargs.pop('infra')
|
||||
super(AliasForm, self).__init__(*args, **kwargs)
|
||||
super(AliasForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class DomainForm(AliasForm):
|
||||
class Meta(AliasForm.Meta):
|
||||
|
@ -125,7 +128,8 @@ class DomainForm(AliasForm):
|
|||
initial = kwargs.get('initial', {})
|
||||
initial['name'] = user.get_next_domain_name()
|
||||
kwargs['initial'] = initial
|
||||
super(DomainForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(DomainForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class DelAliasForm(Form):
|
||||
alias = forms.ModelMultipleChoiceField(queryset=Domain.objects.all(), label="Alias actuels", widget=forms.CheckboxSelectMultiple)
|
||||
|
@ -141,7 +145,8 @@ class MachineTypeForm(ModelForm):
|
|||
fields = ['type','ip_type']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MachineTypeForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(MachineTypeForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['type'].label = 'Type de machine à ajouter'
|
||||
self.fields['ip_type'].label = "Type d'ip relié"
|
||||
|
||||
|
@ -153,9 +158,9 @@ class IpTypeForm(ModelForm):
|
|||
model = IpType
|
||||
fields = ['type','extension','need_infra','domaine_ip_start','domaine_ip_stop', 'prefix_v6', 'vlan']
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(IpTypeForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(IpTypeForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['type'].label = 'Type ip à ajouter'
|
||||
|
||||
class EditIpTypeForm(IpTypeForm):
|
||||
|
@ -171,7 +176,8 @@ class ExtensionForm(ModelForm):
|
|||
fields = ['name', 'need_infra', 'origin']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ExtensionForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(ExtensionForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['name'].label = 'Extension à ajouter'
|
||||
self.fields['origin'].label = 'Enregistrement A origin'
|
||||
|
||||
|
@ -184,7 +190,8 @@ class MxForm(ModelForm):
|
|||
fields = ['zone', 'priority', 'name']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MxForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(MxForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['name'].queryset = Domain.objects.exclude(interface_parent=None)
|
||||
|
||||
class DelMxForm(Form):
|
||||
|
@ -196,7 +203,8 @@ class NsForm(ModelForm):
|
|||
fields = ['zone', 'ns']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(NsForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(NsForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['ns'].queryset = Domain.objects.exclude(interface_parent=None)
|
||||
|
||||
class DelNsForm(Form):
|
||||
|
@ -207,6 +215,10 @@ class TextForm(ModelForm):
|
|||
model = Text
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(TextForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class DelTextForm(Form):
|
||||
text = forms.ModelMultipleChoiceField(queryset=Text.objects.all(), label="Enregistrements Text actuels", widget=forms.CheckboxSelectMultiple)
|
||||
|
||||
|
@ -215,6 +227,10 @@ class NasForm(ModelForm):
|
|||
model = Nas
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(NasForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class DelNasForm(Form):
|
||||
nas = forms.ModelMultipleChoiceField(queryset=Nas.objects.all(), label="Enregistrements Nas actuels", widget=forms.CheckboxSelectMultiple)
|
||||
|
||||
|
@ -223,6 +239,10 @@ class ServiceForm(ModelForm):
|
|||
model = Service
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(ServiceForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
def save(self, commit=True):
|
||||
instance = super(ServiceForm, self).save(commit=False)
|
||||
if commit:
|
||||
|
@ -238,6 +258,10 @@ class VlanForm(ModelForm):
|
|||
model = Vlan
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(VlanForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class DelVlanForm(Form):
|
||||
vlan = forms.ModelMultipleChoiceField(queryset=Vlan.objects.all(), label="Vlan actuels", widget=forms.CheckboxSelectMultiple)
|
||||
|
||||
|
@ -246,8 +270,16 @@ class EditOuverturePortConfigForm(ModelForm):
|
|||
model = Interface
|
||||
fields = ['port_lists']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditOuverturePortConfigForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class EditOuverturePortListForm(ModelForm):
|
||||
class Meta:
|
||||
model = OuverturePortList
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditOuverturePortListForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
|
|
|
@ -195,20 +195,20 @@ def bootstrap_form_typeahead(django_form, typeahead_fields, *args, **kwargs):
|
|||
|
||||
return mark_safe( form )
|
||||
|
||||
def input_id( f_name ) :
|
||||
def input_id( f_bound ) :
|
||||
""" The id of the HTML input element """
|
||||
return 'id_'+f_name
|
||||
return f_bound.auto_id
|
||||
|
||||
def hidden_id( f_name ):
|
||||
def hidden_id( f_bound ):
|
||||
""" The id of the HTML hidden input element """
|
||||
return 'typeahead_hidden_'+f_name
|
||||
return input_id( f_bound ) +'_hidden'
|
||||
|
||||
def hidden_tag( f_bound, f_name ):
|
||||
""" The HTML hidden input element """
|
||||
return render_tag(
|
||||
'input',
|
||||
attrs={
|
||||
'id': hidden_id(f_name),
|
||||
'id': hidden_id( f_bound ),
|
||||
'name': f_name,
|
||||
'type': 'hidden',
|
||||
'value': f_bound.value() or ""
|
||||
|
@ -249,10 +249,10 @@ def typeahead_js( f_name, f_value, f_bound,
|
|||
f_name = f_name,
|
||||
choices = choices,
|
||||
engine = engine,
|
||||
input_id = input_id( f_name ),
|
||||
input_id = input_id( f_bound ),
|
||||
datasets = default_datasets( f_name, match_func ),
|
||||
updater = typeahead_updater( f_name ),
|
||||
change = typeahead_change( f_name ),
|
||||
updater = typeahead_updater( f_bound ),
|
||||
change = typeahead_change( f_bound ),
|
||||
updates = ''.join( [ (
|
||||
'$( "#{u_id}" ).change( function() {{'
|
||||
'setup_{f_name}();'
|
||||
|
@ -260,7 +260,7 @@ def typeahead_js( f_name, f_value, f_bound,
|
|||
'}} );'
|
||||
).format(
|
||||
u_id = u_id,
|
||||
reset_input = reset_input( f_name ),
|
||||
reset_input = reset_input( f_bound ),
|
||||
f_name = f_name
|
||||
) for u_id in update_on ]
|
||||
),
|
||||
|
@ -276,24 +276,24 @@ def init_input( f_name, f_bound ) :
|
|||
'$( "#{input_id}" ).typeahead("val", {init_val});'
|
||||
'$( "#{hidden_id}" ).val( {init_key} );'
|
||||
).format(
|
||||
input_id = input_id( f_name ),
|
||||
input_id = input_id( f_bound ),
|
||||
init_val = '""' if init_key == '""' else
|
||||
'engine_{f_name}.get( {init_key} )[0].value'.format(
|
||||
f_name = f_name,
|
||||
init_key = init_key
|
||||
),
|
||||
init_key = init_key,
|
||||
hidden_id = hidden_id( f_name )
|
||||
hidden_id = hidden_id( f_bound )
|
||||
)
|
||||
|
||||
def reset_input( f_name ) :
|
||||
def reset_input( f_bound ) :
|
||||
""" The JS script to reset the fields values """
|
||||
return (
|
||||
'$( "#{input_id}" ).typeahead("val", "");'
|
||||
'$( "#{hidden_id}" ).val( "" );'
|
||||
).format(
|
||||
input_id = input_id( f_name ),
|
||||
hidden_id = hidden_id( f_name )
|
||||
input_id = input_id( f_bound ),
|
||||
hidden_id = hidden_id( f_bound )
|
||||
)
|
||||
|
||||
def default_choices( f_value ) :
|
||||
|
@ -355,7 +355,7 @@ def default_match_func ( f_name ) :
|
|||
f_name = f_name
|
||||
)
|
||||
|
||||
def typeahead_updater( f_name ):
|
||||
def typeahead_updater( f_bound ):
|
||||
""" The JS script creating the function triggered when an item is
|
||||
selected through typeahead """
|
||||
return (
|
||||
|
@ -365,10 +365,10 @@ def typeahead_updater( f_name ):
|
|||
'return item;'
|
||||
'}}'
|
||||
).format(
|
||||
hidden_id = hidden_id( f_name )
|
||||
hidden_id = hidden_id( f_bound )
|
||||
)
|
||||
|
||||
def typeahead_change( f_name ):
|
||||
def typeahead_change( f_bound ):
|
||||
""" The JS script creating the function triggered when an item is changed
|
||||
(i.e. looses focus and value has changed since the moment it gained focus
|
||||
"""
|
||||
|
@ -380,7 +380,7 @@ def typeahead_change( f_name ):
|
|||
'}}'
|
||||
'}}'
|
||||
).format(
|
||||
input_id = input_id( f_name ),
|
||||
hidden_id = hidden_id( f_name )
|
||||
input_id = input_id( f_bound ),
|
||||
hidden_id = hidden_id( f_bound )
|
||||
)
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ def f_type_id( is_type_tt ):
|
|||
""" The id that will be used in HTML to store the value of the field
|
||||
type. Depends on the fact that type is generate using typeahead or not
|
||||
"""
|
||||
return hidden_id('type') if is_type_tt else input_id('type')
|
||||
return 'id_Interface-type_hidden' if is_type_tt else 'id_Interface-type'
|
||||
|
||||
def generate_ipv4_choices( form ) :
|
||||
""" Generate the parameter choices for the bootstrap_form_typeahead tag
|
||||
|
|
|
@ -33,7 +33,8 @@ class EditOptionalUserForm(ModelForm):
|
|||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditOptionalUserForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditOptionalUserForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
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'
|
||||
|
||||
|
@ -43,7 +44,8 @@ class EditOptionalMachineForm(ModelForm):
|
|||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditOptionalMachineForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditOptionalMachineForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
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"
|
||||
|
@ -54,7 +56,8 @@ class EditOptionalTopologieForm(ModelForm):
|
|||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditOptionalTopologieForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditOptionalTopologieForm, self).__init__(*args, prefix=prefix, **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"
|
||||
|
||||
|
@ -64,7 +67,8 @@ class EditGeneralOptionForm(ModelForm):
|
|||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditGeneralOptionForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditGeneralOptionForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
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)'
|
||||
|
@ -78,7 +82,8 @@ class EditAssoOptionForm(ModelForm):
|
|||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditAssoOptionForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditAssoOptionForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['name'].label = 'Nom de l\'asso'
|
||||
self.fields['siret'].label = 'SIRET'
|
||||
self.fields['adresse1'].label = 'Adresse (ligne 1)'
|
||||
|
@ -94,7 +99,8 @@ class EditMailMessageOptionForm(ModelForm):
|
|||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditMailMessageOptionForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditMailMessageOptionForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['welcome_mail_fr'].label = 'Message dans le mail de bienvenue en français'
|
||||
self.fields['welcome_mail_en'].label = 'Message dans le mail de bienvenue en anglais'
|
||||
|
||||
|
@ -103,5 +109,10 @@ class ServiceForm(ModelForm):
|
|||
model = Service
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(ServiceForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class DelServiceForm(Form):
|
||||
services = forms.ModelMultipleChoiceField(queryset=Service.objects.all(), label="Enregistrements service actuels", widget=forms.CheckboxSelectMultiple)
|
||||
|
||||
|
|
|
@ -31,12 +31,17 @@ class PortForm(ModelForm):
|
|||
model = Port
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(PortForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class EditPortForm(ModelForm):
|
||||
class Meta(PortForm.Meta):
|
||||
fields = ['room', 'related', 'machine_interface', 'radius', 'vlan_force', 'details']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditPortForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditPortForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['machine_interface'].queryset = Interface.objects.all().select_related('domain__extension')
|
||||
self.fields['related'].queryset = Port.objects.all().select_related('switch__switch_interface__domain__extension').order_by('switch', 'port')
|
||||
|
||||
|
@ -44,18 +49,27 @@ class AddPortForm(ModelForm):
|
|||
class Meta(PortForm.Meta):
|
||||
fields = ['port', 'room', 'machine_interface', 'related', 'radius', 'vlan_force', 'details']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(AddPortForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class StackForm(ModelForm):
|
||||
class Meta:
|
||||
model = Stack
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(StackForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class EditSwitchForm(ModelForm):
|
||||
class Meta:
|
||||
model = Switch
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditSwitchForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditSwitchForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['location'].label = 'Localisation'
|
||||
self.fields['number'].label = 'Nombre de ports'
|
||||
|
||||
|
@ -63,8 +77,16 @@ class NewSwitchForm(ModelForm):
|
|||
class Meta(EditSwitchForm.Meta):
|
||||
fields = ['location', 'number', 'details', 'stack', 'stack_member_id']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(NewSwitchForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class EditRoomForm(ModelForm):
|
||||
class Meta:
|
||||
model = Room
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditRoomForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
|
|
|
@ -54,6 +54,10 @@ class UserCreationForm(forms.ModelForm):
|
|||
password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput, validators=[MinLengthValidator(8)], max_length=255)
|
||||
is_admin = forms.BooleanField(label='is admin')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(UserCreationForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('pseudo', 'name', 'surname', 'email')
|
||||
|
@ -80,6 +84,10 @@ class ServiceUserCreationForm(forms.ModelForm):
|
|||
password1 = forms.CharField(label='Password', widget=forms.PasswordInput, min_length=8, max_length=255)
|
||||
password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput, min_length=8, max_length=255)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(ServiceUserCreationForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class Meta:
|
||||
model = ServiceUser
|
||||
fields = ('pseudo',)
|
||||
|
@ -112,7 +120,8 @@ class UserChangeForm(forms.ModelForm):
|
|||
fields = ('pseudo', 'password', 'name', 'surname', 'email')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(UserChangeForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(UserChangeForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
print("User is admin : %s" % kwargs['instance'].is_admin)
|
||||
self.initial['is_admin'] = kwargs['instance'].is_admin
|
||||
|
||||
|
@ -137,6 +146,10 @@ class ServiceUserChangeForm(forms.ModelForm):
|
|||
"""
|
||||
password = ReadOnlyPasswordHashField()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(ServiceUserChangeForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class Meta:
|
||||
model = ServiceUser
|
||||
fields = ('pseudo',)
|
||||
|
@ -163,7 +176,8 @@ class MassArchiveForm(forms.Form):
|
|||
|
||||
class BaseInfoForm(ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BaseInfoForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(BaseInfoForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['name'].label = 'Prénom'
|
||||
self.fields['surname'].label = 'Nom'
|
||||
self.fields['school'].label = 'Établissement'
|
||||
|
@ -226,6 +240,10 @@ class PasswordForm(ModelForm):
|
|||
model = User
|
||||
fields = ['password', 'pwd_ntlm']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(PasswordForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class ServiceUserForm(ModelForm):
|
||||
""" Modification d'un service user"""
|
||||
password = forms.CharField(label=u'Nouveau mot de passe', max_length=255, validators=[MinLengthValidator(8)], widget=forms.PasswordInput, required=False)
|
||||
|
@ -234,6 +252,10 @@ class ServiceUserForm(ModelForm):
|
|||
model = ServiceUser
|
||||
fields = ('pseudo','access_group')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(ServiceUserForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
class EditServiceUserForm(ServiceUserForm):
|
||||
class Meta(ServiceUserForm.Meta):
|
||||
fields = ['access_group','comment']
|
||||
|
@ -244,6 +266,10 @@ class StateForm(ModelForm):
|
|||
model = User
|
||||
fields = ['state']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(StateForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
|
||||
|
||||
class SchoolForm(ModelForm):
|
||||
class Meta:
|
||||
|
@ -251,7 +277,8 @@ class SchoolForm(ModelForm):
|
|||
fields = ['name']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SchoolForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(SchoolForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['name'].label = 'Établissement'
|
||||
|
||||
class ListRightForm(ModelForm):
|
||||
|
@ -260,7 +287,8 @@ class ListRightForm(ModelForm):
|
|||
fields = ['listright', 'details']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ListRightForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(ListRightForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['listright'].label = 'Nom du droit/groupe'
|
||||
|
||||
class NewListRightForm(ListRightForm):
|
||||
|
@ -279,7 +307,8 @@ class DelSchoolForm(Form):
|
|||
|
||||
class RightForm(ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RightForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(RightForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['right'].label = 'Droit'
|
||||
self.fields['right'].empty_label = "Choisir un nouveau droit"
|
||||
|
||||
|
@ -297,7 +326,8 @@ class DelRightForm(Form):
|
|||
|
||||
class BanForm(ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BanForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(BanForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['date_end'].label = 'Date de fin'
|
||||
|
||||
class Meta:
|
||||
|
@ -313,7 +343,8 @@ class BanForm(ModelForm):
|
|||
|
||||
class WhitelistForm(ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(WhitelistForm, self).__init__(*args, **kwargs)
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(WhitelistForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['date_end'].label = 'Date de fin'
|
||||
|
||||
class Meta:
|
||||
|
|
Loading…
Reference in a new issue