Simplify django form rendering

Remove my hack to get bootstrap forms.

Remove the insane render-row-at-a-time forms that then only render
default django forms.
This commit is contained in:
Sachi King 2017-04-24 16:31:13 +10:00
parent 7b74d3829f
commit b3ac11a66b
31 changed files with 4 additions and 160 deletions

View file

@ -90,7 +90,6 @@ STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",

View file

@ -1,4 +1,6 @@
{% load pyconau2017_tags %}
{% load bootstrap %}
{% if form.non_field_errors %}
<div class="has-errors">
{{ form.non_field_errors }}
@ -10,4 +12,4 @@
Fields marked with <strong>*</strong> are required.
</blockquote>
{% include "forms/render.html" with form=form %}
{{ form|bootstrap_horizontal }}

View file

@ -1 +0,0 @@
<input class="form-check-input" type="{{ widget.type }}" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} />

View file

@ -1,3 +0,0 @@
{% if wrap_label %}<label class="form-check-label"{% if widget.attrs.id %} for="{{ widget.attrs.id }}"{% endif %}>{% endif %}
<input class="form-check-input" type="{{ widget.type }}" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} />
{% if wrap_label %} {{ widget.label }}</label>{% endif %}

View file

@ -1 +0,0 @@
<input class="form-control" type="{{ widget.type }}" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} />

View file

@ -1,3 +0,0 @@
{% if wrap_label %}<label class="form-check-label"{% if widget.attrs.id %} for="{{ widget.attrs.id }}"{% endif %}>{% endif %}
<input class="form-check-input" type="{{ widget.type }}" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} />
{% if wrap_label %} {{ widget.label }}</label>{% endif %}

View file

@ -1,5 +0,0 @@
<select class="form-control" name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% for group_name, group_choices, group_index in widget.optgroups %}{% if group_name %}
<optgroup label="{{ group_name }}">{% endif %}{% for option in group_choices %}
{% include option.template_name with widget=option %}{% endfor %}{% if group_name %}
</optgroup>{% endif %}{% endfor %}
</select>

View file

@ -1 +0,0 @@
<input class="form-control" type="{{ widget.type }}" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} />

View file

@ -1,2 +0,0 @@
<textarea class="form-control" name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>
{% if widget.value %}{{ widget.value }}{% endif %}</textarea>

View file

@ -1,58 +0,0 @@
{% load formset_tags %}
{% if form.total_form_count and form.empty_form %}
{% comment %}This is a formset.{% endcomment %}
<div class="formset" data-formset-prefix="{{ form.prefix }}">
{{ form.management_form }}
<div data-formset-body>
{% for inner_form in form %}
<div data-formset-form>
<fieldset>
{% include "forms/render_fields.html" with form=inner_form %}
</fieldset>
</div>
{% if not forloop.last %}
<div class="vertical-small"></div>
{% endif %}
{% endfor %}
</div>
<script type="form-template" data-formset-empty-form>
{% escapescript %}
<div class="vertical-small"></div>
<div data-formset-form>
<fieldset>
{% include "forms/render_fields.html" with form=form.empty_form %}
</fieldset>
</div>
{% endescapescript %}
</script>
<div class="vertical-small"></div>
<input type="button" class="btn" value="Add another" data-formset-add>
<script type="text/javascript">
function defer() {
if (window.jQuery) {
jQuery(function($) {
$(".formset").formset({
animateForms: true
});
});
} else {
setTimeout(function() { defer() }, 50);
}
}
defer();
</script>
</div>
{% else %}
{% include "forms/render_fields.html" %}
{% endif %}

View file

@ -1,5 +0,0 @@
{% for field in form %}
{% if not field.is_hidden %}
{% include "forms/widget.html" %}
{% endif %}
{% endfor %}

View file

@ -1,14 +0,0 @@
{% load pyconau2017_tags %}
<div class="form-group row">
{% classname field.field.widget as widget %}
{% if widget == "CheckboxInput" %}
{% include "forms/widget_boolean_single.html" %}
{% elif widget == "RadioSelect" or widget == "CheckboxSelectMultiple" %}
{% include "forms/widget_boolean_multiple.html" %}
{% elif widget == "Select" or widget == "SelectMultiple" or widget == "LazySelect" or widget == "CountrySelectWidget" %}
{% include "forms/widget_basic.html" with widget_class="select" %}
{% else %}
{% include "forms/widget_basic.html" %}
{% endif %}
</div>

View file

@ -1,12 +0,0 @@
{% if field.errors %}
<div class="alert alert-danger col-sm-offset-2 col-sm-10" role="alert">
{{ field.errors }}
</div>
{% endif %}
<label for="{{ field.id_for_label }}" class="col-sm-2 control-label">{{ field.label }}{% if field.field.required %} *{% endif %}</label>
<div class="col-sm-10">
{{ field }}
{% if field.help_text %}
<span class="help_text">{{ field.help_text|safe }}</span>
{% endif %}
</div>

