Skip to content

Commit

Permalink
Mise à jour majeure de django_crispy_forms
Browse files Browse the repository at this point in the history
  • Loading branch information
Situphen committed Jan 13, 2024
1 parent 411bc88 commit 1a3fe92
Show file tree
Hide file tree
Showing 37 changed files with 433 additions and 1 deletion.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ social-auth-app-django==5.4.0

# Explicit dependencies (references in code)
beautifulsoup4==4.12.2
django-crispy-forms==1.14.0
django-crispy-forms==2.0
django-model-utils==4.3.1
django-munin==0.2.1
django-recaptcha==4.0.0
Expand Down
10 changes: 10 additions & 0 deletions templates/bootstrap/accordion-group.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#{{ div.data_parent }}" href="#{{ div.css_id }}">{{ div.name }}</a>
</div>
<div id="{{ div.css_id }}" class="accordion-body collapse{% if div.active %} in{% endif %}" >
<div class="accordion-inner">
{{ fields|safe }}
</div>
</div>
</div>
3 changes: 3 additions & 0 deletions templates/bootstrap/accordion.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="accordion" id="{{ accordion.css_id }}">
{{ content|safe }}
</div>
21 changes: 21 additions & 0 deletions templates/bootstrap/betterform.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% 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 "bootstrap/field.html" %}
{% endif %}
{% endfor %}
{% if not forloop.last or not fieldset_open %}
</fieldset>
{% endif %}
{% endfor %}
9 changes: 9 additions & 0 deletions templates/bootstrap/display_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% if form.form_html %}
{% if include_media %}{{ form.media }}{% endif %}
{% if form_show_errors %}
{% include "bootstrap/errors.html" %}
{% endif %}
{{ form.form_html }}
{% else %}
{% include "bootstrap/uni_form.html" %}
{% endif %}
8 changes: 8 additions & 0 deletions templates/bootstrap/errors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% if form.non_field_errors %}
<div class="alert alert-block alert-error">
{% if form_error_title %}<h4 class="alert-heading">{{ form_error_title }}</h4>{% endif %}
<ul>
{{ form.non_field_errors|unordered_list }}
</ul>
</div>
{% endif %}
8 changes: 8 additions & 0 deletions templates/bootstrap/errors_formset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% if formset.non_form_errors %}
<div class="alert alert-block alert-error">
{% if formset_error_title %}<h4 class="alert-heading">{{ formset_error_title }}</h4>{% endif %}
<ul>
{{ formset.non_form_errors|unordered_list }}
</ul>
</div>
{% endif %}
36 changes: 36 additions & 0 deletions templates/bootstrap/field.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% load crispy_forms_field %}

{% if field.is_hidden %}
{{ field }}
{% else %}
<{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" class="control-group{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors%}{% if field.errors %} 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 {% 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 'bootstrap/layout/checkboxselectmultiple.html' %}
{% endif %}

{% if field|is_radioselect %}
{% include 'bootstrap/layout/radioselect.html' %}
{% endif %}

{% if not field|is_checkboxselectmultiple and not field|is_radioselect %}
<div class="controls">
{% if field|is_checkbox and form_show_labels %}
<label for="{{ field.id_for_label }}" class="checkbox {% if field.field.required %}requiredField{% endif %}">
{% crispy_field field %}
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% include 'bootstrap/layout/help_text_and_errors.html' %}
{% else %}
{% crispy_field field %}
{% include 'bootstrap/layout/help_text_and_errors.html' %}
{% endif %}
</div>
{% endif %}
</{% if tag %}{{ tag }}{% else %}div{% endif %}>
{% endif %}
4 changes: 4 additions & 0 deletions templates/bootstrap/layout/alert.html
Original file line number Diff line number Diff line change
@@ -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">&times;</button>{% endif %}
{{ content|safe }}
</div>
9 changes: 9 additions & 0 deletions templates/bootstrap/layout/baseinput.html
Original file line number Diff line number Diff line change
@@ -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 }}
/>
1 change: 1 addition & 0 deletions templates/bootstrap/layout/button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<button {{ button.flat_attrs|safe }}>{{ button.content|safe }}</button>
4 changes: 4 additions & 0 deletions templates/bootstrap/layout/buttonholder.html
Original file line number Diff line number Diff line change
@@ -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>
14 changes: 14 additions & 0 deletions templates/bootstrap/layout/checkboxselectmultiple.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% load crispy_forms_filters %}
{% load l10n %}

