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

<%def name="title()">${_("Home")}</%def>

<%def name="breadcrumbs()">
    ${h.instance.breadcrumbs(c.page_instance)|n} ${h.url.link(_("Overview"), h.entity_url(c.page_instance))|n}
</%def>


<%block name="main_content">

<div class="instance_description">
    ${c.tile.description|n}
</div>

%for type in h.config.get_list('adhocracy.instance_overview_contents'):

%if type == u'proposals' and c.page_instance.show_proposals_navigation:
<hr />
<div id="new_proposals_table" class="table">
    %if not h.config.get_bool('adhocracy.show_instance_overview_proposals_all'):
    <h3 class="section">${_("Newest Proposals")}</h3>
    %endif
    ${c.proposals_pager.here()}

    <div id="proposal-actions" class="list_button">
        <% auth = check.proposal.create() %>
        %if auth:
        <a class="button add ttip"
           title="${_('Introduce a new idea to debate.')}"
           href="${h.base_url('/proposal/new')}">${_("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')}" rel="#overlay-join-button">${_("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')}" rel="#overlay-login-button">${_("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">${_("new proposal")}</a>
        %endif

        %if not h.config.get_bool('adhocracy.show_instance_overview_proposals_all'):
        <a href="${h.base_url('/proposal')}"
           class="button edit ttip"
           title="${_('show a list of proposals')}">${_("more proposals")}</a>
        %endif
    </div>

</div>
%endif

%if type == u'milestones' and c.page_instance.milestones:
<hr />
%if h.config.get_int('adhocracy.number_instance_overview_milestones') == 1:
<h3 class="section">${_("Next milestone")}</h3>
%else:
<h3 class="section">${_("Next milestones")}</h3>
%endif
${c.next_milestones_pager.here()}
%endif

%if type == u'events':
<hr />
<h3>${_('Newest Events')}</h3>
${c.events_pager.here()}
%endif

%endfor
</%block>

<%block name="sidebar">
${components.message_button(c.instance)}
%if h.has_permission("watch.instance"):
${components.watch(c.instance)}
%endif

%for type in h.config.get_list('adhocracy.instance_overview_sidebar_contents'):
<div class="sidebar_box">
    %if type == u'events':
    <h3>${_('Newest Events')}</h3>
    ${c.sidebar_events_pager.here()}
    %endif
</div>
%endfor

<div class="sidebar_box">
    <h3 id="information">${_('Information')}</h3>
    <div class="summary">
        %if h.config.get_bool('adhocracy.show_instance_creators'):
        <h6>${_('Created')}</h6>
        <p>${_("by %s on %s") % (h.user.link(c.instance.creator), h.date_tag(c.instance.create_time))|n}</p>
        %endif

        <h6>${_('Votings')}</h6>
        <p>${c.sidebar_delegations}</p>

        %if c.stats is not None:
        <h6>${_('By the numbers')}</h6>
        <ul class="nobullet">
            <li>${_("<b>%s</b> community members") % c.stats.get('members')|n}</li>
            %if c.instance.show_proposals_navigation:
            <li>${_("<b>%s</b> proposals") % c.stats.get('proposals')|n}</li>
            %endif
            <li>${_("<b>%s</b> comments") % c.stats.get('comments')|n}</li>
        </ul>
        %endif

    </div>
</div>
</%block>

<%components:tutorial>
<ol id="joyRideTipContent">
    <li data-id="new_proposals_table"
        data-tip-location="top left">
        <p>${_('tutorial_instance_proposals_table')|n}</p>
    </li>
    <li data-id="proposal-actions"
        data-tip-location="top left">
        <p>${_('tutorial_instance_proposal_button')|n}</p>
    </li>
    <li data-id="information"
        data-tip-location="top left"
        data-next="${_('Close')}">
        <p>${_('tutorial_instance_numbers')}</p>
    </li>
</ol>
</%components:tutorial>
