From f6bf68cae5f2907924e126a3a2f3a2f015292323 Mon Sep 17 00:00:00 2001 From: Caleb Forbes Davis V Date: Thu, 11 Aug 2011 00:50:16 -0500 Subject: [PATCH 1/3] Feature #446 - Render the submission form using the render_divs macro - Currently there are individual calls to wtforms_util.render_field_div for each field in the media submit form, which is too verbose - Matched the field ordering in submit/form.py to the verbose version - hacks the correct textareafield rendering with hard-coded rows and columns. - TODO - figure out how to pass the textarea dimensions with **kwargs --- mediagoblin/submit/forms.py | 2 +- mediagoblin/templates/mediagoblin/submit/start.html | 5 +---- mediagoblin/templates/mediagoblin/utils/wtforms.html | 6 +++++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/mediagoblin/submit/forms.py b/mediagoblin/submit/forms.py index 241d32dc..4519b057 100644 --- a/mediagoblin/submit/forms.py +++ b/mediagoblin/submit/forms.py @@ -22,11 +22,11 @@ from mediagoblin.util import fake_ugettext_passthrough as _ class SubmitStartForm(wtforms.Form): + file = wtforms.FileField(_('File')) title = wtforms.TextField( _('Title'), [wtforms.validators.Length(min=0, max=500)]) description = wtforms.TextAreaField('Description of this work') - file = wtforms.FileField(_('File')) tags = wtforms.TextField( _('Tags'), [tag_length_validator]) diff --git a/mediagoblin/templates/mediagoblin/submit/start.html b/mediagoblin/templates/mediagoblin/submit/start.html index eb34c2e2..3a40850d 100644 --- a/mediagoblin/templates/mediagoblin/submit/start.html +++ b/mediagoblin/templates/mediagoblin/submit/start.html @@ -24,10 +24,7 @@ method="POST" enctype="multipart/form-data">

{% trans %}Submit yer media{% endtrans %}

- {{ wtforms_util.render_field_div(submit_form.file) }} - {{ wtforms_util.render_field_div(submit_form.title) }} - {{ wtforms_util.render_textarea_div(submit_form.description) }} - {{ wtforms_util.render_field_div(submit_form.tags) }} + {{ wtforms_util.render_divs(submit_form) }}
diff --git a/mediagoblin/templates/mediagoblin/utils/wtforms.html b/mediagoblin/templates/mediagoblin/utils/wtforms.html index e3d8e137..3b6cff15 100644 --- a/mediagoblin/templates/mediagoblin/utils/wtforms.html +++ b/mediagoblin/templates/mediagoblin/utils/wtforms.html @@ -23,7 +23,11 @@ {% if field.description -%}
{{ _(field.description) }}
{%- endif %} -
{{ field }}
+ {% if field.type == "TextAreaField" %} +
{{ field(rows=8, cols=20) }}
+ {% else %} +
{{ field }}
+ {% endif %} {%- if field.errors -%} {% for error in field.errors %}
From d07be8119de3b2e10ca37d43dfecd4239dc09aba Mon Sep 17 00:00:00 2001 From: Caleb Forbes Davis V Date: Thu, 11 Aug 2011 10:15:30 -0500 Subject: [PATCH 2/3] eliminates textarea handling since rows cols not required in HTML5 --- .../templates/mediagoblin/utils/wtforms.html | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/mediagoblin/templates/mediagoblin/utils/wtforms.html b/mediagoblin/templates/mediagoblin/utils/wtforms.html index 3b6cff15..2639522a 100644 --- a/mediagoblin/templates/mediagoblin/utils/wtforms.html +++ b/mediagoblin/templates/mediagoblin/utils/wtforms.html @@ -23,30 +23,7 @@ {% if field.description -%}
{{ _(field.description) }}
{%- endif %} - {% if field.type == "TextAreaField" %} -
{{ field(rows=8, cols=20) }}
- {% else %} -
{{ field }}
- {% endif %} - {%- if field.errors -%} - {% for error in field.errors %} -
- {{ error }} -
- {% endfor %} - {%- endif %} -
-{%- endmacro %} - -{# Generically render a textarea - # ... mostly the same thing except it includes rows and cols #} -{% macro render_textarea_div(field, rows=8, cols=20) %} -
-
{{ _(field.label.text) }}
- {% if field.description -%} -
{{ _(field.description) }}
- {%- endif %} -
{{ field(rows=rows, cols=cols) }}
+
{{ field }}
{%- if field.errors -%} {% for error in field.errors %}
From d9204d3a3dd91f63fd43345415ebeb6fc02cc1c8 Mon Sep 17 00:00:00 2001 From: Caleb Forbes Davis V Date: Thu, 11 Aug 2011 19:17:56 -0500 Subject: [PATCH 3/3] uses render_divs for the comments form in media.html for completeness --- mediagoblin/templates/mediagoblin/user_pages/media.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index afc0d903..9c0a1cca 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -55,7 +55,7 @@
- {{ wtforms_util.render_field_div(comment_form.comment_content) }} + {{ wtforms_util.render_divs(comment_form) }}