Changeset - 0f9a48e0adc3
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 11 years ago 2015-03-03 21:44:27
thomas.de.schampheleire@gmail.com
pullrequest overview: create overview from a function to allow re-use

In anticipation of re-use of the pullrequest overview, create a def to
generate this overview given a list of pullrequests.

This also adds a check if the given list is empty, and a check if there is a
pager before displaying the paging links.
1 file changed with 15 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/templates/pullrequests/pullrequest_data.html
Show inline comments
 
## -*- coding: utf-8 -*-
 

	
 
<%def name="pullrequest_overview(pullrequests)">
 

	
 
%if not len(pullrequests):
 
    <div class="normal-indent empty_data">${_('No entries')}</div>
 
    <% return %>
 
%endif
 

	
 
<div class="table">
 
  <table>
 
    <thead>
 
      <tr>
 
        <th></th>
 
        <th class="left">${_('Title')}</th>
 
        <th class="left">${_('Author')}</th>
 
        <th class="left">${_('Date')}</th>
 
        <th class="left">${_('From')}</th>
 
        <th class="left">${_('To')}</th>
 
      </tr>
 
    </thead>
 
% for pr in c.pullrequests_pager:
 
% for pr in pullrequests:
 
    <tr class="${'pr-closed' if pr.is_closed() else ''}">
 
      <td>
 
        %if pr.last_review_status:
 
          <i class="icon-circle changeset-status-${pr.last_review_status}" title="${_("Someone voted: %s") % pr.last_review_status}"></i>
 
        %else:
 
          <i class="icon-circle changeset-status-not_reviewed" title="${_("Nobody voted")}"></i>
 
        %endif
 
      </td>
 
      <td>
 
        <a href="${pr.url()}">
 
        ${pr.title or _("(no title)")}
 
        %if pr.is_closed():
 
          <span class="pr-closed-tag">${_('Closed')}</span>
 
        %endif
 
        </a>
 
      </td>
 
      <td>
 
        ${pr.author.username_and_name}
 
      </td>
 
      <td>
 
        ${h.fmt_date(pr.created_on)}
 
      </td>
 
      <td>
 
        <% org_ref_name=pr.org_ref.rsplit(':', 2)[-2] %>
 
        <a href="${h.url('summary_home', repo_name=pr.org_repo.repo_name, anchor=org_ref_name)}">
 
          ${pr.org_repo.repo_name}#${org_ref_name}
 
        </a>
 
      </td>
 
      <td>
 
        <% other_ref_name=pr.other_ref.rsplit(':', 2)[-2] %>
 
        <a href="${h.url('summary_home', repo_name=pr.other_repo.repo_name, anchor=other_ref_name)}">
 
          ${pr.other_repo.repo_name}#${other_ref_name}
 
        </a>
 
      </td>
 
    </tr>
 
% endfor
 
  </table>
 
</div>
 

	
 
%if pager in pullrequests:
 
<div class="notification-paginator">
 
  <div class="pagination-wh pagination-left">
 
  ${c.pullrequests_pager.pager('$link_previous ~2~ $link_next', **request.GET.mixed())}
 
  ${pullrequests.pager('$link_previous ~2~ $link_next', **request.GET.mixed())}
 
  </div>
 
</div>
 
%endif
 

	
 
</%def>
 

	
 
${pullrequest_overview(c.pullrequests_pager)}
0 comments (0 inline, 0 general)