Changeset - 1cd0a0c05f42
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 13 years ago 2012-09-19 00:03:43
marcin@python-works.com
swap the select values with revisions dynamically when switching the repos on pull request view
- fix the partial ajax request that should never do redirect
2 files changed with 19 insertions and 7 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/compare.py
Show inline comments
 
@@ -39,6 +39,7 @@ from rhodecode.lib import diffs
 

	
 
from rhodecode.model.db import Repository
 
from rhodecode.model.pull_request import PullRequestModel
 
from webob.exc import HTTPBadRequest
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -51,10 +52,12 @@ class CompareController(BaseRepoControll
 
    def __before__(self):
 
        super(CompareController, self).__before__()
 

	
 
    def __get_cs_or_redirect(self, rev, repo, redirect_after=True):
 
    def __get_cs_or_redirect(self, rev, repo, redirect_after=True,
 
                             partial=False):
 
        """
 
        Safe way to get changeset if error occur it redirects to changeset with
 
        proper message
 
        proper message. If partial is set then don't do redirect raise Exception
 
        instead
 

	
 
        :param rev: revision to fetch
 
        :param repo: repo instance
 
@@ -73,7 +76,9 @@ class CompareController(BaseRepoControll
 
        except RepositoryError, e:
 
            log.error(traceback.format_exc())
 
            h.flash(str(e), category='warning')
 
            redirect(h.url('summary_home', repo_name=repo.repo_name))
 
            if not partial:
 
                redirect(h.url('summary_home', repo_name=repo.repo_name))
 
            raise HTTPBadRequest()
 

	
 
    def index(self, org_ref_type, org_ref, other_ref_type, other_ref):
 

	
 
@@ -97,9 +102,9 @@ class CompareController(BaseRepoControll
 
        if c.org_repo.scm_instance.alias != 'hg':
 
            log.error('Review not available for GIT REPOS')
 
            raise HTTPNotFound
 

	
 
        self.__get_cs_or_redirect(rev=org_ref, repo=org_repo)
 
        self.__get_cs_or_redirect(rev=other_ref, repo=other_repo)
 
        partial = request.environ.get('HTTP_X_PARTIAL_XHR')
 
        self.__get_cs_or_redirect(rev=org_ref, repo=org_repo, partial=partial)
 
        self.__get_cs_or_redirect(rev=other_ref, repo=other_repo, partial=partial)
 

	
 
        c.cs_ranges, discovery_data = PullRequestModel().get_compare_data(
 
                                       org_repo, org_ref, other_repo, other_ref
 
@@ -110,7 +115,7 @@ class CompareController(BaseRepoControll
 
        c.target_repo = c.repo_name
 
        # defines that we need hidden inputs with changesets
 
        c.as_form = request.GET.get('as_form', False)
 
        if request.environ.get('HTTP_X_PARTIAL_XHR'):
 
        if partial:
 
            return render('compare/compare_cs.html')
 

	
 
        c.org_ref = org_ref[1]
rhodecode/templates/pullrequests/pullrequest.html
Show inline comments
 
@@ -135,6 +135,7 @@
 
  PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
 

	
 
  var other_repos_info = ${c.other_repos_info|n};
 
  
 
  var loadPreview = function(){
 
	  YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none');
 
      var url = "${h.url('compare_url',
 
@@ -167,6 +168,12 @@
 
        }
 
      }
 

	
 
      YUE.on('other_repo', 'change', function(e){
 
    	  var repo_name = e.currentTarget.value;
 
    	  // replace the <select> of changed repo
 
    	  YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs'];
 
      });
 
      
 
      ypjax(url,'pull_request_overview', function(data){
 
    	  var sel_box = YUQ('#pull_request_form #other_repo')[0];
 
    	  var repo_name = sel_box.options[sel_box.selectedIndex].value;
0 comments (0 inline, 0 general)