Projet

Général

Profil

Télécharger (1,87 ko) Statistiques
| Branche: | Tag: | Révision:

mandayejs / mandayejs / mandaye / forms.py @ 7ab17a37

1
# mandayejs - saml reverse proxy
2
# Copyright (C) 2015  Entr'ouvert
3
#
4
# This program is free software: you can redistribute it and/or modify it
5
# under the terms of the GNU Affero General Public License as published
6
# by the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU Affero General Public License for more details.
13
#
14
# You should have received a copy of the GNU Affero General Public License
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
from __future__ import absolute_import
17

    
18
from django import forms
19
from django.conf import settings
20

    
21
from mandayejs.mandaye.models import UserCredentials
22

    
23
class FormFactory(forms.Form):
24
    def __init__(self, *args, **kwargs): 
25
        super(FormFactory, self).__init__(*args, **kwargs)
26
        fields = getattr(settings, 'SITE_LOCATORS', [])
27
        if fields : 
28
            for field in fields :
29
                if field['kind'] == 'string':
30
                    self.fields[field['name']] = forms.CharField(
31
                            label=field['label'], 
32
                            max_length=32, 
33
                            help_text=field['help']
34
                    )
35
                elif field['kind'] == 'password':
36
                    self.fields[field['name']] = forms.CharField(
37
                            label=field['label'], 
38
                            widget=forms.PasswordInput(), 
39
                            help_text=field['help']
40
                    )
41
                else:
42
                    self.fields[field['name']] = forms.DateField(
43
                            label=field['label'], 
44
                            help_text=field['help']
45
                    )
46

    
(3-3/6)