##// END OF EJS Templates
pull-requests: refactor model for code readability.
marcink -
r2872:c62229b2 default
parent child Browse files
Show More
@@ -868,9 +868,21 b' class RepoPullRequestsView(RepoAppView, '
868 ancestor = source_scm.get_common_ancestor(
868 ancestor = source_scm.get_common_ancestor(
869 source_commit.raw_id, target_commit.raw_id, target_scm)
869 source_commit.raw_id, target_commit.raw_id, target_scm)
870
870
871 # recalculate target ref based on ancestor
871 target_ref_type, target_ref_name, __ = _form['target_ref'].split(':')
872 target_ref_type, target_ref_name, __ = _form['target_ref'].split(':')
872 target_ref = ':'.join((target_ref_type, target_ref_name, ancestor))
873 target_ref = ':'.join((target_ref_type, target_ref_name, ancestor))
873
874
875 get_default_reviewers_data, validate_default_reviewers = \
876 PullRequestModel().get_reviewer_functions()
877
878 # recalculate reviewers logic, to make sure we can validate this
879 reviewer_rules = get_default_reviewers_data(
880 self._rhodecode_db_user, source_db_repo,
881 source_commit, target_db_repo, target_commit)
882
883 given_reviewers = _form['review_members']
884 reviewers = validate_default_reviewers(given_reviewers, reviewer_rules)
885
874 pullrequest_title = _form['pullrequest_title']
886 pullrequest_title = _form['pullrequest_title']
875 title_source_ref = source_ref.split(':', 2)[1]
887 title_source_ref = source_ref.split(':', 2)[1]
876 if not pullrequest_title:
888 if not pullrequest_title:
@@ -882,22 +894,18 b' class RepoPullRequestsView(RepoAppView, '
882
894
883 description = _form['pullrequest_desc']
895 description = _form['pullrequest_desc']
884
896
885 get_default_reviewers_data, validate_default_reviewers = \
886 PullRequestModel().get_reviewer_functions()
887
888 # recalculate reviewers logic, to make sure we can validate this
889 reviewer_rules = get_default_reviewers_data(
890 self._rhodecode_db_user, source_db_repo,
891 source_commit, target_db_repo, target_commit)
892
893 given_reviewers = _form['review_members']
894 reviewers = validate_default_reviewers(given_reviewers, reviewer_rules)
895
896 try:
897 try:
897 pull_request = PullRequestModel().create(
898 pull_request = PullRequestModel().create(
898 self._rhodecode_user.user_id, source_repo, source_ref,
899 created_by=self._rhodecode_user.user_id,
899 target_repo, target_ref, commit_ids, reviewers,
900 source_repo=source_repo,
900 pullrequest_title, description, reviewer_rules,
901 source_ref=source_ref,
902 target_repo=target_repo,
903 target_ref=target_ref,
904 revisions=commit_ids,
905 reviewers=reviewers,
906 title=pullrequest_title,
907 description=description,
908 reviewer_data=reviewer_rules,
901 auth_user=self._rhodecode_user
909 auth_user=self._rhodecode_user
902 )
910 )
903 Session().commit()
911 Session().commit()
General Comments 0
You need to be logged in to leave comments. Login now