Changeset - 9d2db665ef31
[Not reviewed]
beta
0 3 1
Marcin Kuzminski - 13 years ago 2013-04-04 22:33:41
marcin@python-works.com
pagination in pull-requests page + UI
4 files changed with 75 insertions and 19 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/pullrequests.py
Show inline comments
 
@@ -29,39 +29,41 @@ import formencode
 
from webob.exc import HTTPNotFound, HTTPForbidden
 
from collections import defaultdict
 
from itertools import groupby
 

	
 
from pylons import request, response, session, tmpl_context as c, url
 
from pylons.controllers.util import abort, redirect
 
from pylons.i18n.translation import _
 

	
 
from rhodecode.lib.compat import json
 
from rhodecode.lib.base import BaseRepoController, render
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator,\
 
    NotAnonymous
 
from rhodecode.lib.helpers import Page
 
from rhodecode.lib import helpers as h
 
from rhodecode.lib import diffs
 
from rhodecode.lib.utils import action_logger, jsonify
 
from rhodecode.lib.vcs.exceptions import EmptyRepositoryError
 
from rhodecode.lib.vcs.backends.base import EmptyChangeset
 
from rhodecode.lib.diffs import LimitedDiffContainer
 
from rhodecode.model.db import User, PullRequest, ChangesetStatus,\
 
    ChangesetComment
 
from rhodecode.model.pull_request import PullRequestModel
 
from rhodecode.model.meta import Session
 
from rhodecode.model.repo import RepoModel
 
from rhodecode.model.comment import ChangesetCommentsModel
 
from rhodecode.model.changeset_status import ChangesetStatusModel
 
from rhodecode.model.forms import PullRequestForm
 
from mercurial import scmutil
 
from rhodecode.lib.utils2 import safe_int
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class PullrequestsController(BaseRepoController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(PullrequestsController, self).__before__()
 
        repo_model = RepoModel()
 
@@ -131,24 +133,33 @@ class PullrequestsController(BaseRepoCon
 
                  ]
 
        return [g for g in groups if g[0]], selected
 

	
 
    def _get_is_allowed_change_status(self, pull_request):
 
        owner = self.rhodecode_user.user_id == pull_request.user_id
 
        reviewer = self.rhodecode_user.user_id in [x.user_id for x in
 
                                                   pull_request.reviewers]
 
        return (self.rhodecode_user.admin or owner or reviewer)
 

	
 
    def show_all(self, repo_name):
 
        c.pull_requests = PullRequestModel().get_all(repo_name)
 
        c.repo_name = repo_name
 
        p = safe_int(request.params.get('page', 1), 1)
 

	
 
        c.pullrequests_pager = Page(c.pull_requests, page=p, items_per_page=10)
 

	
 
        c.pullrequest_data = render('/pullrequests/pullrequest_data.html')
 

	
 
        if request.environ.get('HTTP_X_PARTIAL_XHR'):
 
            return c.pullrequest_data
 

	
 
        return render('/pullrequests/pullrequest_show_all.html')
 

	
 
    @NotAnonymous()
 
    def index(self):
 
        org_repo = c.rhodecode_db_repo
 

	
 
        if org_repo.scm_instance.alias != 'hg':
 
            log.error('Review not available for GIT REPOS')
 
            raise HTTPNotFound
 

	
 
        try:
 
            org_repo.scm_instance.get_changeset()
 
@@ -192,24 +203,25 @@ class PullrequestsController(BaseRepoCon
 
        # gather forks and add to this list ... even though it is rare to
 
        # request forks to pull from their parent
 
        for fork in org_repo.forks:
 
            add_other_repo(fork)
 

	
 
        # add parents of this fork also, but only if it's not empty
 
        if org_repo.parent and org_repo.parent.scm_instance.revisions:
 
            add_other_repo(org_repo.parent)
 
            c.default_other_repo = org_repo.parent.repo_name
 

	
 
        c.default_other_repo_info = other_repos_info[c.default_other_repo]
 
        c.other_repos_info = json.dumps(other_repos_info)
 

	
 
        return render('/pullrequests/pullrequest.html')
 

	
 
    @NotAnonymous()
 
    def create(self, repo_name):
 
        repo = RepoModel()._get_repo(repo_name)
 
        try:
 
            _form = PullRequestForm(repo.repo_id)().to_python(request.POST)
 
        except formencode.Invalid, errors:
 
            log.error(traceback.format_exc())
 
            if errors.error_dict.get('revisions'):
 
                msg = 'Revisions: %s' % errors.error_dict['revisions']
 
            elif errors.error_dict.get('pullrequest_title'):
rhodecode/public/css/style.css
Show inline comments
 
@@ -4559,32 +4559,59 @@ form.comment-inline-form {
 
    margin: 34px 2px 2px 8px
 
}
 

	
 
/****
 
PULL REQUESTS
 
*****/
 
.pullrequests_section_head {
 
    padding: 10px 10px 10px 0px;
 
    font-size: 16px;
 
    font-weight: bold;
 
}
 

	
 
div.closed h4 a,
 
h3.closed,
 
#pullrequests_container li.closed a
 
 {
 
    color: #555;
 
    background: #eee;
 
}
 

	
 
div.pr-title {
 
    font-size: 1.6em;
 
}
 

	
 
div.pr {
 
    border-bottom: 1px solid #DDD;
 
    margin: 0px 20px;
 
    padding: 10px 0px;
 
}
 
div.pr-closed {
 
    background-color: rgba(245,245,245,0.5);
 
}
 

	
 
span.pr-closed-tag {
 
    margin-bottom: 1px;
 
    margin-right: 1px;
 
    padding: 1px 3px;
 
    font-size: 10px;
 
    padding: 1px 3px 1px 3px;
 
    font-size: 10px;
 
    color: #336699;
 
    white-space: nowrap;
 
    -webkit-border-radius: 4px;
 
    border-radius: 4px;
 
    border: 1px solid #d9e8f8;
 
    line-height: 1.5em;
 
}
 

	
 
/****
 
  PERMS
 
*****/
 
#perms .perms_section_head {
 
    padding: 10px 10px 10px 0px;
 
    font-size: 16px;
 
    font-weight: bold;
 
}
 

	
 
#perms .perm_tag {
 
    padding: 1px 3px 1px 3px;
 
    font-size: 10px;
rhodecode/templates/pullrequests/pullrequest_data.html
Show inline comments
 
new file 100644
 
## -*- coding: utf-8 -*-
 

	
 
% for pr in c.pullrequests_pager:
 
  <div class="pr ${'pr-closed' if pr.is_closed() else ''}">
 
    <div class="pr-title">
 
       %if pr.is_closed():
 
         <div style="float:left;margin: -4px 0px;"><span class="pr-closed-tag">${_('Closed')}</span></div>
 
       %endif
 
      <img src="${h.url('/images/icons/flag_status_%s.png' % str(pr.last_review_status))}" />
 
      <a href="${h.url('pullrequest_show',repo_name=c.repo_name,pull_request_id=pr.pull_request_id)}">
 
      ${_('Pull request #%s opened by %s on %s') % (pr.pull_request_id, pr.author.full_name, h.fmt_date(pr.created_on))}
 
      </a>
 
    </div>
 
    <h5 style="border:0px;padding-bottom:0px">${_('Title')}: ${pr.title}</h5>
 
    <div>${pr.description}</div>
 
  </div>
 
% endfor
 

	
 
<div class="pagination-wh pagination-left">
 
<script type="text/javascript">
 
YUE.onDOMReady(function(){
 
    YUE.delegate("pullrequests","click",function(e, matchedEl, container){
 
        ypjax(e.target.href,"pullrequests",function(){
 
            show_more_event();
 
            tooltip_activate();
 
            show_changeset_tooltip();
 
        });
 
        YUE.preventDefault(e);
 
    },'.pager_link');
 
});
 
</script>
 
${c.pullrequests_pager.pager('$link_previous ~2~ $link_next')}
 
</div>
rhodecode/templates/pullrequests/pullrequest_show_all.html
Show inline comments
 
@@ -5,38 +5,22 @@
 
</%def>
 

	
 
<%def name="breadcrumbs_links()">
 
    ${_('Pull requests')}
 
</%def>
 

	
 
<%def name="page_nav()">
 
    ${self.menu('repositories')}
 
</%def>
 

	
 
<%def name="main()">
 
${self.context_bar('showpullrequest')}
 

	
 
<div class="box">
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
    </div>
 

	
 
    %for pr in c.pull_requests:
 
        <div class="${'closed' if pr.is_closed() else ''}">
 
          <h4 style="border:0px;padding:0px">
 
            <img src="${h.url('/images/icons/flag_status_%s.png' % str(pr.last_review_status))}" />
 
            <a href="${h.url('pullrequest_show',repo_name=c.repo_name,pull_request_id=pr.pull_request_id)}">
 
            ${_('Pull request #%s opened by %s on %s') % (pr.pull_request_id, pr.author.full_name, h.fmt_date(pr.created_on))}
 
            </a>
 
            %if pr.is_closed():
 
              (${_('Closed')})
 
            %endif
 
          </h4>
 
          <h5 style="border:0px;padding-bottom:0px">${_('Title')}: ${pr.title}</h5>
 
          <div style="padding:0px 24px">${pr.description}</div>
 
          <div style="border-bottom: 1px solid #DDD;margin:10px 20px;padding-bottom:10px"></div>
 
        </div>
 
    %endfor
 

	
 
    ${c.pullrequest_data}
 
</div>
 

	
 
</%def>
0 comments (0 inline, 0 general)