From 494bce47f92165f322347003baac22731e0ee7aa Mon Sep 17 00:00:00 2001 From: tilly-Q Date: Mon, 12 May 2014 12:20:03 -0400 Subject: [PATCH] Changed the format of the wtforms table slightly --- mediagoblin/edit/forms.py | 4 +- mediagoblin/static/css/base.css | 10 +++-- .../templates/mediagoblin/edit/metadata.html | 23 +++------- .../templates/mediagoblin/utils/wtforms.html | 45 ++++++++++++------- 4 files changed, 46 insertions(+), 36 deletions(-) diff --git a/mediagoblin/edit/forms.py b/mediagoblin/edit/forms.py index ce66526f..7ddf603e 100644 --- a/mediagoblin/edit/forms.py +++ b/mediagoblin/edit/forms.py @@ -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( diff --git a/mediagoblin/static/css/base.css b/mediagoblin/static/css/base.css index d0396ceb..bb2a2cbd 100644 --- a/mediagoblin/static/css/base.css +++ b/mediagoblin/static/css/base.css @@ -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; } diff --git a/mediagoblin/templates/mediagoblin/edit/metadata.html b/mediagoblin/templates/mediagoblin/edit/metadata.html index 364cad0d..d5d1fec5 100644 --- a/mediagoblin/templates/mediagoblin/edit/metadata.html +++ b/mediagoblin/templates/mediagoblin/edit/metadata.html @@ -78,20 +78,15 @@ visit http:/wwww.json-ld.org for more information. -->

{% trans %}Context{% endtrans %}

- - - - - {% for miniform in form.context -%} - {{ wtforms_util.render_table_row(miniform) }} - {% endfor -%} + {{ wtforms_util.render_fieldlist_as_table_rows(form.context) }}
- {% trans %}Identifier{% endtrans %}{% trans %}Value{% endtrans %}
+ +
@@ -99,26 +94,22 @@

{% trans %}Data{% endtrans %}

- - - - - {% for miniform in form.media_metadata -%} - {{ wtforms_util.render_table_row(miniform) }} - {% endfor -%} + {{ wtforms_util.render_fieldlist_as_table_rows(form.media_metadata) }}
- {% trans %}Identifier{% endtrans %}{% trans %}Value{% endtrans %}
+ + + diff --git a/mediagoblin/templates/mediagoblin/utils/wtforms.html b/mediagoblin/templates/mediagoblin/utils/wtforms.html index e861b674..c83d53f1 100644 --- a/mediagoblin/templates/mediagoblin/utils/wtforms.html +++ b/mediagoblin/templates/mediagoblin/utils/wtforms.html @@ -70,26 +70,14 @@ {# Auto-render a form as a table #} {% macro render_table(form) -%} {% for field in form %} - - - - + render_field_as_table_row(field) {% endfor %} {%- endmacro %} -{% macro render_table_row(form) %} +{% macro render_form_as_table_row(form) %} {%- for field in form %} + {%- endmacro %} +{% macro render_field_as_table_row(field) %} + + + + +{% 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) %}
-- 2.25.1
{{ field.label.text }} - {{field}} - {% if field.errors %} -
-
    - {% for error in field.errors %} -
  • {{error}}
  • - {% endfor %} -
- {% endif %} -
{{ render_label_p(field) }} {{field}} {%- if field.errors -%} @@ -105,6 +93,33 @@
{{ field.label.text }} + {{field}} + {% if field.errors %} +
+
    + {% for error in field.errors %} +
  • {{error}}
  • + {% endfor %} +
+ {% endif %} +