[Python-modules-commits] [python-django-crispy-forms] 01/06: Import python-django-crispy-forms_1.6.0.orig.tar.gz
Michael Fladischer
fladi at moszumanska.debian.org
Fri Jan 15 11:31:28 UTC 2016
This is an automated email from the git hooks/post-receive script.
fladi pushed a commit to branch master
in repository python-django-crispy-forms.
commit 8d1af358bbc8ff4c43719425776ce42abba63cde
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date: Fri Jan 15 11:54:19 2016 +0100
Import python-django-crispy-forms_1.6.0.orig.tar.gz
---
.gitignore | 5 +
.travis.yml | 21 ++--
CHANGELOG.md | 8 ++
crispy_forms/__init__.py | 2 +-
crispy_forms/bootstrap.py | 45 ++++----
crispy_forms/compatibility.py | 14 +--
crispy_forms/helper.py | 17 ++-
crispy_forms/layout.py | 21 ++--
crispy_forms/templates/bootstrap/display_form.html | 2 +-
crispy_forms/templates/bootstrap/uni_form.html | 2 +-
.../templates/bootstrap3/display_form.html | 2 +-
.../templates/bootstrap3/layout/buttonholder.html | 4 +
crispy_forms/templates/bootstrap3/uni_form.html | 2 +-
.../templates/bootstrap4/accordion-group.html | 12 ++
crispy_forms/templates/bootstrap4/accordion.html | 3 +
crispy_forms/templates/bootstrap4/betterform.html | 22 ++++
.../templates/bootstrap4/display_form.html | 9 ++
crispy_forms/templates/bootstrap4/errors.html | 8 ++
.../templates/bootstrap4/errors_formset.html | 9 ++
crispy_forms/templates/bootstrap4/field.html | 48 ++++++++
crispy_forms/templates/bootstrap4/inputs.html | 13 +++
.../templates/bootstrap4/layout/alert.html | 4 +
.../templates/bootstrap4/layout/baseinput.html | 9 ++
.../templates/bootstrap4/layout/button.html | 1 +
.../templates/bootstrap4/layout/buttonholder.html | 4 +
.../bootstrap4/layout/checkboxselectmultiple.html | 18 +++
.../layout/checkboxselectmultiple_inline.html | 14 +++
crispy_forms/templates/bootstrap4/layout/div.html | 4 +
.../templates/bootstrap4/layout/field_errors.html | 5 +
.../bootstrap4/layout/field_errors_block.html | 5 +
.../bootstrap4/layout/field_with_buttons.html | 17 +++
.../templates/bootstrap4/layout/fieldset.html | 6 +
.../templates/bootstrap4/layout/formactions.html | 9 ++
.../templates/bootstrap4/layout/help_text.html | 7 ++
.../bootstrap4/layout/help_text_and_errors.html | 13 +++
.../templates/bootstrap4/layout/inline_field.html | 21 ++++
.../templates/bootstrap4/layout/multifield.html | 27 +++++
.../bootstrap4/layout/prepended_appended_text.html | 30 +++++
.../templates/bootstrap4/layout/radioselect.html | 17 +++
.../bootstrap4/layout/radioselect_inline.html | 14 +++
.../templates/bootstrap4/layout/tab-link.html | 1 +
crispy_forms/templates/bootstrap4/layout/tab.html | 6 +
.../bootstrap4/layout/uneditable_input.html | 10 ++
.../templates/bootstrap4/table_inline_formset.html | 51 +++++++++
.../{bootstrap3 => bootstrap4}/uni_form.html | 6 +-
crispy_forms/templates/bootstrap4/uni_formset.html | 8 ++
.../templates/bootstrap4/whole_uni_form.html | 14 +++
.../templates/bootstrap4/whole_uni_formset.html | 30 +++++
crispy_forms/templates/uni_form/display_form.html | 2 +-
crispy_forms/templates/uni_form/uni_form.html | 2 +-
crispy_forms/templatetags/crispy_forms_field.py | 6 +-
crispy_forms/templatetags/crispy_forms_filters.py | 15 ++-
crispy_forms/templatetags/crispy_forms_tags.py | 7 +-
crispy_forms/tests/conftest.py | 6 +-
crispy_forms/tests/forms.py | 6 +
crispy_forms/tests/test_form_helper.py | 122 +++++++++++++++++++--
crispy_forms/tests/test_layout.py | 97 ++++++++--------
crispy_forms/tests/test_layout_objects.py | 33 +++++-
crispy_forms/tests/test_settings.py | 22 ++++
crispy_forms/tests/test_tags.py | 74 ++++++++++++-
crispy_forms/tests/test_utils.py | 39 +++++++
crispy_forms/tests/urls.py | 7 +-
crispy_forms/utils.py | 44 ++++++++
docs/crispy_tag_forms.rst | 11 +-
docs/form_helper.rst | 3 +
docs/install.rst | 4 +-
requirements.txt | 3 +-
tox.ini | 7 +-
68 files changed, 976 insertions(+), 154 deletions(-)
diff --git a/.gitignore b/.gitignore
index 64ad0a6..5b225c0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,8 @@ _build
# OSX
*.DS_Store
+
+# editors
+.project
+.pydevproject
+.settings/
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 754e1ed..b784294 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,15 +3,14 @@ language: python
sudo: false
python:
- - "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
+ - "3.5"
env:
- - DJANGO='django>=1.4.0,<1.5.0'
- - DJANGO='django>=1.7.0,<1.8.0'
- DJANGO='django>=1.8.0,<1.9.0'
+ - DJANGO='django>=1.9.0,<1.10.0'
- DJANGO='https://github.com/django/django/archive/master.tar.gz'
install:
- pip install $DJANGO
@@ -23,21 +22,17 @@ notifications:
matrix:
exclude:
- python: "3.2"
- env: DJANGO='django>=1.4.0,<1.5.0'
- - python: "3.2"
env: DJANGO='https://github.com/django/django/archive/master.tar.gz'
- - python: "3.3"
- env: DJANGO='django>=1.4.0,<1.5.0'
+ - python: "3.2"
+ env: DJANGO='django>=1.9.0,<1.10.0'
- python: "3.3"
env: DJANGO='https://github.com/django/django/archive/master.tar.gz'
+ - python: "3.3"
+ env: DJANGO='django>=1.9.0,<1.10.0'
- python: "3.4"
- env: DJANGO='django>=1.4.0,<1.5.0'
- - python: "2.6"
- env: DJANGO='django>=1.7.0,<1.8.0'
- - python: "2.6"
- env: DJANGO='django>=1.8.0,<1.9.0'
- - python: "2.6"
env: DJANGO='https://github.com/django/django/archive/master.tar.gz'
+ - python: "3.5"
+ env: DJANGO='django>=1.7.0,<1.8.0'
allow_failures:
- env: DJANGO='https://github.com/django/django/archive/master.tar.gz'
after_success:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f407784..f73e59f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# CHANGELOG for django-crispy-forms
+## 1.6.0 (2016/1/7)
+
+ * Fixed compatibility with Django 1.9
+ * Added Bootstrap 4 template pack
+ * Other small fixes.
+
+See [1.6.0 Milestone](https://github.com/maraujop/django-crispy-forms/issues?q=milestone%3A1.6.0+is%3Aclosed) for full issue list.
+
## 1.5.2 (2015/9/10)
* Fix: KeyError: u'wrapper_class' when clearing template context. #511, #512
diff --git a/crispy_forms/__init__.py b/crispy_forms/__init__.py
index 4ffded2..1fa0596 100644
--- a/crispy_forms/__init__.py
+++ b/crispy_forms/__init__.py
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
-__version__ = '1.5.2'
+__version__ = '1.6.0'
diff --git a/crispy_forms/bootstrap.py b/crispy_forms/bootstrap.py
index a9c9bbd..bff16cf 100644
--- a/crispy_forms/bootstrap.py
+++ b/crispy_forms/bootstrap.py
@@ -36,7 +36,7 @@ class PrependedAppendedText(Field):
'input_size': self.input_size,
'active': getattr(self, "active", False)
}
- template = self.template % template_pack
+ template = self.get_template_name(template_pack)
return render_field(
self.field, form, form_style, context,
template=template, attrs=self.attrs,
@@ -82,12 +82,13 @@ class FormActions(LayoutObject):
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, **kwargs):
html = self.get_rendered_fields(form, form_style, context, template_pack, **kwargs)
- extra_context = {
+ template = self.get_template_name(template_pack)
+ context.update({
'formactions': self,
'fields_output': html
- }
- template = self.template % template_pack
- return render_to_string(template, extra_context, context)
+ })
+
+ return render_to_string(template, context.flatten())
def flat_attrs(self):
return flatatt(self.attrs)
@@ -139,7 +140,7 @@ class FieldWithButtons(Div):
)
extra_context = {'div': self, 'buttons': buttons}
- template = self.template % template_pack
+ template = self.get_template_name(template_pack)
if isinstance(self.fields[0], Field):
# FieldWithButtons(Field('field_name'), StrictButton("go"))
@@ -183,7 +184,9 @@ class StrictButton(object):
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, **kwargs):
self.content = Template(text_type(self.content)).render(context)
template = self.template % template_pack
- return render_to_string(template, {'button': self}, context)
+ context.update({'button': self})
+
+ return render_to_string(template, context.flatten())
class Container(Div):
@@ -287,13 +290,13 @@ class TabHolder(ContainerHolder):
content = self.get_rendered_fields(form, form_style, context, template_pack)
links = ''.join(tab.render_link(template_pack) for tab in self.fields)
- extra_context = {
+ context.update({
'tabs': self,
'links': links,
'content': content
- }
- template = self.template % template_pack
- return render_to_string(template, extra_context, context)
+ })
+ template = self.get_template_name(template_pack)
+ return render_to_string(template, context.flatten())
class AccordionGroup(Container):
@@ -335,12 +338,10 @@ class Accordion(ContainerHolder):
group, form, form_style, context, template_pack=template_pack, **kwargs
)
- template = self.template % template_pack
- return render_to_string(
- template,
- {'accordion': self, 'content': content},
- context
- )
+ template = self.get_template_name(template_pack)
+ context.update({'accordion': self, 'content': content})
+
+ return render_to_string(template, context.flatten())
class Alert(Div):
@@ -362,12 +363,10 @@ class Alert(Div):
self.dismiss = dismiss
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, **kwargs):
- template = self.template % template_pack
- return render_to_string(
- template,
- {'alert': self, 'content': self.content, 'dismiss': self.dismiss},
- context
- )
+ template = self.get_template_name(template_pack)
+ context.update({'alert': self, 'content': self.content, 'dismiss': self.dismiss})
+
+ return render_to_string(template, context.flatten())
class UneditableField(Field):
diff --git a/crispy_forms/compatibility.py b/crispy_forms/compatibility.py
index 6a5cc3d..bf2803a 100644
--- a/crispy_forms/compatibility.py
+++ b/crispy_forms/compatibility.py
@@ -1,18 +1,6 @@
import sys
-import django
-
-if (1, 4) <= django.VERSION <= (1, 5):
- from django.utils.functional import SimpleLazyObject as DefaultSimpleLazyObject
-
- class SimpleLazyObject(DefaultSimpleLazyObject):
-
- def __contains__(self, item):
- if self._wrapped is None:
- self._setup()
- return self._wrapped.__contains__(item)
-else:
- from django.utils.functional import SimpleLazyObject
+from django.utils.functional import SimpleLazyObject
try:
basestring
diff --git a/crispy_forms/helper.py b/crispy_forms/helper.py
index c4bb468..0ae1263 100644
--- a/crispy_forms/helper.py
+++ b/crispy_forms/helper.py
@@ -7,7 +7,7 @@ from django.utils.safestring import mark_safe
from crispy_forms.compatibility import string_types
from crispy_forms.layout import Layout
from crispy_forms.layout_slice import LayoutSlice
-from crispy_forms.utils import render_field, flatatt, TEMPLATE_PACK
+from crispy_forms.utils import render_field, flatatt, TEMPLATE_PACK, list_intersection, list_difference
from crispy_forms.exceptions import FormHelpersException
@@ -148,6 +148,9 @@ class FormHelper(DynamicLayoutHandler):
**form_style**: Uni-form has two built in different form styles. You can choose
your favorite. This can be set to "default" or "inline". Defaults to "default".
+ **include_media**: Whether to automatically include form media. Set to False if
+ you want to manually include form media outside the form. Defaults to True.
+
Public Methods:
**add_input(input)**: You can add input buttons using this method. Inputs
@@ -203,6 +206,7 @@ class FormHelper(DynamicLayoutHandler):
disable_csrf = False
label_class = ''
field_class = ''
+ include_media = True
def __init__(self, form=None):
self.attrs = {}
@@ -315,11 +319,11 @@ class FormHelper(DynamicLayoutHandler):
# we suppose they need to be rendered
if hasattr(form, 'Meta'):
if hasattr(form.Meta, 'fields'):
- current_fields = set(getattr(form, 'fields', []))
- meta_fields = set(getattr(form.Meta, 'fields'))
+ current_fields = tuple(getattr(form, 'fields', {}).keys())
+ meta_fields = getattr(form.Meta, 'fields')
- fields_to_render = current_fields & meta_fields
- left_fields_to_render = fields_to_render - form.rendered_fields
+ fields_to_render = list_intersection(current_fields, meta_fields)
+ left_fields_to_render = list_difference(fields_to_render, form.rendered_fields)
for field in left_fields_to_render:
html += render_field(field, form, self.form_style, context)
@@ -341,7 +345,8 @@ class FormHelper(DynamicLayoutHandler):
'form_show_labels': self.form_show_labels,
'disable_csrf': self.disable_csrf,
'label_class': self.label_class,
- 'field_class': self.field_class
+ 'field_class': self.field_class,
+ 'include_media': self.include_media
}
# col-[lg|md|sm|xs]-<number>
label_size_match = re.search('(\d+)', self.label_class)
diff --git a/crispy_forms/layout.py b/crispy_forms/layout.py
index 4324aaf..57673dc 100644
--- a/crispy_forms/layout.py
+++ b/crispy_forms/layout.py
@@ -164,11 +164,9 @@ class ButtonHolder(LayoutObject):
html = self.get_rendered_fields(form, form_style, context, template_pack, **kwargs)
template = self.get_template_name(template_pack)
- return render_to_string(
- template,
- {'buttonholder': self, 'fields_output': html},
- context
- )
+ context.update({'buttonholder': self, 'fields_output': html})
+
+ return render_to_string(template, context.flatten())
class BaseInput(TemplateNameMixin):
@@ -196,7 +194,9 @@ class BaseInput(TemplateNameMixin):
"""
self.value = Template(text_type(self.value)).render(context)
template = self.get_template_name(template_pack)
- return render_to_string(template, {'input': self}, context)
+ context.update({'input': self})
+
+ return render_to_string(template, context.flatten())
class Submit(BaseInput):
@@ -323,12 +323,13 @@ class MultiField(LayoutObject):
labelclass=self.label_class, layout_object=self, **kwargs
)
- extra_context = {
+ template = self.get_template_name(template_pack)
+ context.update({
'multifield': self,
'fields_output': fields_output
- }
- template = self.get_template_name(template_pack)
- return render_to_string(template, extra_context, context)
+ })
+
+ return render_to_string(template, context.flatten())
class Div(LayoutObject):
diff --git a/crispy_forms/templates/bootstrap/display_form.html b/crispy_forms/templates/bootstrap/display_form.html
index 5b383a0..62aa466 100644
--- a/crispy_forms/templates/bootstrap/display_form.html
+++ b/crispy_forms/templates/bootstrap/display_form.html
@@ -1,5 +1,5 @@
{% if form.form_html %}
- {{ form.media }}
+ {% if include_media %}{{ form.media }}{% endif %}
{% if form_show_errors %}
{% include "bootstrap/errors.html" %}
{% endif %}
diff --git a/crispy_forms/templates/bootstrap/uni_form.html b/crispy_forms/templates/bootstrap/uni_form.html
index 08c62ec..550821d 100644
--- a/crispy_forms/templates/bootstrap/uni_form.html
+++ b/crispy_forms/templates/bootstrap/uni_form.html
@@ -1,7 +1,7 @@
{% load crispy_forms_utils %}
{% specialspaceless %}
- {{ form.media }}
+ {% if include_media %}{{ form.media }}{% endif %}
{% if form_show_errors %}
{% include "bootstrap/errors.html" %}
{% endif %}
diff --git a/crispy_forms/templates/bootstrap3/display_form.html b/crispy_forms/templates/bootstrap3/display_form.html
index a5c8505..1bbfaff 100644
--- a/crispy_forms/templates/bootstrap3/display_form.html
+++ b/crispy_forms/templates/bootstrap3/display_form.html
@@ -1,5 +1,5 @@
{% if form.form_html %}
- {{ form.media }}
+ {% if include_media %}{{ form.media }}{% endif %}
{% if form_show_errors %}
{% include "bootstrap3/errors.html" %}
{% endif %}
diff --git a/crispy_forms/templates/bootstrap3/layout/buttonholder.html b/crispy_forms/templates/bootstrap3/layout/buttonholder.html
new file mode 100644
index 0000000..23a3945
--- /dev/null
+++ b/crispy_forms/templates/bootstrap3/layout/buttonholder.html
@@ -0,0 +1,4 @@
+<div {% if buttonholder.css_id %}id="{{ buttonholder.css_id }}"{% endif %}
+ class="buttonHolder{% if buttonholder.css_class %} {{ buttonholder.css_class }}{% endif %}">
+ {{ fields_output|safe }}
+</div>
diff --git a/crispy_forms/templates/bootstrap3/uni_form.html b/crispy_forms/templates/bootstrap3/uni_form.html
index ca8fa1f..a5575ea 100644
--- a/crispy_forms/templates/bootstrap3/uni_form.html
+++ b/crispy_forms/templates/bootstrap3/uni_form.html
@@ -1,7 +1,7 @@
{% load crispy_forms_utils %}
{% specialspaceless %}
- {{ form.media }}
+ {% if include_media %}{{ form.media }}{% endif %}
{% if form_show_errors %}
{% include "bootstrap3/errors.html" %}
{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/accordion-group.html b/crispy_forms/templates/bootstrap4/accordion-group.html
new file mode 100644
index 0000000..5d39b8e
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/accordion-group.html
@@ -0,0 +1,12 @@
+<div class="panel panel-default">
+ <div class="panel-heading">
+ <h4 class="panel-title">
+ <a class="accordion-toggle" data-toggle="collapse" data-parent="#{{ div.data_parent }}" href="#{{ div.css_id }}">{{ div.name }}</a>
+ </h4>
+ </div>
+ <div id="{{ div.css_id }}" class="panel-collapse collapse{% if div.active %} in{% endif %}" >
+ <div class="panel-body">
+ {{ fields|safe }}
+ </div>
+ </div>
+</div>
diff --git a/crispy_forms/templates/bootstrap4/accordion.html b/crispy_forms/templates/bootstrap4/accordion.html
new file mode 100644
index 0000000..295bf41
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/accordion.html
@@ -0,0 +1,3 @@
+<div class="panel-group" id="{{ accordion.css_id }}">
+ {{ content|safe }}
+</div>
diff --git a/crispy_forms/templates/bootstrap4/betterform.html b/crispy_forms/templates/bootstrap4/betterform.html
new file mode 100644
index 0000000..847520e
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/betterform.html
@@ -0,0 +1,22 @@
+{% for fieldset in form.fieldsets %}
+ <fieldset class="fieldset-{{ forloop.counter }} {{ fieldset.classes }}">
+ {% if fieldset.legend %}
+ <legend>{{ fieldset.legend }}</legend>
+ {% endif %}
+
+ {% if fieldset.description %}
+ <p class="description">{{ fieldset.description }}</p>
+ {% endif %}
+
+ {% for field in fieldset %}
+ {% if field.is_hidden %}
+ {{ field }}
+ {% else %}
+ {% include "bootstrap4/field.html" %}
+ {% endif %}
+ {% endfor %}
+ {% if not forloop.last or not fieldset_open %}
+ </fieldset>
+ {% endif %}
+{% endfor %}
+
diff --git a/crispy_forms/templates/bootstrap4/display_form.html b/crispy_forms/templates/bootstrap4/display_form.html
new file mode 100644
index 0000000..7655644
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/display_form.html
@@ -0,0 +1,9 @@
+{% if form.form_html %}
+ {% if include_media %}{{ form.media }}{% endif %}
+ {% if form_show_errors %}
+ {% include "bootstrap4/errors.html" %}
+ {% endif %}
+ {{ form.form_html }}
+{% else %}
+ {% include "bootstrap4/uni_form.html" %}
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/errors.html b/crispy_forms/templates/bootstrap4/errors.html
new file mode 100644
index 0000000..14fd41b
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/errors.html
@@ -0,0 +1,8 @@
+{% if form.non_field_errors %}
+ <div class="alert alert-block alert-danger">
+ {% if form_error_title %}<h4 class="alert-heading">{{ form_error_title }}</h4>{% endif %}
+ <ul>
+ {{ form.non_field_errors|unordered_list }}
+ </ul>
+ </div>
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/errors_formset.html b/crispy_forms/templates/bootstrap4/errors_formset.html
new file mode 100644
index 0000000..900a871
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/errors_formset.html
@@ -0,0 +1,9 @@
+{% if formset.non_form_errors %}
+ <div class="alert alert-block alert-danger">
+ {% if formset_error_title %}<h4 class="alert-heading">{{ formset_error_title }}</h4>{% endif %}
+ <ul>
+ {{ formset.non_form_errors|unordered_list }}
+ </ul>
+ </div>
+{% endif %}
+
diff --git a/crispy_forms/templates/bootstrap4/field.html b/crispy_forms/templates/bootstrap4/field.html
new file mode 100644
index 0000000..64a6593
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/field.html
@@ -0,0 +1,48 @@
+{% load crispy_forms_field %}
+
+{% if field.is_hidden %}
+ {{ field }}
+{% else %}
+ {% if field|is_checkbox %}
+ <div class="form-group row">
+ {% if label_class %}
+ <div class="controls col-{{ bootstrap_device_type }}-offset-{{ label_size }} {{ field_class }}">
+ {% endif %}
+ {% endif %}
+ <{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" {% if not field|is_checkbox %}class="form-group row{% else %}class="checkbox{% endif %}{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors%}{% if field.errors %} has-error{% endif %}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
+ {% if field.label and not field|is_checkbox and form_show_labels %}
+ <label for="{{ field.id_for_label }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
+ {{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
+ </label>
+ {% endif %}
+
+ {% if field|is_checkboxselectmultiple %}
+ {% include 'bootstrap4/layout/checkboxselectmultiple.html' %}
+ {% endif %}
+
+ {% if field|is_radioselect %}
+ {% include 'bootstrap4/layout/radioselect.html' %}
+ {% endif %}
+
+ {% if not field|is_checkboxselectmultiple and not field|is_radioselect %}
+ {% if field|is_checkbox and form_show_labels %}
+ <label for="{{ field.id_for_label }}" class="{% if field.field.required %} requiredField{% endif %}">
+ {% crispy_field field %}
+ {{ field.label|safe }}
+ {% include 'bootstrap4/layout/help_text_and_errors.html' %}
+ </label>
+ {% else %}
+ <div class="controls {{ field_class }}">
+ {% crispy_field field %}
+ {% include 'bootstrap4/layout/help_text_and_errors.html' %}
+ </div>
+ {% endif %}
+ {% endif %}
+ </{% if tag %}{{ tag }}{% else %}div{% endif %}>
+ {% if field|is_checkbox %}
+ {% if label_class %}
+ </div>
+ {% endif %}
+ </div>
+ {% endif %}
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/inputs.html b/crispy_forms/templates/bootstrap4/inputs.html
new file mode 100644
index 0000000..8900704
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/inputs.html
@@ -0,0 +1,13 @@
+{% if inputs %}
+ <div class="form-group row">
+ {% if label_class %}
+ <div class="aab controls {{ label_class }}"></div>
+ {% endif %}
+
+ <div class="controls {{ field_class }}">
+ {% for input in inputs %}
+ {% include "bootstrap4/layout/baseinput.html" %}
+ {% endfor %}
+ </div>
+ </div>
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/layout/alert.html b/crispy_forms/templates/bootstrap4/layout/alert.html
new file mode 100644
index 0000000..904c111
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/alert.html
@@ -0,0 +1,4 @@
+<div{% if alert.css_id %} id="{{ alert.css_id }}"{% endif %}{% if alert.css_class %} class="{{ alert.css_class }}"{% endif %}>
+ {% if dismiss %}<button type="button" class="close" data-dismiss="alert">×</button>{% endif %}
+ {{ content|safe }}
+</div>
\ No newline at end of file
diff --git a/crispy_forms/templates/bootstrap4/layout/baseinput.html b/crispy_forms/templates/bootstrap4/layout/baseinput.html
new file mode 100644
index 0000000..aa3f2fe
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/baseinput.html
@@ -0,0 +1,9 @@
+<input type="{{ input.input_type }}"
+ name="{% if input.name|wordcount > 1 %}{{ input.name|slugify }}{% else %}{{ input.name }}{% endif %}"
+ value="{{ input.value }}"
+ {% if input.input_type != "hidden" %}
+ class="{{ input.field_classes }}"
+ id="{% if input.id %}{{ input.id }}{% else %}{{ input.input_type }}-id-{{ input.name|slugify }}{% endif %}"
+ {% endif %}
+ {{ input.flat_attrs|safe }}
+ />
diff --git a/crispy_forms/templates/bootstrap4/layout/button.html b/crispy_forms/templates/bootstrap4/layout/button.html
new file mode 100644
index 0000000..013492e
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/button.html
@@ -0,0 +1 @@
+<button {{ button.flat_attrs|safe }}>{{ button.content|safe }}</button>
diff --git a/crispy_forms/templates/bootstrap4/layout/buttonholder.html b/crispy_forms/templates/bootstrap4/layout/buttonholder.html
new file mode 100644
index 0000000..23a3945
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/buttonholder.html
@@ -0,0 +1,4 @@
+<div {% if buttonholder.css_id %}id="{{ buttonholder.css_id }}"{% endif %}
+ class="buttonHolder{% if buttonholder.css_class %} {{ buttonholder.css_class }}{% endif %}">
+ {{ fields_output|safe }}
+</div>
diff --git a/crispy_forms/templates/bootstrap4/layout/checkboxselectmultiple.html b/crispy_forms/templates/bootstrap4/layout/checkboxselectmultiple.html
new file mode 100644
index 0000000..557cef9
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/checkboxselectmultiple.html
@@ -0,0 +1,18 @@
+{% load crispy_forms_filters %}
+{% load l10n %}
+
+<div class="controls {{ field_class }}"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>
+ {% include 'bootstrap4/layout/field_errors_block.html' %}
+
+ {% for choice in field.field.choices %}
+
+ {% if not inline_class %}<div class="checkbox">{% endif %}
+ <label class="{% if inline_class %}checkbox-{{ inline_class }}{% endif %}">
+ <input type="checkbox"{% if choice.0 in field.value or choice.0|stringformat:"s" in field.value or choice.0|stringformat:"s" == field.value|stringformat:"s" %} checked="checked"{% endif %} name="{{ field.html_name }}" id="id_{{ field.html_name }}_{{ forloop.counter }}" value="{{ choice.0|unlocalize }}" {{ field.field.widget.attrs|flatatt }}>
+ {{ choice.1|unlocalize }}
+ </label>
+ {% if not inline_class %}</div>{% endif %}
+ {% endfor %}
+
+ {% include 'bootstrap4/layout/help_text.html' %}
+</div>
diff --git a/crispy_forms/templates/bootstrap4/layout/checkboxselectmultiple_inline.html b/crispy_forms/templates/bootstrap4/layout/checkboxselectmultiple_inline.html
new file mode 100644
index 0000000..d9a44e6
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/checkboxselectmultiple_inline.html
@@ -0,0 +1,14 @@
+{% if field.is_hidden %}
+ {{ field }}
+{% else %}
+ <div id="div_{{ field.auto_id }}" class="form-group row{% if form_show_errors and field.errors %} has-error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
+
+ {% if field.label %}
+ <label for="{{ field.auto_id }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
+ {{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
+ </label>
+ {% endif %}
+
+ {% include 'bootstrap4/layout/checkboxselectmultiple.html' %}
+ </div>
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/layout/div.html b/crispy_forms/templates/bootstrap4/layout/div.html
new file mode 100644
index 0000000..1e72f16
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/div.html
@@ -0,0 +1,4 @@
+<div {% if div.css_id %}id="{{ div.css_id }}"{% endif %}
+ {% if div.css_class %}class="{{ div.css_class }}"{% endif %} {{ div.flat_attrs|safe }}>
+ {{ fields|safe }}
+</div>
diff --git a/crispy_forms/templates/bootstrap4/layout/field_errors.html b/crispy_forms/templates/bootstrap4/layout/field_errors.html
new file mode 100644
index 0000000..b49cdc3
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/field_errors.html
@@ -0,0 +1,5 @@
+{% if form_show_errors and field.errors %}
+ {% for error in field.errors %}
+ <span id="error_{{ forloop.counter }}_{{ field.auto_id }}" class="help-block"><strong>{{ error }}</strong></span>
+ {% endfor %}
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/layout/field_errors_block.html b/crispy_forms/templates/bootstrap4/layout/field_errors_block.html
new file mode 100644
index 0000000..fb02dee
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/field_errors_block.html
@@ -0,0 +1,5 @@
+{% if form_show_errors and field.errors %}
+ {% for error in field.errors %}
+ <p id="error_{{ forloop.counter }}_{{ field.auto_id }}" class="help-block"><strong>{{ error }}</strong></p>
+ {% endfor %}
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/layout/field_with_buttons.html b/crispy_forms/templates/bootstrap4/layout/field_with_buttons.html
new file mode 100644
index 0000000..494e411
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/field_with_buttons.html
@@ -0,0 +1,17 @@
+{% load crispy_forms_field %}
+
+<div{% if div.css_id %} id="{{ div.css_id }}"{% endif %} class="form-group row{% if form_show_errors and field.errors %} has-error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}{% if div.css_class %} {{ div.css_class }}{% endif %}" {{ div.flat_attrs|safe }}>
+ {% if field.label and form_show_labels %}
+ <label for="{{ field.id_for_label }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
+ {{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
+ </label>
+ {% endif %}
+
+ <div class="controls {{ field_class }}">
+ <div class="input-group">
+ {% crispy_field field %}
+ <span class="input-group-btn{% if active %} active{% endif %}{% if input_size %} {{ input_size }}{% endif %}">{{ buttons|safe }}</span>
+ </div>
+ {% include 'bootstrap4/layout/help_text_and_errors.html' %}
+ </div>
+</div>
diff --git a/crispy_forms/templates/bootstrap4/layout/fieldset.html b/crispy_forms/templates/bootstrap4/layout/fieldset.html
new file mode 100644
index 0000000..81ed29b
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/fieldset.html
@@ -0,0 +1,6 @@
+<fieldset {% if fieldset.css_id %}id="{{ fieldset.css_id }}"{% endif %}
+ {% if fieldset.css_class or form_style %}class="{{ fieldset.css_class }} {{ form_style }}"{% endif %}
+ {{ fieldset.flat_attrs|safe }}>
+ {% if legend %}<legend>{{ legend|safe }}</legend>{% endif %}
+ {{ fields|safe }}
+</fieldset>
diff --git a/crispy_forms/templates/bootstrap4/layout/formactions.html b/crispy_forms/templates/bootstrap4/layout/formactions.html
new file mode 100644
index 0000000..b80aa17
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/formactions.html
@@ -0,0 +1,9 @@
+<div{% if formactions.attrs %} {{ formactions.flat_attrs|safe }}{% endif %} class="form-group row">
+ {% if label_class %}
+ <div class="aab controls {{ label_class }}"></div>
+ {% endif %}
+
+ <div class="controls {{ field_class }}">
+ {{ fields_output|safe }}
+ </div>
+</div>
diff --git a/crispy_forms/templates/bootstrap4/layout/help_text.html b/crispy_forms/templates/bootstrap4/layout/help_text.html
new file mode 100644
index 0000000..0e2ed45
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/help_text.html
@@ -0,0 +1,7 @@
+{% if field.help_text %}
+ {% if help_text_inline %}
+ <span id="hint_{{ field.auto_id }}" class="help-block">{{ field.help_text|safe }}</span>
+ {% else %}
+ <p id="hint_{{ field.auto_id }}" class="help-block">{{ field.help_text|safe }}</p>
+ {% endif %}
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/layout/help_text_and_errors.html b/crispy_forms/templates/bootstrap4/layout/help_text_and_errors.html
new file mode 100644
index 0000000..d21cd44
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/help_text_and_errors.html
@@ -0,0 +1,13 @@
+{% if help_text_inline and not error_text_inline %}
+ {% include 'bootstrap4/layout/help_text.html' %}
+{% endif %}
+
+{% if error_text_inline %}
+ {% include 'bootstrap4/layout/field_errors.html' %}
+{% else %}
+ {% include 'bootstrap4/layout/field_errors_block.html' %}
+{% endif %}
+
+{% if not help_text_inline %}
+ {% include 'bootstrap4/layout/help_text.html' %}
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/layout/inline_field.html b/crispy_forms/templates/bootstrap4/layout/inline_field.html
new file mode 100644
index 0000000..9677181
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/inline_field.html
@@ -0,0 +1,21 @@
+{% load crispy_forms_field %}
+
+{% if field.is_hidden %}
+ {{ field }}
+{% else %}
+ {% if field|is_checkbox %}
+ <div id="div_{{ field.auto_id }}" class="checkbox">
+ <label for="{{ field.id_for_label }}" class="{% if field.field.required %} requiredField{% endif %}">
+ {% crispy_field field 'class' 'checkbox' %}
+ {{ field.label|safe }}
+ </label>
+ </div>
+ {% else %}
+ <div id="div_{{ field.auto_id }}" class="form-group">
+ <label for="{{ field.id_for_label }}" class="sr-only{% if field.field.required %} requiredField{% endif %}">
+ {{ field.label|safe }}
+ </label>
+ {% crispy_field field 'placeholder' field.label %}
+ </div>
+ {% endif %}
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/layout/multifield.html b/crispy_forms/templates/bootstrap4/layout/multifield.html
new file mode 100644
index 0000000..0a2c050
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/multifield.html
@@ -0,0 +1,27 @@
+{% load crispy_forms_field %}
+
+{% if field.is_hidden %}
+ {{ field }}
+{% else %}
+
+ {% if field.label %}
+ <label for="{{ field.id_for_label }}"{% if labelclass %} class="{{ labelclass }}"{% endif %}>
+ {% endif %}
+
+ {% if field|is_checkbox %}
+ {% crispy_field field %}
+ {% endif %}
+
+ {% if field.label %}
+ {{ field.label }}
+ {% endif %}
+
+ {% if not field|is_checkbox %}
+ {% crispy_field field %}
+ {% endif %}
+
+ {% if field.label %}
+ </label>
+ {% endif %}
+
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/layout/prepended_appended_text.html b/crispy_forms/templates/bootstrap4/layout/prepended_appended_text.html
new file mode 100644
index 0000000..e0f1171
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/prepended_appended_text.html
@@ -0,0 +1,30 @@
+{% load crispy_forms_field %}
+
+{% if field.is_hidden %}
+ {{ field }}
+{% else %}
+ <div id="div_{{ field.auto_id }}" class="form-group row{% if form_show_errors and field.errors %} has-error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
+
+ {% if field.label and form_show_labels %}
+ <label for="{{ field.id_for_label }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
+ {{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
+ </label>
+ {% endif %}
+
+ <div class="controls {{ field_class }}">
+ {% if field|is_select %}
+ {% if crispy_prepended_text %}<span class="input-group{% if active %} active{% endif %}{% if input_size %} {{ input_size }}{% endif %}">{{ crispy_prepended_text|safe }}</span>{% endif %}
+ {% crispy_field field %}
+ {% if crispy_appended_text %}<span class="input-group{% if active %} active{% endif %}{% if input_size %} {{ input_size }}{% endif %}">{{ crispy_appended_text|safe }}</span>{% endif %}
+ {% else %}
+ <div class="input-group">
+ {% if crispy_prepended_text %}<span class="input-group-addon{% if active %} active{% endif %}{% if input_size %} {{ input_size }}{% endif %}">{{ crispy_prepended_text|safe }}</span>{% endif %}
+ {% crispy_field field %}
+ {% if crispy_appended_text %}<span class="input-group-addon{% if active %} active{% endif %}{% if input_size %} {{ input_size }}{% endif %}">{{ crispy_appended_text|safe }}</span>{% endif %}
+ </div>
+ {% endif %}
+
+ {% include 'bootstrap4/layout/help_text_and_errors.html' %}
+ </div>
+ </div>
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/layout/radioselect.html b/crispy_forms/templates/bootstrap4/layout/radioselect.html
new file mode 100644
index 0000000..f4cefd4
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/radioselect.html
@@ -0,0 +1,17 @@
+{% load crispy_forms_filters %}
+{% load l10n %}
+
+<div class="controls {{ field_class }}"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>
+ {% include 'bootstrap4/layout/field_errors_block.html' %}
+
+ {% for choice in field.field.choices %}
+ {% if not inline_class %}<div class="radio">{% endif %}
+ <label class="{% if inline_class %}radio-{{ inline_class }}{% endif %}">
+ <input type="radio"{% if choice.0|stringformat:"s" == field.value|stringformat:"s" %} checked="checked"{% endif %} name="{{ field.html_name }}" id="id_{{ field.html_name }}_{{ forloop.counter }}" value="{{ choice.0|unlocalize }}" {{ field.field.widget.attrs|flatatt }}>
+ {{ choice.1|unlocalize }}
+ </label>
+ {% if not inline_class %}</div>{% endif %}
+ {% endfor %}
+
+ {% include 'bootstrap4/layout/help_text.html' %}
+</div>
diff --git a/crispy_forms/templates/bootstrap4/layout/radioselect_inline.html b/crispy_forms/templates/bootstrap4/layout/radioselect_inline.html
new file mode 100644
index 0000000..2add9d3
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/radioselect_inline.html
@@ -0,0 +1,14 @@
+{% if field.is_hidden %}
+ {{ field }}
+{% else %}
+ <div id="div_{{ field.auto_id }}" class="form-group row{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors and field.errors %} has-error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
+
+ {% if field.label %}
+ <label for="{{ field.auto_id }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
+ {{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
+ </label>
+ {% endif %}
+
+ {% include 'bootstrap4/layout/radioselect.html' %}
+ </div>
+{% endif %}
diff --git a/crispy_forms/templates/bootstrap4/layout/tab-link.html b/crispy_forms/templates/bootstrap4/layout/tab-link.html
new file mode 100644
index 0000000..60a69e0
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/tab-link.html
@@ -0,0 +1 @@
+<li class="tab-pane{% if 'active' in link.css_class %} active{% endif %}"><a href="#{{ link.css_id }}" data-toggle="tab">{{ link.name|capfirst }}{% if tab.errors %}!{% endif %}</a></li>
diff --git a/crispy_forms/templates/bootstrap4/layout/tab.html b/crispy_forms/templates/bootstrap4/layout/tab.html
new file mode 100644
index 0000000..730b4b4
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/tab.html
@@ -0,0 +1,6 @@
+<ul{% if tabs.css_id %} id="{{ tabs.css_id }}"{% endif %} class="nav nav-tabs">
+ {{ links|safe }}
+</ul>
+<div class="tab-content panel-body">
+ {{ content|safe }}
+</div>
diff --git a/crispy_forms/templates/bootstrap4/layout/uneditable_input.html b/crispy_forms/templates/bootstrap4/layout/uneditable_input.html
new file mode 100644
index 0000000..d5fdf2d
--- /dev/null
+++ b/crispy_forms/templates/bootstrap4/layout/uneditable_input.html
@@ -0,0 +1,10 @@
+{% load crispy_forms_field %}
+
+
+<div id="div_{{ field.auto_id }}" class="form-group row{% if form_show_errors and field.errors %} error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
+ <label class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}</label>
+ <div class="controls {{ field_class }}">
... 1083 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django-crispy-forms.git
More information about the Python-modules-commits
mailing list