Feature #446 - Render the submission form using the render_divs macro
authorCaleb Forbes Davis V <caldavis@gmail.com>
Thu, 11 Aug 2011 05:50:16 +0000 (00:50 -0500)
committerCaleb Forbes Davis V <caldavis@gmail.com>
Thu, 11 Aug 2011 05:50:16 +0000 (00:50 -0500)
- 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
mediagoblin/templates/mediagoblin/submit/start.html
mediagoblin/templates/mediagoblin/utils/wtforms.html

index 241d32dcdee5c8989cb4a3788b99822f89298422..4519b057a4e4420ab413daf16bb7e980195faeb3 100644 (file)
@@ -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])
index eb34c2e23f4aefe9add62fc5c94ce61cc6fbcbac..3a40850da01b1b7cfb79a1ecd7faf8f0de0ee9de 100644 (file)
         method="POST" enctype="multipart/form-data">
     <div class="grid_8 prefix_1 suffix_1 form_box">
       <h1>{% trans %}Submit yer media{% endtrans %}</h1>
-      {{ 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) }}
       <div class="form_submit_buttons">
       <input type="submit" value="{% trans %}Submit{% endtrans %}" class="button" />
       </div>
index e3d8e137d51adc025405abd5b8dddd0925fdb1b5..3b6cff15f46b63a83e6e5ec996564e5a4f5748d1 100644 (file)
     {% if field.description -%}
       <div class="form_field_description">{{ _(field.description) }}</div>
     {%- endif %}
-    <div class="form_field_input">{{ field }}</div>
+    {% if field.type == "TextAreaField" %}
+      <div class="form_field_input">{{ field(rows=8, cols=20) }}</div>
+    {% else %}
+      <div class="form_field_input">{{ field }}</div>
+    {% endif %}
     {%- if field.errors -%}
       {% for error in field.errors %}
         <div class="form_field_error">