summaryrefslogtreecommitdiff
path: root/horizon/templatetags
diff options
context:
space:
mode:
authorJiri Tomasek <jtomasek@redhat.com>2014-07-02 14:05:54 +0200
committerJiri Tomasek <jtomasek@redhat.com>2014-07-28 16:13:21 +0200
commit92146772b677e9fce57cc11b4a4a1542a05c23b2 (patch)
tree8458f99e3c3d68a537383587724908ee5b2fffe5 /horizon/templatetags
parentb04f020fc1dce27b47a174259ea3ba542127401b (diff)
downloadhorizon-92146772b677e9fce57cc11b4a4a1542a05c23b2.tar.gz
Update Twitter Bootstrap to version 3
Updated to bootstrap 3.2.0 back to v3.1.1 fix base-line-height variable Revamped grid system Replaced help-inline with help-block Change .control-group to .form-group Add column widths to horizontal form labels and .controls, remove .controls class Datepicker form fix Add btn-default to btn elements with no other color Topbar switcher fix Rename button sizes Replace alert-error with alert-danger Removed alert-block Alerts fixing Updated LinkAction and Action table actions to define icon, replaced btn-default icon with glyphicon Replaced icons with glyphicons, removed btn-icon styling from horizon.scss change Button Icons text in customizing docs Fixed table header Fix page_header h2 margin Nav accordion fix Tables fix Modal fixes added form-control class to input and selects Forms fixes Workflow modal fix Fix quota bar updated customizing docs removed unused styling from horizon.scss make datepicker form inline fix table filter styling added btn-danger to terminate instances button fixed loading spinner form fields and validations Created bootstrap_form_field filter and template to render bootstrap forms properly Style up the datepicker Fixed failing test cases Implements: blueprint bootstrap-update Change-Id: Ic826849be1af7fc6bf06f97dd7a60fc54b862148
Diffstat (limited to 'horizon/templatetags')
-rw-r--r--horizon/templatetags/bootstrap_form_field.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/horizon/templatetags/bootstrap_form_field.py b/horizon/templatetags/bootstrap_form_field.py
new file mode 100644
index 000000000..fec7fcce6
--- /dev/null
+++ b/horizon/templatetags/bootstrap_form_field.py
@@ -0,0 +1,47 @@
+from django import forms
+from django.template import Context
+from django.template.loader import get_template
+from django import template
+
+register = template.Library()
+
+@register.filter
+def bootstrap_form_field(element):
+ markup_classes = {'label': '', 'value': '', 'single_value': ''}
+ return render(element, markup_classes)
+
+
+def add_input_classes(field):
+ if not is_checkbox(field) and not is_multiple_checkbox(field) and not is_radio(field) \
+ and not is_file(field):
+ field_classes = field.field.widget.attrs.get('class', '')
+ field_classes += ' form-control'
+ field.field.widget.attrs['class'] = field_classes
+
+
+def render(element, markup_classes):
+ add_input_classes(element)
+ template = get_template("horizon/common/_bootstrap_form_field.html")
+ context = Context({'field': element, 'classes': markup_classes})
+
+ return template.render(context)
+
+
+@register.filter
+def is_checkbox(field):
+ return isinstance(field.field.widget, forms.CheckboxInput)
+
+
+@register.filter
+def is_multiple_checkbox(field):
+ return isinstance(field.field.widget, forms.CheckboxSelectMultiple)
+
+
+@register.filter
+def is_radio(field):
+ return isinstance(field.field.widget, forms.RadioSelect)
+
+
+@register.filter
+def is_file(field):
+ return isinstance(field.field.widget, forms.FileInput)