Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

moving tags box into its own helper

  • Loading branch information...
commit 0bdd1287494decb4e271ce8801a12b368f3bfbe0 1 parent bd4248b
@fwenzel fwenzel authored
View
14 apps/addons/helpers.py
@@ -102,3 +102,17 @@ def review_add_box(context, addon):
c = dict(context.items())
c['addon'] = addon
return c
+
+
+@register.inclusion_tag('addons/tags_box.html')
+@jinja2.contextfunction
+def tags_box(context, addon, dev_tags, user_tags):
+ """
+ Details page: Show a box with existing tags along with a form to add new
+ ones.
+ """
+ c = dict(context.items())
+ c.update({'addon': addon,
+ 'dev_tags': dev_tags,
+ 'user_tags': user_tags})
+ return c
View
35 apps/addons/templates/addons/details.html
@@ -369,40 +369,7 @@ <h3 class="compact-bottom">{{ _('Need help with this add-on?') }}</h3>
{% endif %}
{# /support #}
- {# tags #}
- <div class="clearboth">
- <h3 class="compact-bottom">{{ _('Tags', 'tags_header_tags_title') }}</h3>
-
- <div id="tags">
- {{ tag_list(addon, dev_tags=dev_tags, user_tags=user_tags) }}
- </div>
-
- {% if user.is_authenticated() %}
- <a href="#" id="addatag">{{ _('Add a tag') }}</a>
- <div class="addtagform">
- <form id="tagForm" action="{{ remora_url('/tags/add/') }}"
- method="post">{# TODO reverse URL #}
- {{ cake_csrf_token() }}
- <input type="text" id="newTag" name="newTag"/>
- <input type="hidden" name="addonid" id="addtagformaddonid" value="{{ addon.id }}"/>
- <button id="addtagbutton">{{ _('Add', 'tags_add_tag_button') }}</button>
- </form>
- <span class="hint">
- {% trans %}
- Comma-separated, minimum of 2 characters. Example:
- <span class="example">ocean, sail boat, water</span>
- {% endtrans %}
- </span>
- </div>
- {% else %}
- {% trans register='/users/register', login='/users/login' %}
- {# TODO reverse URL #}
- <a href="{{ register }}">Register</a> or
- <a href="{{ login }}">Log in</a> to add tags
- {% endtrans %}
- {% endif %}
- </div>
- {# /tags #}
+ {{ tags_box(addon=addon, dev_tags=dev_tags, user_tags=user_tags) }}
{# addon recommendations #}
{% if recommendations %}
View
32 apps/addons/templates/addons/tags_box.html
@@ -0,0 +1,32 @@
+<div class="clearboth">
+ <h3 class="compact-bottom">{{ _('Tags', 'tags_header_tags_title') }}</h3>
+
+ <div id="tags">
+ {{ tag_list(addon, dev_tags=dev_tags, user_tags=user_tags) }}
+ </div>
+
+ {% if user.is_authenticated() %}
+ <a href="#" id="addatag">{{ _('Add a tag') }}</a>
+ <div class="addtagform">
+ <form id="tagForm" action="{{ remora_url('/tags/add/') }}"
+ method="post">{# TODO reverse URL #}
+ {{ cake_csrf_token() }}
+ <input type="text" id="newTag" name="newTag"/>
+ <input type="hidden" name="addonid" id="addtagformaddonid" value="{{ addon.id }}"/>
+ <button id="addtagbutton">{{ _('Add', 'tags_add_tag_button') }}</button>
+ </form>
+ <span class="hint">
+ {% trans %}
+ Comma-separated, minimum of 2 characters. Example:
+ <span class="example">ocean, sail boat, water</span>
+ {% endtrans %}
+ </span>
+ </div>
+ {% else %}
+ {% trans register='/users/register', login='/users/login' %}
+ {# TODO reverse URL #}
+ <a href="{{ register }}">Register</a> or
+ <a href="{{ login }}">Log in</a> to add tags
+ {% endtrans %}
+ {% endif %}
+</div>
Please sign in to comment.
Something went wrong with that request. Please try again.