From: Elrond Date: Fri, 22 Feb 2013 13:19:19 +0000 (+0100) Subject: Create wtforms_util.render_label(_p) and use it around. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cde7a07d5ef576f50d86ba91a152f6fd434bd95d;p=mediagoblin.git 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. --- 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 -%}