{% from "layout/errorlist.html" import errorlist %} {# these macros are only used here so it's better to define them locally #} {% macro raw_row(html, classes, label) %}
{{ html|safe }}
{% endmacro %} {% macro row(field, classes, label=None) %} {% if not label %} {% set label = field.label %} {% endif %} {{ row_custom(field, field.name + ' ' + classes, label) }} {% endmacro %} {% macro form_row(form, field_name, classes='') %} {% set html = form[field_name] %} {% if form[field_name].help_text %} {% set html = to_unicode('{old_html}
{details}
')|f( old_html=html, details=form[field_name].help_text) %} {% endif %} {{ raw_row(html, field_name + ' ' + classes, form[field_name].label) }} {% endmacro %} {% macro submit_row(form, type) %}
{% endmacro %} {% macro image_preview(form, type, name) %} {% if type == 'image' %}
{% if form.instance.pk %} {% endif %}
{% endif %} {% endmacro %} {% macro image_fields(form, type, name) %} {{ form_row(form, name, classes='upload-media') }} {{ raw_row('
{text}'|fe( name=name, text=_('Cancel'), url=url('gallery.gallery', media_type=media_type)), 'progress ' + name, _('Progress')) }} {{ image_preview(form, type, name) }} {% endmacro %} {% if image_form.instance.pk %} {% set has_draft = True %} {% endif %} {# What JS needs to do: * Hide/Show progress * Show progress => Disable submit * Hide progress => Enable submit TODO: better error messages ("invalid file" means too big, or extension, etc) #}