Mercurial > hg > bts-webui
changeset 99:13172027572c draft
bug_tags: add a tag selector templatetag
It correctly marks the current tags as checked.
author | diegoe-guest |
---|---|
date | Wed, 01 Jul 2009 07:41:40 +0000 |
parents | a57274673095 |
children | a7432db23990 |
files | bts_webui/amancay/templates/bug_tags_selector.html bts_webui/amancay/templatetags/bug_tags.py |
diffstat | 2 files changed, 50 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/bts_webui/amancay/templates/bug_tags_selector.html @@ -0,0 +1,15 @@ +{% comment %} vim: set sw=4 ts=4 sts=4 noet: {% endcomment %} + +{% for tag in active_tags %} +{% if tag %} +<div id="tag_checkbox"> + {{ tag }} <input type="checkbox" name="{{ tag }}" value="1" + checked="checked"/> +</div> +{% endif %} +{% endfor %} +{% for tag in all_tags %} +<div id="tag_checkbox"> + {{ tag }} <input type="checkbox" name="{{ tag }}" value="1"/> +</div> +{% endfor %}
new file mode 100644 --- /dev/null +++ b/bts_webui/amancay/templatetags/bug_tags.py @@ -0,0 +1,35 @@ +# vim: set sw=4 ts=4 sts=4 noet: + +TAGS = ('patch', 'wontfix', 'moreinfo', 'unreproducible', 'help', 'pending', 'fixed', 'security', 'upstream', 'confirmed', 'fixed-upstream', 'fixed-in-experimental', 'd-i', 'ipv6', 'lfs', 'l10n', 'potato', 'woody', 'sarge', 'sarge-ignore', 'etch', 'etch-ignore', 'sid', 'experimental') + +from django import template + +register = template.Library() + +def bug_tags_selector(context): + """ + Render tags checkboxes for the current bug. + """ + + bug = context.get('bug_status') + if bug is None: + return None + + active_tags = bug.tags.split(' ') + + all_tags = [t for t in TAGS if t not in active_tags] + + # all_tags could be [''], let's check it's not + if all_tags and all_tags[0] == '': + all_tags = [] + + print active_tags, all_tags + + return { + 'bug': bug, + 'all_tags': all_tags, + 'active_tags': active_tags, + } + +register.inclusion_tag('bug_tags_selector.html', + takes_context=True)(bug_tags_selector)