Changeset - b262e349a7a5
[Not reviewed]
codereview
0 5 1
Marcin Kuzminski - 13 years ago 2012-06-06 01:07:48
marcin@python-works.com
created pull-request overview
6 files changed with 177 insertions and 33 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/compare.py
Show inline comments
 
@@ -120,7 +120,8 @@ class CompareController(BaseRepoControll
 

	
 
        c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in
 
                                                   c.cs_ranges])
 

	
 
        if request.environ.get('HTTP_X_PARTIAL_XHR'):
 
            return render('compare/compare_cs.html')
 

	
 
        c.org_ref = org_ref[1]
 
        c.other_ref = other_ref[1]
rhodecode/controllers/pullrequests.py
Show inline comments
 
@@ -31,7 +31,7 @@ from pylons.i18n.translation import _
 

	
 
from rhodecode.lib.base import BaseRepoController, render
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from webob.exc import HTTPNotFound
 
from rhodecode.model.db import User
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -47,9 +47,12 @@ class PullrequestsController(BaseRepoCon
 
    def _get_repo_refs(self,repo):
 
        hist_l = []
 

	
 
        branches_group = ([(k, k) for k in repo.branches.keys()], _("Branches"))
 
        bookmarks_group = ([(k, k) for k in repo.bookmarks.keys()], _("Bookmarks"))
 
        tags_group = ([(k, k) for k in repo.tags.keys()], _("Tags"))
 
        branches_group = ([('branch:' + k, k) for k in repo.branches.keys()],
 
                          _("Branches"))
 
        bookmarks_group = ([('book:' + k, k) for k in repo.bookmarks.keys()],
 
                           _("Bookmarks"))
 
        tags_group = ([('tag:' + k, k) for k in repo.tags.keys()],
 
                      _("Tags"))
 

	
 
        hist_l.append(bookmarks_group)
 
        hist_l.append(branches_group)
 
@@ -58,8 +61,30 @@ class PullrequestsController(BaseRepoCon
 
        return hist_l
 

	
 
    def index(self):
 
        org_repo = c.rhodecode_db_repo
 
        c.org_refs = self._get_repo_refs(c.rhodecode_repo)
 
        c.sources = []
 
        c.sources.append('%s/%s' % (c.rhodecode_db_repo.user.username,
 
                                    c.repo_name))
 
        c.org_repos = []
 
        c.other_repos = []
 
        c.org_repos.append((org_repo.repo_name, '%s/%s' % (
 
                                org_repo.user.username, c.repo_name))
 
                           )
 

	
 
        c.other_refs = c.org_refs
 
        c.other_repos.extend(c.org_repos)
 

	
 
        #gather forks and add to this list
 
        for fork in org_repo.forks:
 
            c.other_repos.append((fork.repo_name, '%s/%s' % (
 
                                    fork.user.username, fork.repo_name))
 
                                 )
 
        #add parents of this fork also
 
        c.other_repos.append((org_repo.parent.repo_name, '%s/%s' % (
 
                                    org_repo.parent.user.username, 
 
                                    org_repo.parent.repo_name))
 
                                 )
 

	
 
        #TODO: maybe the owner should be default ?
 
        c.review_members = []
 
        c.available_members = [(x.user_id, x.username) for x in
 
                        User.query().filter(User.username != 'default').all()]
 
        return render('/pullrequests/pullrequest.html')
rhodecode/model/db.py
Show inline comments
 
@@ -603,6 +603,20 @@ class Repository(Base, BaseModel):
 
        return q.one().ui_value
 

	
 
    @property
 
    def forks(self):
 
        """
 
        Return forks of this repo
 
        """
 
        return Repository.get_repo_forks(self.repo_id)
 

	
 
    @property
 
    def parent(self):
 
        """
 
        Returns fork parent
 
        """
 
        return self.fork
 

	
 
    @property
 
    def just_name(self):
 
        return self.repo_name.split(Repository.url_sep())[-1]
 

	
rhodecode/templates/compare/compare_cs.html
Show inline comments
 
new file 100644
 
## Changesets table !
 
<div class="container">
 
  <table class="compare_view_commits noborder">
 
  %if not c.cs_ranges:
 
    <tr><td>${_('No changesets')}</td></tr>
 
  %else:
 
    %for cnt, cs in enumerate(c.cs_ranges):
 
        <tr>
 
        <td><div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(h.email(cs.author),14)}"/></div></td>
 
        <td>
 
          %if cs.raw_id in c.statuses:
 
            <div title="${c.statuses[cs.raw_id][1]}" class="changeset-status-ico"><img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses[cs.raw_id][0])}" /></div>
 
          %endif
 
        </td>                
 
        <td>${h.link_to('r%s:%s' % (cs.revision,h.short_id(cs.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}</td>
 
        <td><div class="author">${h.person(cs.author)}</div></td>
 
        <td><span class="tooltip" title="${h.age(cs.date)}">${cs.date}</span></td>
 
        <td><div class="message">${h.urlify_commit(h.wrap_paragraphs(cs.message),c.repo_name)}</div></td>
 
        </tr>
 
    %endfor
 
  %endif
 
  </table>
 
</div>
 
\ No newline at end of file
rhodecode/templates/compare/compare_diff.html
Show inline comments
 
@@ -33,24 +33,11 @@
 
            </div>
 
        </div>
 
        <div id="changeset_compare_view_content">
 
            <div class="container">
 
            <table class="compare_view_commits noborder">
 
            %for cnt, cs in enumerate(c.cs_ranges):
 
                <tr>
 
                <td><div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(h.email(cs.author),14)}"/></div></td>
 
                <td>
 
                  %if cs.raw_id in c.statuses:
 
                    <div title="${c.statuses[cs.raw_id][1]}" class="changeset-status-ico"><img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses[cs.raw_id][0])}" /></div>
 
                  %endif
 
                </td>                
 
                <td>${h.link_to('r%s:%s' % (cs.revision,h.short_id(cs.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}</td>
 
                <td><div class="author">${h.person(cs.author)}</div></td>
 
                <td><span class="tooltip" title="${h.age(cs.date)}">${cs.date}</span></td>
 
                <td><div class="message">${h.urlify_commit(h.wrap_paragraphs(cs.message),c.repo_name)}</div></td>
 
                </tr>
 
            %endfor
 
            </table>
 
            </div>
 
            ##CS
 
            <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${_('Changesets')}</div>
 
            <%include file="compare_cs.html" />
 

	
 
            ## FILES
 
            <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${_('Files affected')}</div>
 
            <div class="cs_files">
 
              %for fid, change, f, stat in c.files:              
rhodecode/templates/pullrequests/pullrequest.html
Show inline comments
 
@@ -19,7 +19,8 @@
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
    </div>
 
    <div style="padding:30px">
 
    ${h.form(url('#'),method='put', id='pull_request_form')}
 
    <div style="float:left;padding:30px">
 
        ##ORG
 
        <div style="float:left">
 
            <div class="fork_user">
 
@@ -27,14 +28,14 @@
 
                    <img alt="gravatar" src="${h.gravatar_url(c.rhodecode_db_repo.user.email,24)}"/>
 
                </div>
 
                <span style="font-size: 20px">
 
                ${h.select('other','',['%s/%s' % (c.rhodecode_db_repo.user.username,c.repo_name)])}:${h.select('other_ref','',c.org_refs)}
 
                ${h.select('org_repo','',c.org_repos,class_='refs')}:${h.select('org_ref','',c.org_refs,class_='refs')}
 
                </span>
 
                 <div style="padding:5px 3px 3px 42px;">${c.rhodecode_db_repo.description}</div>
 
            </div>
 
            <div style="clear:both;padding-top: 10px"></div>
 
        </div>
 
          <div style="float:left;font-size:24px;padding:0px 20px">
 
          <img src="${h.url('/images/arrow_right_64.png')}"/>
 
          <img height=32 width=32 src="${h.url('/images/arrow_right_64.png')}"/>
 
          </div>
 
        
 
        ##OTHER, most Probably the PARENT OF THIS FORK
 
@@ -44,16 +45,65 @@
 
                    <img alt="gravatar" src="${h.gravatar_url(c.rhodecode_db_repo.user.email,24)}"/>
 
                </div>
 
                <span style="font-size: 20px">
 
                ${h.select('orther','',c.sources)}:${h.select('other_ref','',c.org_refs)}
 
                ${h.select('other_repo','',c.other_repos,class_='refs')}:${h.select('other_ref','',c.other_refs,class_='refs')}
 
                </span>
 
                 <div style="padding:5px 3px 3px 42px;">${c.rhodecode_db_repo.description}</div>
 
            </div>
 
            <div style="clear:both;padding-top: 10px"></div>
 
        </div>
 
       <div style="float:left;padding:5px 5px 5px 15px">
 
         <span>
 
           <a id="refresh" href="#">
 
             <img class="icon" title="${_('Refresh')}" alt="${_('Refresh')}" src="${h.url('/images/icons/arrow_refresh.png')}"/>
 
             ${_('refresh overview')}
 
           </a>
 
         </span>       
 
     </div>
 
       <div style="clear:both;padding-top: 10px"></div>       
 
       <div style="float:left" id="pull_request_overview">
 
       </div>        
 
     </div>
 
    <div style="float:left; border-left:1px dashed #eee">
 
        <h4>${_('Pull request reviewers')}</h4>
 
        <div id="reviewers" style="padding:0px 0px 0px 15px">
 
        ##TODO: make this nicer :)
 
          <table class="table noborder">
 
                  <tr>
 
                      <td>
 
                          <div>
 
                              <div style="float:left">
 
                                  <div class="text" style="padding: 0px 0px 6px;">${_('Choosen reviewers')}</div>
 
                                  ${h.select('review_members',[x[0] for x in c.review_members],c.review_members,multiple=True,size=8,style="min-width:210px")}
 
                                 <div  id="remove_all_elements" style="cursor:pointer;text-align:center">
 
                                     ${_('Remove all elements')}
 
                                     <img alt="remove" style="vertical-align:text-bottom" src="${h.url('/images/icons/arrow_right.png')}"/>
 
                                 </div>
 
                              </div>
 
                              <div style="float:left;width:20px;padding-top:50px">
 
                                  <img alt="add" id="add_element"
 
                                      style="padding:2px;cursor:pointer"
 
                                      src="${h.url('/images/icons/arrow_left.png')}"/>
 
                                  <br />
 
                                  <img alt="remove" id="remove_element"
 
                                      style="padding:2px;cursor:pointer"
 
                                      src="${h.url('/images/icons/arrow_right.png')}"/>
 
                              </div>
 
                              <div style="float:left">
 
                                   <div class="text" style="padding: 0px 0px 6px;">${_('Available reviewers')}</div>
 
                                   ${h.select('available_members',[],c.available_members,multiple=True,size=8,style="min-width:210px")}
 
                                   <div id="add_all_elements" style="cursor:pointer;text-align:center">
 
                                         <img alt="add" style="vertical-align:text-bottom" src="${h.url('/images/icons/arrow_left.png')}"/>
 
                                          ${_('Add all elements')}
 
                                   </div>
 
                              </div>
 
                          </div>
 
                      </td>
 
                  </tr>
 
          </table>        
 
        </div>
 
    </div> 
 
    <h3>${_('Create new pull request')}</h3>
 
     
 
    <h3>${_('New pull request')} from USER:REF into PARENT:REF</h3>
 
    ${h.form(url('#'),method='put')}
 
    <div class="form">
 
        <!-- fields -->
 

	
 
@@ -85,7 +135,51 @@
 
    </div>
 
    ${h.end_form()}     
 
     
 
     
 
</div>
 

	
 
<script type="text/javascript">
 
  MultiSelectWidget('review_members','available_members','pull_request_form');
 
  
 
  var loadPreview = function(){
 
      var url = "${h.url('compare_url', 
 
          repo_name='org_repo',
 
          org_ref_type='branch', org_ref='org_ref',
 
          other_ref_type='branch', other_ref='other_ref',
 
          repo='other_repo')}";
 
  
 
      var select_refs = YUQ('#pull_request_form select.refs')
 
    
 
      for(var i=0;i<select_refs.length;i++){
 
        var select_ref = select_refs[i];
 
        var select_ref_data = select_ref.value.split(':');
 
        var key = null;
 
        var val = null;
 
        if(select_ref_data.length>1){
 
          key = select_ref.name+"_type";
 
          val = select_ref_data[0];
 
          url = url.replace(key,val);
 
    
 
          key = select_ref.name;
 
          val = select_ref_data[1];
 
          url = url.replace(key,val);
 
    
 
        }else{
 
          key = select_ref.name;
 
          val = select_ref.value;
 
          url = url.replace(key,val);
 
        }
 
      }
 
    
 
      ypjax(url,'pull_request_overview', function(data){})	  
 
  }
 
  YUE.on('refresh','click',function(e){
 
     loadPreview()
 
  })
 
  
 
  //lazy load after 0.5
 
  
 
  setTimeout(loadPreview,500)
 
  
 
</script>
 

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