<div metal:use-macro="request.sdiapi.main_template" i18n:domain="substanced">

  <div metal:fill-slot="main">

    <a href="./@@database" class="btn btn-primary" style="margin-bottom: 20px;" i18n:translate="">Back</a>

    <div class="panel panel-default">
      <div class="panel-heading" i18n:translate="">Unfinished steps</div>
      <div class="panel-body">

        <p tal:condition="not unfinished_steps" i18n:translate="">There are no unfinished steps.</p>

        <table tal:condition="unfinished_steps" class="table table-striped">
          <thead>
            <tr>
              <th i18n:translate="">Step name</th>
              <th i18n:translate="">Action</th>
            </tr>
          </thead>
          <tbody>
            <tr tal:repeat="step unfinished_steps">
              <td>${step[0]}</td>
              <td>
                <form action="./@@database" method="POST">
                  <input type="hidden" value="${request.session.get_csrf_token()}"
                         name="csrf_token"/>
                  <input type="hidden" value="${step[0]}" name="step" />
                  <input type="submit" class="btn btn-primary" i18n:attributes="value"
                         name="evolve_finished" value="Mark as finished"/>
                </form>  
              </td>
            </tr>
          </tbody>
        </table>  
      </div>
    </div>

    <div class="panel panel-default">
      <div class="panel-heading" i18n:translate="">Finished steps</div>
      <div class="panel-body">
        <table class="table table-striped">
          <thead>
            <tr>
              <th i18n:translate="">Step name</th>
              <th i18n:translate="">Applied on</th>
              <th i18n:translate="">Action</th>
            </tr>
          </thead>
          <tbody>
            <tr tal:repeat="step finished_steps">
              <td>${step[1]}</td>
              <td>${format_timestamp(step[0], request.user.timezone)}</td>
              <td>
                <form action="./@@database" method="POST">
                  <input type="hidden" value="${request.session.get_csrf_token()}"
                         name="csrf_token"/>
                  <input type="hidden" value="${step[1]}" name="step" />
                  <input type="submit" class="btn btn-primary" i18n:attributes="value"
                         name="evolve_unfinished" value="Mark as unfinished"/>
                </form>  
              </td>
            </tr>
          </tbody>
        </table>  
      </div>
    </div>
  </div>
</div>
