-
Notifications
You must be signed in to change notification settings - Fork 23
/
forms.py
91 lines (71 loc) · 2.96 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
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from .models import Profile, Interest, Message
from django.forms import ModelForm, FileInput
class CustomUserCreationForm(UserCreationForm):
class Meta:
model = User
fields = ['first_name', 'email', 'username',
'password1', 'password2']
labels = {
'first_name': 'Имя и фамилия',
'email': 'Email',
'username':'Логин',
'password1':'Пароль',
'password2': 'Подтверждение пароля'
}
def __init__(self, *args, **kwargs):
super(CustomUserCreationForm, self).__init__(*args, **kwargs)
for name, field in self.fields.items():
field.widget.attrs.update({'class': 'form-control input-box form-ensurance-header-control'})
class ProfileForm(ModelForm):
class Meta:
model = Profile
fields = ['name', 'email', 'username',
'summary', 'about', 'image',
'city', 'profession',
'github', 'linkedin', 'twitter',
'youtube']
labels = {
'name': 'Имя и фамилия',
'email': 'Email',
'username':'Логин',
'city': 'Город',
'profession': 'Профессия',
'summary': 'В двух словах о себе',
'about': 'Подробнее о себе',
'image': 'Изменить фото профиля',
}
widgets = {
'image': FileInput(),
}
def __init__(self, *args, **kwargs):
super(ProfileForm, self).__init__(*args, **kwargs)
for name, field in self.fields.items():
field.widget.attrs.update({'class': 'form-control input-box form-ensurance-header-control'})
class InterestForm(ModelForm):
class Meta:
model = Interest
fields = '__all__'
exclude = ['profile', 'slug']
labels = {
'name': 'Название',
'description':'Описание',
}
def __init__(self, *args, **kwargs):
super(InterestForm, self).__init__(*args, **kwargs)
for name, field in self.fields.items():
field.widget.attrs.update({'class': 'form-control input-box form-ensurance-header-control'})
class MessageForm(ModelForm):
class Meta:
model = Message
fields = ['name', 'email', 'subject', 'body']
labels = {'name': 'Имя и фамилия',
'email': 'Email',
'subject':'Тема сообщения',
'body':'Текст сообщения'
}
def __init__(self, *args, **kwargs):
super(MessageForm, self).__init__(*args, **kwargs)
for name, field in self.fields.items():
field.widget.attrs.update({'class': 'form-control input-box form-ensurance-header-control'})