Changed the format of the wtforms table slightly
authortilly-Q <nattilypigeonfowl@gmail.com>
Mon, 12 May 2014 16:20:03 +0000 (12:20 -0400)
committertilly-Q <nattilypigeonfowl@gmail.com>
Mon, 12 May 2014 16:20:03 +0000 (12:20 -0400)
mediagoblin/edit/forms.py
mediagoblin/static/css/base.css
mediagoblin/templates/mediagoblin/edit/metadata.html
mediagoblin/templates/mediagoblin/utils/wtforms.html

index ce66526f551aefe12145c782ac912c5d3249d877..7ddf603ed28796c1a11ecfd6c172b1c206825f5c 100644 (file)
@@ -124,8 +124,8 @@ class ChangeEmailForm(wtforms.Form):
             "Enter your password to prove you own this account."))
 
 class MetaDataForm(wtforms.Form):
-    identifier = wtforms.TextField('')
-    value = wtforms.TextField('')
+    identifier = wtforms.TextField(_(u'Identifier'))
+    value = wtforms.TextField(_(u'Value'))
 
 class EditMetaDataForm(wtforms.Form):
     media_metadata = wtforms.FieldList(
index d0396ceb1daafe4b5f2c17822eb9bd44f9001b94..bb2a2cbd120b4c82933b860a2774bb4e2685bb15 100644 (file)
@@ -943,12 +943,16 @@ p.verifier {
 table.metadata_editor {
 
     margin: 10px auto;
-    width: 800px;
+    width: 1000px;
+}
+
+table.metadata_editor tr th {
+    width:100px;
 }
 
 table.metadata_editor tr td {
-    width:350px;
+    width:300px;
 }
 table.metadata_editor tr td.form_field_input input {
-    width: 300px
+    width:300px;
 }
index 364cad0de94a74f95e2fc9af9fb252d7412b9c92..d5d1fec502065e5b0d0772ec74598e9433411fdc 100644 (file)
      visit http:/wwww.json-ld.org for more information. -->
   <h3>{% trans %}Context{% endtrans %}</h3>
   <table class="metadata_editor" id="context_list">
-    <tr>
-      <td><a class="strong highlight">
-        {% trans %}Identifier{% endtrans %}</a></td>
-      <td><a class="strong highlight">{% trans %}Value{% endtrans %}</a></td>
-    </tr>
-  {% for miniform in form.context -%}
-    {{ wtforms_util.render_table_row(miniform) }}
-  {% endfor -%}
+    {{ wtforms_util.render_fieldlist_as_table_rows(form.context) }}
   </table>
 
   <table class="metadata_editor" id="buttons_top">
     <tr>
+      <th></th>
       <td><input type=button value="{% trans %}Add new Row{% endtrans %}"
         class="button_action" id="add_new_context_row" /></td>
+      <th></th>
       <td></td>
     </tr>
   </table>
 <!-- This table holds all the information about the media entry's metadata -->
   <h3>{% trans %}Data{% endtrans %}</h3>
   <table class="metadata_editor" id="metadata_list" >
-    <tr>
-      <td><a class="strong highlight">
-        {% trans %}Identifier{% endtrans %}</a></td>
-      <td><a class="strong highlight">{% trans %}Value{% endtrans %}</a></td>
-    </tr>
-  {% for miniform in form.media_metadata -%}
-    {{ wtforms_util.render_table_row(miniform) }}
-  {% endfor -%}
+    {{ wtforms_util.render_fieldlist_as_table_rows(form.media_metadata) }}
   </table>
 
 <!-- These are the buttons you use to control the form -->
   <table class="metadata_editor" id="buttons_bottom">
     <tr>
+      <th></th>
       <td><input type=button value="{% trans %}Add new Row{% endtrans %}"
         class="button_action" id="add_new_metadata_row" />
       </td>
+      <th></th>
       <td><input type=submit value="{% trans %}Update Metadata{% endtrans %}"
         class="button_action_highlight" /></td>
     </tr>
     <tr>
+      <th></th>
       <td><input type=button value="{% trans %}Clear empty Rows{% endtrans %}"
         class="button_action" id="clear_empty_rows" /></td>
     </tr>
index e861b67481136b1045d1587df49eb9e6175060c3..c83d53f11fc9d0c5d21ced32b1c2d0b43d83235a 100644 (file)
 {# Auto-render a form as a table #}
 {% macro render_table(form) -%}
   {% for field in form %}
-    <tr>
-      <th>{{ field.label.text }}</th>
-      <td>
-        {{field}}
-        {% if field.errors %}
-          <br />
-          <ul class="errors">
-            {% for error in field.errors %}
-              <li>{{error}}</li>
-            {% endfor %}
-          </ul>
-        {% endif %}
-      </td>
-    </tr>
+    render_field_as_table_row(field)
   {% endfor %}
 {%- endmacro %}
 
-{% macro render_table_row(form) %}
+{% macro render_form_as_table_row(form) %}
   <tr>
   {%- for field in form %}
+    <th>{{ render_label_p(field) }}</th>
     <td class="form_field_input">
       {{field}}
       {%- if field.errors -%}
   </tr>
 {%- endmacro %}
 
+{% macro render_field_as_table_row(field) %}
+  <tr>
+    <th>{{ field.label.text }}</th>
+    <td>
+      {{field}}
+      {% if field.errors %}
+        <br />
+        <ul class="errors">
+          {% for error in field.errors %}
+            <li>{{error}}</li>
+          {% endfor %}
+        </ul>
+      {% endif %}
+    </td>
+  </tr>
+{% endmacro %}
+
+{% macro render_fieldlist_as_table_rows(fieldlist) %}
+  {% for field in fieldlist -%}
+    {%- if field.type == 'FormField' %}
+        {{ render_form_as_table_row(field) }}
+    {%- else %}
+        {{ render_field_as_table_row(field) }}
+    {%- endif %}
+  {% endfor -%}
+{% endmacro %}
+
 {# Render a boolean field #}
 {% macro render_bool(field) %}
   <div class="boolean">