From cde7a07d5ef576f50d86ba91a152f6fd434bd95d Mon Sep 17 00:00:00 2001 From: Elrond Date: Fri, 22 Feb 2013 14:19:19 +0100 Subject: [PATCH] Create wtforms_util.render_label(_p) and use it around. - This makes many places more readable. - Gives us translation in two places. - Allows easier changing of labels in a central place. --- .../mediagoblin/edit/edit_account.html | 4 ++-- .../user_pages/collection_confirm_delete.html | 2 +- .../collection_item_confirm_remove.html | 2 +- .../mediagoblin/user_pages/media_collect.html | 4 +--- .../user_pages/media_confirm_delete.html | 2 +- .../templates/mediagoblin/utils/wtforms.html | 20 ++++++++++++++++--- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/mediagoblin/templates/mediagoblin/edit/edit_account.html b/mediagoblin/templates/mediagoblin/edit/edit_account.html index 4b980301..3f508af4 100644 --- a/mediagoblin/templates/mediagoblin/edit/edit_account.html +++ b/mediagoblin/templates/mediagoblin/edit/edit_account.html @@ -45,11 +45,11 @@ {{ wtforms_util.render_field_div(form.new_password) }}

{{ form.wants_comment_notification }} - {{ form.wants_comment_notification.label }}

+ {{ wtforms_util.render_label(form.wants_comment_notification) }}

{{ form.license_preference }} - {{ form.license_preference.label }}

+ {{ wtforms_util.render_label(form.license_preference) }}

diff --git a/mediagoblin/templates/mediagoblin/user_pages/collection_confirm_delete.html b/mediagoblin/templates/mediagoblin/user_pages/collection_confirm_delete.html index 7499c0cf..2b790584 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/collection_confirm_delete.html +++ b/mediagoblin/templates/mediagoblin/user_pages/collection_confirm_delete.html @@ -36,7 +36,7 @@

{{ form.confirm }} - + {{ wtforms_util.render_label(form.confirm) }}

diff --git a/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html b/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html index 447201cd..449cc3ce 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html +++ b/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html @@ -42,7 +42,7 @@

{{ form.confirm }} - + {{ wtforms_util.render_label(form.confirm) }}

diff --git a/mediagoblin/templates/mediagoblin/user_pages/media_collect.html b/mediagoblin/templates/mediagoblin/user_pages/media_collect.html index 159eeeb4..0fa0a9f4 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media_collect.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media_collect.html @@ -48,9 +48,7 @@
-

- -

+ {{- wtforms_util.render_label_p(form.collection) }}
{{ form.collection }} {% trans %}+{% endtrans %} diff --git a/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html b/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html index d2a5655e..1d7dcc17 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html @@ -40,7 +40,7 @@

{{ form.confirm }} - + {{ wtforms_util.render_label(form.confirm) }}

diff --git a/mediagoblin/templates/mediagoblin/utils/wtforms.html b/mediagoblin/templates/mediagoblin/utils/wtforms.html index df2354ed..35b4aa04 100644 --- a/mediagoblin/templates/mediagoblin/utils/wtforms.html +++ b/mediagoblin/templates/mediagoblin/utils/wtforms.html @@ -16,11 +16,25 @@ # along with this program. If not, see . #} +{# Render the label for a field #} +{% macro render_label(field) %} + {%- if field.label.text -%} + + {%- endif -%} +{%- endmacro %} + +{# Render the label in a

for a field #} +{% macro render_label_p(field) %} + {%- if field.label.text %} +

+ {{- render_label(field) -}} +

+ {%- endif %} +{%- endmacro %} + {# Generically render a field #} {% macro render_field_div(field) %} - {% if field.label.text -%} -

- {%- endif %} + {{- render_label_p(field) }}
{{ field }} {%- if field.errors -%} -- 2.25.1