|
1
|
|
|
from django import forms |
|
2
|
|
|
|
|
3
|
|
|
# import autocomplete_light |
|
4
|
|
|
|
|
5
|
|
|
from .models import Organisation, User |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
class OrganisationForm(forms.ModelForm): |
|
9
|
|
|
|
|
10
|
|
|
def __init__(self, *args, **kwargs): |
|
11
|
|
|
super(OrganisationForm, self).__init__(*args, **kwargs) |
|
12
|
|
|
|
|
13
|
|
|
class Meta: |
|
14
|
|
|
model = Organisation |
|
15
|
|
|
exclude = ('user', 'created_at', 'modified_at', |
|
16
|
|
|
'active', 'created_by', 'modified_by') |
|
17
|
|
|
# widgets = { |
|
18
|
|
|
# 'name': autocomplete_light.TextWidget('OrganisationAutocomplete'), |
|
19
|
|
|
# } |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
class OrganisationMemberAddForm(forms.ModelForm): |
|
23
|
|
|
|
|
24
|
|
|
def __init__(self, *args, **kwargs): |
|
25
|
|
|
super(OrganisationMemberAddForm, self).__init__(*args, **kwargs) |
|
26
|
|
|
|
|
27
|
|
|
class Meta: |
|
28
|
|
|
model = Organisation |
|
29
|
|
|
exclude = ('user', 'created_at', 'modified_at', |
|
30
|
|
|
'name', 'organisation_type', 'description', |
|
31
|
|
|
'location', 'organisation_role', |
|
32
|
|
|
'active', 'created_by', 'modified_by') |
|
33
|
|
|
|
|
34
|
|
|
existing_user = forms.ModelChoiceField(queryset=User.objects.all(), required=False) |
|
35
|
|
|
new_user = forms.EmailField(label='Invite New User', required=False) |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
class UserRegistrationForm(forms.ModelForm): |
|
39
|
|
|
""" |
|
40
|
|
|
Form class for completing a user's registration and activating the |
|
41
|
|
|
User. |
|
42
|
|
|
|
|
43
|
|
|
The class operates on a user model which is assumed to have the required |
|
44
|
|
|
fields of a BaseUserModel |
|
45
|
|
|
""" |
|
46
|
|
|
first_name = forms.CharField(max_length=30) |
|
47
|
|
|
last_name = forms.CharField(max_length=30) |
|
48
|
|
|
password = forms.CharField(max_length=30, widget=forms.PasswordInput) |
|
49
|
|
|
password_confirm = forms.CharField(max_length=30, |
|
50
|
|
|
widget=forms.PasswordInput) |
|
51
|
|
|
|
|
52
|
|
|
def __init__(self, *args, **kwargs): |
|
53
|
|
|
super(UserRegistrationForm, self).__init__(*args, **kwargs) |
|
54
|
|
|
self.initial['username'] = '' |
|
55
|
|
|
|
|
56
|
|
|
class Meta: |
|
57
|
|
|
model = User |
|
58
|
|
|
exclude = ('is_staff', 'is_superuser', 'is_active', 'last_login', |
|
59
|
|
|
'date_joined', 'groups', 'user_permissions') |
|
60
|
|
|
|