Source

buglink / web / templates / macros.j2

{# -*-HTML-*- #}

{% macro render_pagination(pagination) %}
<div class="pagination pagination-centered">
  <ul>
    <li class="{{ 'disabled' if not pagination.has_prev }}">
      <a {% if pagination.has_prev %}href="{{ url_for_other_page(pagination.page - 1) }}"{% endif %}>
	&laquo;
      </a>
    </li>
    {%- for page in pagination.iter_pages() %}
    {% if page %}
    <li class="{{ 'active' if page == pagination.page }}">
      <a href="{{ url_for_other_page(page) }}">{{ page }}</a>
    </li>
    {% else %}
    <li><span class=ellipsis>&hellip;</span></li>
    {% endif %}
    {%- endfor %}
    <li class="{{ 'disabled' if not pagination.has_next }}">
      <a {% if pagination.has_next %}href="{{ url_for_other_page(pagination.page + 1) }}"{% endif %}>
	&raquo;
      </a>
    </li>
  </ul>
</div>
{% endmacro %}

{% macro render_changesets_for_issue(issue) %}
  <ul>
    {% for group in issue.changesets|groupby('repository') %}
      <li>{{ render_repository(group.grouper) }}<ul>
      {% for changeset in group.list %}
          <li>{{ render_changeset(changeset) }}</li>
      {% endfor %}
      </ul>
    {% endfor %}
  </ul>
{% endmacro %}

{% macro render_repository(repository) %}
  {% set url = url_for_repository(repository) %}
  {% if url %}
    <a href="{{ url }}" class="external">{{repository.path}}</a>
  {% else %}
    {{repository.path}}
  {% endif %}
{% endmacro %}

{% macro render_changeset(changeset) %}
  <tt>
  {% set url = url_for_changeset(changeset) %}
  {% if url %}
    <a href="{{ url }}" class="external">{{changeset.hash}}</a>
  {% else %}
    {{changeset.hash}}
  {% endif %}
  </tt>
{% endmacro %}

{% macro render_issues(minus, plus, annon) %}
{% if plus %}
<div>
  Additionnal Issues solved:
  <ul>
    {% for issue in plus %}
    <li>{{ render_issue(issue) }}</li>
    {% endfor %}
  </ul>
</div>
{% endif %}
{% if minus %}
<div>
  Issues missing:
  <ul>
    {% for issue in minus %}
    <li>{{ render_issue(issue) }}</li>
    {% else %}
    <li>None</li>
    {% endfor %}
  </ul>
</div>
{% endif %}
<p>{{ annon }} changesets without issues.</p>
{% endmacro %}

{% macro render_issue(issue) %}
  <a href="{{ url_for('views.issue', ref=issue.ref) }}">{{issue.ref}}</a>
  {% set url = url_for_issue(issue) %}
  {% if url %}
   (<a href="{{ url }}" class="external">BTS</a>)
  {% endif %}
{% endmacro %}

{% macro render_binary(binary) %}
  {% set url = url_for_binary(binary) %}
  {% if url %}
   <a href="{{ url }}" class="external">{{ binary.module.name }} - {{ binary.build.number }}</a>
  {% else %}
   {{ binary.module.name }} - {{ binary.build.number }}
  {% endif %}
{% endmacro %}

{% macro diff_repo(repopath, repo, optparams) %}
{% set oldch, newch, issuesmin, issuesplus, num_annon = repo %}
{% if oldch != newch %}
<li>
  <h3><a href="{{ url_for('diff.changeset', repo=repopath, old=oldch,
                          new=newch, **optparams) }}">
    {{- repopath -}}
  </a> (<tt>{{ oldch[:12] }}</tt> &rarr; <tt>{{ newch[:12] }}</tt>)</h3>
  {{ render_issues(issuesmin, issuesplus, num_annon) }}
</li>
{% endif %}
{% endmacro %}