<div class="controls"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>
{% include 'bootstrap/layout/field_errors_block.html' %}

{% for choice in field.field.choices %}
<label class="checkbox{% if inline_class %} {{ inline_class }}{% endif %}" for="id_{{ field.html_name }}_{{ forloop.counter0 }}">
<input type="checkbox"{% if choice.0 in field.value or choice.0|stringformat:"s" in field.value or choice.0|stringformat:"s" == field.value|default_if_none:""|stringformat:"s" %} checked{% endif %} name="{{ field.html_name }}" id="id_{{ field.html_name }}_{{ forloop.counter0 }}" value="{{ choice.0|unlocalize }}" {{ field.field.widget.attrs|flatatt }}>{{ choice.1|unlocalize }}
</label>
{% endfor %}

{% include 'bootstrap/layout/help_text.html' %}
</div>
14 changes: 14 additions & 0 deletions templates/bootstrap/layout/checkboxselectmultiple_inline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% if field.is_hidden %}
{{ field }}
{% else %}
<div id="div_{{ field.auto_id }}" class="control-group{% if form_show_errors and field.errors %} error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">

{% if field.label %}
<label for="{{ field.auto_id }}" class="control-label{% if field.field.required %} requiredField{% endif %}">
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}

{% include 'bootstrap/layout/checkboxselectmultiple.html' %}
</div>
{% endif %}
3 changes: 3 additions & 0 deletions templates/bootstrap/layout/column.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div {% if div.css_id %}id="{{ div.css_id }}"{% endif %} class="{{ div.css_class|default:'' }}" {{ div.flat_attrs|safe }}>
{{ fields|safe }}
</div>
4 changes: 4 additions & 0 deletions templates/bootstrap/layout/div.html
Original file line number Diff line number Diff line change
@@ -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>
5 changes: 5 additions & 0 deletions templates/bootstrap/layout/field_errors.html
Original file line number Diff line number Diff line change
@@ -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-inline"><strong>{{ error }}</strong></span>
{% endfor %}
{% endif %}
5 changes: 5 additions & 0 deletions templates/bootstrap/layout/field_errors_block.html
Original file line number Diff line number Diff line change
@@ -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 %}
17 changes: 17 additions & 0 deletions templates/bootstrap/layout/field_with_buttons.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% load crispy_forms_field %}

<div{% if div.css_id %} id="{{ div.css_id }}"{% endif %} class="control-group{% if form_show_errors and field.errors %} 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{% if field.field.required %} requiredField{% endif %}">
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}

<div class="controls">
<div class="input-append">
{% crispy_field field %}
{{ buttons|safe }}
</div>
{% include 'bootstrap/layout/help_text_and_errors.html' %}
</div>
</div>
6 changes: 6 additions & 0 deletions templates/bootstrap/layout/fieldset.html
Original file line number Diff line number Diff line change
@@ -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>
3 changes: 3 additions & 0 deletions templates/bootstrap/layout/formactions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div{% if formactions.attrs %} {{ formactions.flat_attrs|safe }}{% endif %} class="form-actions">
{{ fields_output|safe }}
</div>
7 changes: 7 additions & 0 deletions templates/bootstrap/layout/help_text.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% if field.help_text %}
{% if help_text_inline %}
<span id="hint_{{ field.auto_id }}" class="help-inline">{{ field.help_text|safe }}</span>
{% else %}
<p id="hint_{{ field.auto_id }}" class="help-block">{{ field.help_text|safe }}</p>
{% endif %}
{% endif %}
13 changes: 13 additions & 0 deletions templates/bootstrap/layout/help_text_and_errors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% if help_text_inline and not error_text_inline %}
{% include 'bootstrap/layout/help_text.html' %}
{% endif %}

