-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathforms.py
79 lines (72 loc) · 2.61 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
from datetime import date
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Column, Div, Layout
from django import forms
from django.contrib.auth.forms import UserCreationForm
from user.models import User
class LoginForm(forms.Form):
username = forms.CharField(
label="Username or Email Address",
widget=forms.TextInput(
attrs={"placeholder": "username", "class": "form-control"}
),
)
password = forms.CharField(
widget=forms.PasswordInput(
attrs={"placeholder": "password", "class": "form-control"}
)
)
class SignupForm(UserCreationForm):
class Meta:
model = User
fields = (
"username",
"email",
"password1",
"password2",
"first_name",
"middle_name",
"last_name",
"phone_number",
"gender",
"dob",
)
widgets = {
"password1": forms.PasswordInput(attrs={"class": "form-control"}),
"password2": forms.PasswordInput(attrs={"class": "form-control"}),
"dob": forms.widgets.DateInput(attrs={"type": "date", "max": date.today}),
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
HTML('<p class="h5 pb-3 text-primary text-center">Vital Information</h2>'),
Div(
Column("email", css_class="form-group col-md-6 mb-1"),
Column("username", css_class="form-group col-md-6 mb-1"),
css_class="row",
),
Div(
Column("password1", css_class="form-group col-md-6 mb-1"),
Column("password2", css_class="form-group col-md-6 mb-1"),
css_class="row",
),
HTML(
"""
<hr/>
<p class="h5 pb-3 text-primary text-center">Personal Information</h2>
"""
),
Div(
Column("first_name", css_class="form-group col-md-4 mb-1"),
Column("middle_name", css_class="form-group col-md-4 mb-1"),
Column("last_name", css_class="form-group col-md-4 mb-1"),
css_class="row",
),
Div(
Column("gender", css_class="form-group col-md-4 mb-1"),
Column("dob", css_class="form-group col-md-4 mb-1"),
Column("phone_number", css_class="form-group col-md-4 mb-1"),
css_class="row",
),
)