Project

General

Profile

Download (1018 Bytes) Statistics
| Branch: | Tag: | Revision:

root / uauth / organization / forms.py @ 64438aee

1 e8136392 Serghei Mihai
from django.utils.translation import ugettext as _
2
from django import forms
3
4
from .models import LocalAccount
5
6
7
class LocalAccountForm(forms.ModelForm):
8
9
    class Meta:
10
        exclude = ('organization', )
11
        model = LocalAccount
12
        widgets = {
13
            'expiration_date': forms.DateInput(attrs={'class': 'datepicker'}),
14
            'password': forms.PasswordInput
15
        }
16
17 7b499930 Serghei Mihai
    def save(self):
18
        # save previous password
19
        old_password = self.initial.get('password')
20
        obj = super(LocalAccountForm, self).save(commit=False)
21
        if not self.cleaned_data.get('password'):
22
            obj.password = old_password
23
        obj.save()
24
        return obj
25
26 e8136392 Serghei Mihai
27
class LocalAccountCreateForm(LocalAccountForm):
28
    accounts_number = forms.IntegerField(_('Number of accounts to create'), required=False)
29
    accounts_number_start = forms.IntegerField(_('First number of multiple accounts'), required=False)
30 64438aee Serghei Mihai
31
32
class UsersImportForm(forms.Form):
33
    users_file = forms.FileField(_('Users file'))