Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
264ea9c8
Commit
264ea9c8
authored
Oct 28, 2016
by
Daniel W Bond
Browse files
moved 'form-control' css classes to forms.py from views.py
parent
bdb750ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
roomlist/accounts/forms.py
View file @
264ea9c8
...
...
@@ -73,7 +73,9 @@ class BooleanRadioField(forms.TypedChoiceField):
class
StudentUpdateForm
(
forms
.
Form
):
first_name
=
forms
.
CharField
(
required
=
False
,
max_length
=
30
)
first_name
.
widget
.
attrs
[
'class'
]
=
'form-control'
last_name
=
forms
.
CharField
(
required
=
False
,
max_length
=
30
)
last_name
.
widget
.
attrs
[
'class'
]
=
'form-control'
gender
=
MultiSelectFormField
(
choices
=
Student
.
GENDER_CHOICES
,
required
=
False
)
show_gender
=
BooleanRadioField
(
required
=
True
)
...
...
@@ -82,12 +84,14 @@ class StudentUpdateForm(forms.Form):
room
=
SelectRoomField
(
queryset
=
Room
.
objects
.
all
(),
required
=
False
)
privacy
=
forms
.
TypedChoiceField
(
choices
=
Student
.
PRIVACY_CHOICES
)
privacy
.
widget
.
attrs
[
'class'
]
=
'form-control'
# exclude self from request in form instantiation
blocked_kids
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Student
.
objects
.
all
(),
required
=
False
)
major
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Major
.
objects
.
all
(),
required
=
False
)
graduating_year
=
forms
.
IntegerField
(
max_value
=
9999
,
min_value
=-
9999
,
required
=
False
)
graduating_year
.
widget
.
attrs
[
'class'
]
=
'form-control'
def
clean
(
self
):
cleaned_data
=
super
(
StudentUpdateForm
,
self
).
clean
()
...
...
roomlist/accounts/views.py
View file @
264ea9c8
...
...
@@ -218,14 +218,9 @@ class UpdateStudent(LoginRequiredMixin, FormValidMessageMixin, FormView):
else
:
form
.
fields
[
'room'
].
widget
.
user
=
self
.
request
.
user
# bootstrap
form
.
fields
[
'first_name'
].
widget
.
attrs
[
'class'
]
=
'form-control'
form
.
fields
[
'last_name'
].
widget
.
attrs
[
'class'
]
=
'form-control'
form
.
fields
[
'graduating_year'
].
widget
.
attrs
[
'class'
]
=
'form-control'
# chosen
form
.
fields
[
'major'
].
widget
.
attrs
[
'class'
]
=
'chosen-select'
form
.
fields
[
'blocked_kids'
].
widget
.
attrs
[
'class'
]
=
'blocked-select'
form
.
fields
[
'major'
].
widget
.
attrs
[
'class'
]
=
'
form-control
chosen-select'
form
.
fields
[
'blocked_kids'
].
widget
.
attrs
[
'class'
]
=
'
form-control
blocked-select'
context
[
'my_form'
]
=
form
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment