Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippidb-web
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iPPIDB
ippidb-web
Commits
6f20d4cb
Commit
6f20d4cb
authored
6 years ago
by
Bryan BRANCOTTE
Browse files
Options
Downloads
Patches
Plain Diff
Comments
parent
1751bd25
No related branches found
No related tags found
1 merge request
!1
Wizard form
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ippisite/ippidb/templatetags/customtags.py
+11
-6
11 additions, 6 deletions
ippisite/ippidb/templatetags/customtags.py
with
11 additions
and
6 deletions
ippisite/ippidb/templatetags/customtags.py
+
11
−
6
View file @
6f20d4cb
...
...
@@ -20,16 +20,15 @@ def url_replace(request, field, value):
@register.filter
def
bootstrap
(
object
):
return
mark_safe
(
""
.
join
(
bootstrap_core
(
object
)))
return
mark_safe
(
""
.
join
(
bootstrap_core
(
object
)))
def
bootstrap_core
(
object
):
ret
=
[]
print
(
type
(
object
.
field
.
widget
))
if
isinstance
(
object
,
forms
.
BoundField
):
field
=
object
if
isinstance
(
field
.
field
.
widget
,
forms
.
HiddenInput
)
or
\
isinstance
(
field
.
field
.
widget
,
forms
.
SelectMultiple
):
print_label
=
True
if
isinstance
(
field
.
field
.
widget
,
forms
.
HiddenInput
):
ret
.
append
(
field
.
as_widget
())
if
field
.
errors
:
for
e
in
field
.
errors
:
...
...
@@ -81,7 +80,9 @@ def bootstrap_core(object):
ret
.
append
(
'
<div class=
"
%s
"
>
'
%
wrapping_classes
)
ret
.
append
(
field
.
as_widget
(
attrs
=
attrs
))
ret
.
append
(
"""
<label class=
"
%s
"
>%s</label>
"""
%
(
label_classes
,
field
.
label
))
if
print_label
:
# most of the use case want to print the label
ret
.
append
(
"""
<label class=
"
%s
"
>%s</label>
"""
%
(
label_classes
,
field
.
label
))
# If the field has a datalist attribut the input field will suggest from it, printing the element
if
datalist
:
...
...
@@ -99,18 +100,22 @@ def bootstrap_core(object):
ret
.
append
(
'
</div>
'
)
# return it as safe html code
elif
isinstance
(
object
,
forms
.
BaseFormSet
):
# print formset's error which are not related to a form the formset itself
formset
=
object
for
error
in
formset
.
non_form_errors
():
ret
.
append
(
"""
<div class=
"
alert alert-danger
"
>%s</div>
"""
%
error
.
replace
(
"
\n
"
,
"
<br/>
"
))
elif
isinstance
(
object
,
forms
.
BaseForm
):
# print form's error which are not related to a field but the form itself
form
=
object
for
field
in
form
:
for
l
in
bootstrap_core
(
field
):
ret
.
append
(
l
)
elif
isinstance
(
object
,
ErrorList
):
# print errors in a bootstrap way
for
error
in
object
:
ret
.
append
(
"""
<div class=
"
alert alert-danger
"
>%s</div>
"""
%
error
.
replace
(
"
\n
"
,
"
<br/>
"
))
elif
isinstance
(
object
,
Message
):
# print messages in a bootstrap way
message
=
object
level_tag
=
message
.
level_tag
if
level_tag
==
"
error
"
:
...
...
@@ -129,4 +134,4 @@ def bootstrap_core(object):
@register.filter
(
'
startswith
'
)
def
startswith
(
text
,
starts
):
return
text
.
startswith
(
starts
)
\ No newline at end of file
return
text
.
startswith
(
starts
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment