<%inherit file="/template.html" /> <%namespace name="tiles" file="/badge/tiles.html"/> <%namespace name="components" file="/components.html"/> <%def name="title()">${_("Badges")} <%def name="breadcrumbs()"> ${h.badge.breadcrumbs(None)|n} <%def name="edit_button(base_url, badge_id, is_global)"> %if (is_global and can.badge.edit_global()) or (not is_global and can.badge.edit_instance()): ${_('Edit')} %endif <%def name="delete_button(base_url, badge_id, is_global)"> %if (is_global and can.badge.manage_global()) or (not is_global and can.badge.manage_instance()): ${_('Delete')} %endif <%def name="new_button(base_url, type_, is_global)"> %if (is_global and can.badge.manage_global()) or (not is_global and can.badge.manage_instance()): ${_("New")} %endif <%def name="render_table(badges, base_url, type_, show_header, is_global)"> %if badges is not None: <% table_def = { 'user': user_badges_table, 'delegateable': delegateable_badges_table, 'category': category_badges_table, 'thumbnail': thumbnail_badges_table, 'instance': instance_badges_table, }.get(type_) %> %if show_header:
${_(u'In all instances') if is_global else _(u'In instance "%s"') % c.instance.label}${new_button(c.badge_base_url, type_, is_global)}
%endif %if badges: ${table_def(base_url, badges)} %else:

${_("No badges added yet.")}

%endif %endif <%def name="render_context_tables()"> ${render_tables(c.global_badges, c.instance_badges, c.badge_base_url, c.badge_header, c.badge_type)} <%def name="render_tables(global_badges, instance_badges, base_url, title, type_)"> <% single_table = global_badges is None or instance_badges is None %>

${title} %if single_table: %if global_badges is not None: ${new_button(base_url, type_, True)} %elif instance_badges is not None: ${new_button(base_url, type_, False)} %endif %endif

%if type_ == 'user':

${_("User badges allow you to organize your members according to certain groups.")}

%elif type_ == 'delegateable':

${_("Proposal badges may be used to link different attributes to a proposal (e.g. official, first phase, etc.).")}

%elif type_ == 'category':

${_("Add new categories to allow your users to categorize their proposals according to a topic.")}

%elif type_ == 'thumbnail':

${_("Status badges may be used to indicate different statuses of proposals in your participation process (e.g. accepted, rejected, in discussion, etc.) with an image.")}

%endif ${render_table(global_badges, base_url, type_, not single_table, True)} ${render_table(instance_badges, base_url, type_, not single_table, False)} <%def name="user_badges_table(base_url, badge_items)"> %for badge in badge_items: %endfor
${_("Title")} ${_("Description")} ${_("Preview")} ${_("Assigned Group")} ${_("Display")} ${_("Actions")}
${badge.title} ${badge.description and (badge.description[:20] + u'...') or ''} ${tiles.badge(badge)} ${badge.group and _(badge.group.group_name) or ""} ${badge.display_group and _("yes") or _("no")} ${edit_button(base_url, badge.id, badge.instance is None)} ${delete_button(base_url, badge.id, badge.instance is None)}
<%def name="delegateable_badges_table(base_url, badge_items)"> %for badge in badge_items: %endfor
${_("Title")} ${_("Description")} ${_("Preview")} ${_("Impact")} ${_("Actions")}
${badge.title} ${badge.description and (badge.description[:20] + u'...') or ''} ${tiles.badge(badge)} ${badge.impact} ${edit_button(base_url, badge.id, badge.instance is None)} ${delete_button(base_url, badge.id, badge.instance is None)}
<%def name="instance_badges_table(base_url, badge_items)"> %for badge in badge_items: %endfor
${_("Title")} ${_("Description")} ${_("Preview")} ${_("Actions")}
${badge.title} ${badge.description and (badge.description[:20] + u'...') or ''} ${tiles.badge(badge)} ${edit_button(base_url, badge.id, badge.instance is None)} ${delete_button(base_url, badge.id, badge.instance is None)}
<%def name="category_badges_table(base_url, badge_items)"> %for badge in badge_items: %endfor
${_("Title")} ${_("Description")} ${_("Preview")} ${_("Impact")} ${_("Parent")} ${_("Actions")}
${badge.title} ${badge.description and (badge.description[:20] + u'...') or ''} ${tiles.badge(badge)} ${badge.impact} ${badge.parent.title if badge.parent else ""} ${edit_button(base_url, badge.id, badge.instance is None)} ${delete_button(base_url, badge.id, badge.instance is None)}
<%def name="thumbnail_badges_table(base_url, badge_items)"> %for badge in badge_items: %endfor
${_("Title")} ${_("Description")} ${_("Preview")} ${_("Impact")} ${_("Actions")}
${badge.title} ${(badge.description[:20] + u'...' if len(badge.description) > 20 else badge.description) if badge.description else u''} ${tiles.badge(badge)} ${badge.impact} ${edit_button(base_url, badge.id, badge.instance is None)} ${delete_button(base_url, badge.id, badge.instance is None)}
<%block name="main_content"> ${components.flashmessages()} ${render_context_tables()}