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

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

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

<%block name="sidebar">
${components.watch(c.milestone)}

<div class="sidebar_box">
    <h3 id="information">${_('Information')}</h3>
    <div class="summary">

        <h6>${_('Created')}</h6>
        <%
        created_msg = _("by %s on %s") % (
            h.user.link(c.milestone.creator),
            h.date_tag(c.milestone.create_time))
        %>
        <p>${created_msg|n}</p>

        %if c.milestone.modify_time is not None:
        <h6>${_('Last Change')}</h6>
        <p>${h.datetime_tag(c.milestone.modify_time)|n}</p>
        %endif

        %if c.milestone.category:
        <h6>${_('Category')}</h6>
        <p>${c.milestone.category.title}</p>
        %endif

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

<%block name="main_content">
<div id="milestone">
    <h2 id="milestone_title">
        <span class="date">
            %if c.milestone.time:
            ${h.date_tag(c.milestone.time, format=u'medium')|n}
            %else:
            ${_(u'(unknown)')}
            %endif
        </span>
        <br />
        ${c.milestone.title}

        <div class="utility">
            %if can.milestone.edit(c.milestone):
            <a href="${h.entity_url(c.milestone, member='edit')}">${_("edit")}</a>
            %endif
            %if can.milestone.delete(c.milestone):
            <a href="${h.entity_url(c.milestone, member='ask_delete')}">${_("delete")}</a>
            %endif
        </div>
    </h2>

    ${c.tile.text|n}

    <hr />

    <% auth = check.proposal.create() %>
    <% url = h.base_url('/proposal/new?milestone=%d' % c.milestone.id) %>
    <div class="morelink_header">
        <h3>${_("Associated Proposals")}</h3>

        %if auth:
            <a class="more_link"
               title="${_('Introduce a new idea to debate.')}"
               href="${url}">${_("Create new proposal")}</a>
        %elif auth.propose_join():
            <a class="more_link"
               title="${_('Join instance to create a new proposal.')}"
               href="${url}"
               rel="#overlay-join-button">${_("Create new proposal")}</a>
        %elif auth.propose_login():
            <a class="more_link"
               title="${_('Login to create a new proposal.')}"
               href="${url}"
               rel="#overlay-login-button">${_("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">${_("Create new proposal")}</a>
        %endif
    </div>
    %if c.show_proposals_pager:
    <div id="proposals_table" class="table">
        ${c.proposals_pager.here()}
    </div>
    %else:
    ${_('No proposals are connected to this milestone')}
    %endif
    <div class="list_button" id="new-proposal">
        %if auth:
            <a class="button add ttip"
               title="${_('Introduce a new idea to debate.')}"
               href="${url}">${_("new proposal")}</a>
        %elif auth.propose_join():
            <a class="button add ttip"
               title="${_('Join instance to create a new proposal.')}"
               href="${url}"
               rel="#overlay-join-button">${_("new proposal")}</a>
        %elif auth.propose_login():
            <a class="button add ttip"
               title="${_('Login to create a new proposal.')}"
               href="${url}"
               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

    </div>

    <hr />

    <div id="associated-norms">
        %if c.instance.use_norms:
        <h3>${_("Associated Norms")}</h3>
        %if c.show_pages_pager:
        <div id="pages_table" class="table" style="padding-bottom: 1em;">
            ${c.pages_pager.here()}
        </div>
        %else:
        ${_('No norms are connected to this milestone')}
        %endif
        %endif
    </div>

<%components:tutorial>
<ol id="joyRideTipContent">
    <li data-id="FIXME: no id"
        data-tip-location="bottom left" class="custom">
        <p>${_('tutorial_milestone_details_follow')}</p>
    </li>

    <li data-id="milestone-description"
        data-tip-location="bottom left" class="custom">
        <p>${_('tutorial_milestone_details_description')}</p>
    </li>

    <li data-id="related-norms"
        data-tip-location="top left" class="custom">
        <p>${_('tutorial_milestone_details_listing')}</p>
    </li>
</ol>
</%components:tutorial>
</div>
</%block>
