<%inherit file="/template.html" />
<%namespace name="components" file="/components.html"/>
<%namespace name="forms" file="/forms.html"/>
<%namespace name="sidebar_defs" file="/sidebar.html"/>

<%def name="title()">${c.category.title|n}</%def>

<%def name="breadcrumbs()">
${h.category.breadcrumbs(c.category)|n}
</%def>



<%block name="headline">
<h2>
    ${c.category.title}
    <div class="utility">
        %if can.badge.edit_instance():
        <a href="${h.base_url('/badge/edit/%i' % c.category.id)}">${_("edit")}</a>
        %endif
    </div>
</h2>
<hr />

<div class="category_body">
    ${h.render(c.category.long_description, safe_mode='adhocracy_config')|n}
</div>

<div class="morelink_header">
    <h3>${_('Proposals')}</h3>

    <% auth = check.proposal.create() %>
    %if auth:
    <a class="more_link"
       title="${_('Introduce a new idea to debate.')}"
       href="${h.base_url('/proposal/new', query_params={'category': c.category.id})}">${_(u"Create new proposal")}</a>
    %elif auth.propose_join():
    <a class="more_link"
       title="${_('Join instance to create a new proposal.')}"
       href="${h.base_url('/proposal/new', query_params={'category': c.category.id})}"
       rel="#overlay-join-button">${_(u"Create new proposal")}</a>
    %elif auth.propose_login():
    <a class="more_link"
       title="${_('Login to create a new proposal.')}"
       href="${h.base_url('/proposal/new', query_params={'category': c.category.id})}"
       rel="#overlay-login-button">${_(u"Create new proposal")}</a>
    %elif auth.propose_validate_email():
    <a class="more_link"
       title="${_('Validate email in order to create a new proposal.')}"
       rel="#overlay-validate-button">${_(u"Create new proposal")}</a>
    %endif
</div>
<hr />
</%block>


<%block name="main_content">
<div class="list_filter" id="proposals-search">
    ${forms.search(name='proposals_q', placeholder=_(u'Find proposals'), value=request.params.get('proposals_q', ''))}
</div>

${c.proposals_pager.render_pager()}

<% auth = check.proposal.create() %>
<div class="list_button" id="new-proposal">
    %if auth:
    <a class="button add ttip"
       title="${_('Introduce a new idea to debate.')}"
       href="${h.base_url('/proposal/new', query_params={'category': c.category.id})}">${_(u"new proposal")}</a>
    %elif auth.propose_join():
    <a class="button add ttip"
       title="${_('Join instance to create a new proposal.')}"
       href="${h.base_url('/proposal/new', query_params={'category': c.category.id})}"
       rel="#overlay-join-button">${_(u"new proposal")}</a>
    %elif auth.propose_login():
    <a class="button add ttip"
       title="${_('Login to create a new proposal.')}"
       href="${h.base_url('/proposal/new', query_params={'category': c.category.id})}"
       rel="#overlay-login-button">${_(u"new proposal")}</a>
    %elif auth.propose_validate_email():
    <a class="button add ttip"
       title="${_('Validate email in order to create a new proposal.')}"
       rel="#overlay-validate-button">${_(u"new proposal")}</a>
    %endif
</div>
</%block>

<%block name="sidebar">
${c.proposals_pager.render_facets(cls='sidebar_box', exclude=['delegateablebadgecategory'])}

%if c.instance.use_norms:
<div class="sidebar_box">
    <h3>${_("Norms in this Category")}</h3>

    ${c.pages_pager.render_pager()}
</div>
%endif
</%block>
