Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Valentin Samir
django-cas-server
Commits
aa980960
Commit
aa980960
authored
Aug 02, 2016
by
Valentin Samir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use custom templatetags instead settings custom attributes to Boundfields
As it do not work with django 1.7
parent
15188ba1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
8 deletions
+19
-8
cas_server/forms.py
cas_server/forms.py
+2
-6
cas_server/templates/cas_server/form.html
cas_server/templates/cas_server/form.html
+3
-2
cas_server/templatetags/__init__.py
cas_server/templatetags/__init__.py
+0
-0
cas_server/templatetags/cas_server.py
cas_server/templatetags/cas_server.py
+14
-0
No files found.
cas_server/forms.py
View file @
aa980960
...
...
@@ -26,15 +26,11 @@ class BootsrapForm(forms.Form):
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
BootsrapForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
for
(
name
,
field
)
in
self
.
fields
.
item
s
():
for
field
in
self
.
fields
.
value
s
():
# Only tweak the fiel if it will be displayed
if
not
isinstance
(
field
.
widget
,
forms
.
HiddenInput
):
# tell to display the field (used in form.html)
self
[
name
].
display
=
True
attrs
=
{}
if
isinstance
(
field
.
widget
,
forms
.
CheckboxInput
):
self
[
name
].
checkbox
=
True
else
:
if
not
isinstance
(
field
.
widget
,
forms
.
CheckboxInput
):
attrs
[
'class'
]
=
"form-control"
if
field
.
label
:
# pragma: no branch (currently all field are hidden or labeled)
attrs
[
"placeholder"
]
=
field
.
label
...
...
cas_server/templates/cas_server/form.html
View file @
aa980960
{% load cas_server %}
{% for error in form.non_field_errors %}
<div
class=
"alert alert-danger alert-dismissable"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"alert"
aria-hidden=
"true"
>
×
</button>
{{error}}
</div>
{% endfor %}
{% for field in form %}{% if field
.display
%}
{% for field in form %}{% if
not
field
|is_hidden
%}
<div
class=
"form-group{% spaceless %}
{% if not form.non_field_errors %}
{% if field.errors %} has-error
...
...
@@ -12,7 +13,7 @@
{% endif %}
{% endif %}"
{%
endspaceless
%}
>
{% spaceless %}
{% if field
.
checkbox %}
{% if field
|is_
checkbox %}
<div
class=
"checkbox"
><label
for=
"{{field.auto_id}}"
>
{{field}}{{field.label}}
</label>
{% else %}
<label
class=
"control-label"
for=
"{{field.auto_id}}"
>
{{field.label}}
</label>
...
...
cas_server/templatetags/__init__.py
0 → 100644
View file @
aa980960
cas_server/templatetags/cas_server.py
0 → 100644
View file @
aa980960
from
django
import
template
from
django
import
forms
register
=
template
.
Library
()
@
register
.
filter
(
name
=
'is_checkbox'
)
def
is_checkbox
(
field
):
return
isinstance
(
field
.
field
.
widget
,
forms
.
CheckboxInput
)
@
register
.
filter
(
name
=
'is_hidden'
)
def
is_hidden
(
field
):
return
isinstance
(
field
.
field
.
widget
,
forms
.
HiddenInput
)
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