View file

@ -1,18 +0,0 @@
<h3>
{{ field.label }}{% if field.field.required %} *{% endif %}
</h3>
{% if field.help_text %}
<span class="help_text">{{ field.help_text|safe }}</span>
{% endif %}
{% if field.errors %}
<div class="alert alert-danger" role="alert">
{{ field.errors }}
</div>
{% endif %}
{% for item in field %}
<div class="col-sm-offset-2 col-sm-10">
{{ item }}
</div>
{% endfor%}

View file

@ -1,17 +0,0 @@
<h3>
{{ field.label }}{% if field.field.required %} *{% endif %}
</h3>
{% if field.errors %}
<div class="alert alert-danger col-sm-offset-2 col-sm-10" role="alert">
{{ field.errors }}
</div>
{% endif %}
<div class="col-sm-offset-2 col-sm-10">
<label class="form-check-label" for="id_profile-past_lca_0">
{{ field }}
<p>Sign me up</p>
{% if field.help_text %}
<span class="help_text">{{ field.help_text|safe }}</span>
{% endif %}
</label>
</div>

View file

@ -1,5 +1,4 @@
{% extends "registrasion/base.html" %}
{% load bootstrap %}
{% load registrasion_tags %}
{% block content %}

View file

@ -1,5 +1,4 @@
{% extends "registrasion/base.html" %}
{% load bootstrap %}
{% load registrasion_tags %}
{% block body %}

View file

@ -1,5 +1,4 @@
{% extends "registrasion/base.html" %}
{% load bootstrap %}
{% load pyconau2017_tags %}
{% block header_title %}Buy Your Ticket{% endblock %}

View file

@ -1,5 +1,4 @@
{% extends "registrasion/base.html" %}
{% load bootstrap %}
{% load registrasion_tags %}
{% load pyconau2017_tags %}
{% load staticfiles %}

View file

@ -1,5 +1,4 @@
{% extends "registrasion/base.html" %}
{% load bootstrap %}
{% load registrasion_tags %}
{% load pyconau2017_tags %}

View file

@ -1,5 +1,4 @@
{% extends "registrasion/base.html" %}
{% load bootstrap %}
{% load pyconau2017_tags %}
{% block header_title %}Your profile{% endblock %}

View file

@ -1,5 +1,4 @@
{% extends "site_base.html" %}
{% load bootstrap %}
{% load registrasion_tags %}
{% block body %}

View file

@ -1,5 +1,4 @@
{% extends "registrasion/base.html" %}
{% load bootstrap %}
{% load registrasion_tags %}
{% load pyconau2017_tags %}

View file

@ -1,5 +1,4 @@
{% extends "registrasion/base.html" %}
{% load bootstrap %}
{% load registrasion_tags %}
{% load pyconau2017_tags %}

View file

@ -1,7 +1,5 @@
{% extends "symposion/proposals/base.html" %}
{% load bootstrap %}
{% block page_title %}Upload Document to '{{ proposal.title }}'{% endblock %}
{% block proposals_body %}

View file

@ -1,7 +1,6 @@
{% extends "symposion/proposals/base.html" %}
{% load i18n %}
{% load bootstrap %}
{% block head_title %}{{ proposal.title }}{% endblock %}
{% block page_title %}#{{ proposal.number }}: {{ proposal.title }} ({{ proposal.speaker }}){% endblock %}

View file

@ -1,7 +1,5 @@
{% extends "symposion/proposals/base.html" %}
{% load bootstrap %}
{% block head_title %}Editing {{ proposal.title }}{% endblock %}
{% block page_title %}Editing: {{ proposal.title }}{% endblock %}

View file

@ -1,7 +1,6 @@
{% extends "symposion/proposals/base.html" %}
{% load i18n %}
{% load bootstrap %}
{% block page_title %}{% trans 'Proposal:' %} {{ proposal.title }}{% endblock %}
{% block head_title %}{% trans 'Proposal:' %} {{ proposal.title }}{% endblock %}

View file

@ -1,7 +1,7 @@
{% extends "symposion/reviews/base.html" %}
{% load i18n %}
{% load bootstrap %}
{% load i18n %}
{% block body %}

View file

@ -1,6 +1,5 @@
{% extends "symposion/speakers/base.html" %}
{% load bootstrap %}
{% load i18n %}
{% block head_title %}{% trans "Create Speaker Profile" %}{% endblock %}

View file

@ -1,6 +1,5 @@
{% extends "symposion/speakers/base.html" %}
{% load bootstrap %}
{% load i18n %}
{% block head_title %}{% trans "Edit Speaker Profile" %}{% endblock %}