{% if error_text_inline %}
{% include 'bootstrap/layout/field_errors.html' %}
{% else %}
{% include 'bootstrap/layout/field_errors_block.html' %}
{% endif %}

{% if not help_text_inline %}
{% include 'bootstrap/layout/help_text.html' %}
{% endif %}
27 changes: 27 additions & 0 deletions templates/bootstrap/layout/multifield.html
Original file line number Diff line number Diff line change
@@ -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 %}
24 changes: 24 additions & 0 deletions templates/bootstrap/layout/prepended_appended_text.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% load crispy_forms_field %}

{% if field.is_hidden %}
{{ field }}
{% else %}
<div id="div_{{ field.auto_id }}" class="control-group{% if form_show_errors and field.errors %} 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{% if field.field.required %} requiredField{% endif %}">
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}

<div class="controls">
<div class="{% if crispy_prepended_text %}input-prepend{% endif %} {% if crispy_appended_text %}input-append{% endif %}">
{% if crispy_prepended_text %}<span class="{% if not field|is_select %}add-on{% endif %}{% if active %} active{% endif %}">{{ crispy_prepended_text|safe }}</span>{% endif %}
{% crispy_field field %}
{% if crispy_appended_text %}<span class="{% if not field|is_select %}add-on{% endif %}{% if active %} active{% endif %}">{{ crispy_appended_text|safe }}</span>{% endif %}
</div>

{% include 'bootstrap/layout/help_text_and_errors.html' %}
</div>
</div>
{% endif %}
14 changes: 14 additions & 0 deletions templates/bootstrap/layout/radioselect.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% load crispy_forms_filters %}
{% load l10n %}

<div class="controls"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>
{% include 'bootstrap/layout/field_errors_block.html' %}

{% for choice in field.field.choices %}
<label for="id_{{ field.html_name }}_{{ forloop.counter0 }}" class="radio{% if inline_class %} {{ inline_class }}{% endif %}">
<input type="radio"{% if choice.0|stringformat:"s" == field.value|default_if_none:""|stringformat:"s" %} checked{% endif %} name="{{ field.html_name }}" id="id_{{ field.html_name }}_{{ forloop.counter0 }}" value="{{ choice.0|unlocalize }}" {{ field.field.widget.attrs|flatatt }}>{{ choice.1|unlocalize }}
</label>
{% endfor %}

{% include 'bootstrap/layout/help_text.html' %}
</div>
14 changes: 14 additions & 0 deletions templates/bootstrap/layout/radioselect_inline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% if field.is_hidden %}
{{ field }}
{% else %}
<div id="div_{{ field.auto_id }}" class="control-group{% if form_show_errors and field.errors %} error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">

{% if field.label %}
<label for="{{ field.auto_id }}" class="control-label{% if field.field.required %} requiredField{% endif %}">
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}

{% include 'bootstrap/layout/radioselect.html' %}
</div>
{% endif %}
3 changes: 3 additions & 0 deletions templates/bootstrap/layout/row.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div {% if div.css_id %}id="{{ div.css_id }}"{% endif %} class="row {{ div.css_class|default:'' }}" {{ div.flat_attrs|safe }}>
{{ fields|safe }}
</div>
1 change: 1 addition & 0 deletions templates/bootstrap/layout/tab-link.html
Original file line number Diff line number Diff line change
@@ -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>
6 changes: 6 additions & 0 deletions templates/bootstrap/layout/tab.html
Original file line number Diff line number Diff line change
@@ -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">
{{ content|safe }}
</div>
7 changes: 7 additions & 0 deletions templates/bootstrap/layout/uneditable_input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="div_{{ field.auto_id }}" class="control-group{% if form_show_errors and field.errors %} error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
<div class="control-label{% if field.field.required %} requiredField{% endif %}">{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}</div>
<div class="controls">
<span {{ flat_attrs|safe }}>{% if field.value %}{{ field.value }}{% endif %}</span>
{% include 'bootstrap/layout/help_text.html' %}
</div>
</div>
Loading

0 comments on commit 1a3fe92

Please sign in to comment.