forked from abidibo/aidsbank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms.py
119 lines (99 loc) · 4.41 KB
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# coding=utf-8
from django import forms
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.admin.widgets import AdminDateWidget
from registration.forms import RegistrationForm
from registration.signals import user_registered
from aidsbank.models import Applicant, Loan, Asset, Movement, AssetComment
"""
Authentication form
"""
class UserAuthenticationForm(AuthenticationForm):
def __init__(self, *args, **kwargs):
super(UserAuthenticationForm, self).__init__(*args, **kwargs)
self.fields['username'].widget.attrs['class'] = 'form-control input-sm'
self.fields['password'].widget.attrs['class'] = 'form-control input-sm'
"""
New user registration form
"""
class UserRegistrationForm(RegistrationForm):
firstname = forms.CharField(label=u'Nome', max_length=64)
lastname = forms.CharField(label=u'Cognome', max_length=64)
address = forms.CharField(label=u'Indirizzo', max_length=128)
city = forms.CharField(label=u'Città', max_length=128)
cap = forms.CharField(label=u'CAP', max_length=5)
province = forms.CharField(label=u'Provincia', max_length=128)
phone = forms.CharField(label=u'Telefono', max_length=128)
privacy = forms.BooleanField(widget=forms.CheckboxInput(attrs={'class': 'required'}),
label=u'Informativa privacy',
error_messages={'required': "Devi accettare i termini e le condizioni d'uso per registrarti"},
help_text = u'Nullam convallis tellus quis massa hendrerit fringilla! Ut at mi id lectus feugiat ultricies pulvinar vel enim. Cras ut dolor et est cursus cursus. Fusce condimentum, ante non sollicitudin laoreet, est tortor consectetur nibh, quis ultricies enim arcu ut leo. Duis tincidunt purus et augue laoreet vel rutrum tellus sagittis. Suspendisse potenti. Integer vitae nisi tellus. ');
"""
Applicant profile form
"""
class ApplicantProfileForm(forms.ModelForm):
class Meta:
model = Applicant
exclude = ('user',)
"""
asset request, only submit buttons
"""
class AssetRequestForm(forms.Form):
pass
"""
Loan editing, manager
"""
class LoanEditManagerForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(LoanEditManagerForm, self).__init__(*args, **kwargs)
self.fields['loan_date'].widget.attrs['class'] = 'calendar'
class Meta:
model = Loan
fields = ['asset', 'applicant', 'reservation_date', 'status', 'addressee', 'place', 'deposit', 'loan_date', 'loan_duration', 'renewal_date', 'return_date', 'solicit_date', 'follow_up', 'notes', 'renewal_available']
widgets = {'asset': forms.HiddenInput(), 'applicant': forms.HiddenInput(), 'status': forms.HiddenInput(), 'reservation_date': forms.HiddenInput()}
"""
Asset creation, manager
"""
class AssetCreateManagerForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(AssetCreateManagerForm, self).__init__(*args, **kwargs)
self.fields['invoice_date'].widget.attrs['class'] = 'calendar'
class Meta:
model = Asset
"""
Asset edit, manager
"""
class AssetForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(AssetForm, self).__init__(*args, **kwargs)
self.fields['invoice_date'].widget.attrs['class'] = 'calendar'
class Meta:
model = Asset
"""
Movement creation, manager
"""
class MovementCreateManagerForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(MovementCreateManagerForm, self).__init__(*args, **kwargs)
self.fields['date'].widget.attrs['class'] = 'calendar'
class Meta:
model = Movement
fields = ['date', 'type', 'status', 'notes']
"""
Asset comment creation, manager
"""
class AssetCommentCreateManagerForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(AssetCommentCreateManagerForm, self).__init__(*args, **kwargs)
class Meta:
model = AssetComment
widgets = {'asset': forms.HiddenInput(), 'applicant': forms.HiddenInput(), 'published': forms.HiddenInput(), 'date': forms.HiddenInput()}
"""
Asset comment approval, manager
"""
class AssetCommentApproveManagerForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(AssetCommentApproveManagerForm, self).__init__(*args, **kwargs)
class Meta:
model = AssetComment
widgets = {'asset': forms.HiddenInput(), 'applicant': forms.HiddenInput(), 'published': forms.HiddenInput(), 'date': forms.HiddenInput(), 'text': forms.HiddenInput()}