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
f6c1d17d
Commit
f6c1d17d
authored
6 years ago
by
Bryan BRANCOTTE
Browse files
Options
Downloads
Patches
Plain Diff
commenting source
parent
738607de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Wizard form
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ippisite/ippidb/templatetags/customtags.py
+12
-0
12 additions, 0 deletions
ippisite/ippidb/templatetags/customtags.py
with
12 additions
and
0 deletions
ippisite/ippidb/templatetags/customtags.py
+
12
−
0
View file @
f6c1d17d
...
...
@@ -21,12 +21,16 @@ def bootstrap(object):
if
isinstance
(
object
,
BoundField
):
field
=
object
attrs
=
field
.
field
.
widget
.
attrs
# get the class specified in the code
css_classes
=
set
(
attrs
.
get
(
"
class
"
,
""
).
split
(
"
"
))
# if the field has errors, we add bootstrap classes
if
field
.
errors
:
css_classes
.
add
(
"
is-invalid
"
)
# we propagate the "required" attribute
if
field
.
field
.
required
:
attrs
[
'
required
'
]
=
'
required
'
if
isinstance
(
field
.
field
.
widget
,
widgets
.
CheckboxInput
):
# if it is a checkbox, we the classes are not the same
wrapping_classes
=
"
form-check
"
label_classes
=
"
form-check-label
"
css_classes
.
add
(
"
form-check-input
"
)
...
...
@@ -35,21 +39,29 @@ def bootstrap(object):
# label_classes = "form-check-label"
# css_classes.add("form-check-input")
else
:
# usual classes
wrapping_classes
=
"
input_field form-group
"
label_classes
=
"
form-control-placeholder
"
css_classes
.
add
(
"
form-control
"
)
if
field
.
name
==
"
DELETE
"
:
# HACK : If the field is the DELETE button of the formset
attrs
[
"
onchange
"
]
=
"
formsetItemDelete(this);
"
wrapping_classes
+=
"
formset-item-delete-host
"
css_classes
.
add
(
"
formset-item-delete
"
)
# overwrite the css classes
attrs
[
"
class
"
]
=
"
"
.
join
(
css_classes
)
# render the field
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
field
.
errors
:
# render its errors
for
e
in
field
.
errors
:
ret
.
append
(
"""
<div class=
"
invalid-feedback
"
>%s</div>
"""
%
e
)
ret
.
append
(
'
</div>
'
)
# return it as safe html code
return
mark_safe
(
""
.
join
(
ret
))
else
:
logger
.
error
(
"
Can
'
t bootstrapize object of class %s
"
%
str
(
type
(
object
)))
...
...
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