##// END OF EJS Templates
review-rules: extend code to support the forbid commit authors.
marcink -
r1787:bb077306 default
parent child Browse files
Show More
@@ -0,0 +1,33 b''
1 import logging
2
3 from sqlalchemy import *
4 from rhodecode.model import meta
5 from rhodecode.lib.dbmigrate.versions import _reset_base, notify
6
7 log = logging.getLogger(__name__)
8
9
10 def upgrade(migrate_engine):
11 """
12 Upgrade operations go here.
13 Don't create your own engine; bind migrate_engine to your metadata
14 """
15 _reset_base(migrate_engine)
16 from rhodecode.lib.dbmigrate.schema import db_4_7_0_1 as db
17
18 repo_review_rule_table = db.RepoReviewRule.__table__
19
20 forbid_commit_author_to_review = Column(
21 "forbid_commit_author_to_review", Boolean(), nullable=True, default=False)
22 forbid_commit_author_to_review.create(table=repo_review_rule_table)
23
24 fixups(db, meta.Session)
25
26
27 def downgrade(migrate_engine):
28 meta = MetaData()
29 meta.bind = migrate_engine
30
31
32 def fixups(models, _SESSION):
33 pass
@@ -51,7 +51,7 b' PYRAMID_SETTINGS = {}'
51 51 EXTENSIONS = {}
52 52
53 53 __version__ = ('.'.join((str(each) for each in VERSION[:3])))
54 __dbversion__ = 77 # defines current db version for migrations
54 __dbversion__ = 78 # defines current db version for migrations
55 55 __platform__ = platform.system()
56 56 __license__ = 'AGPLv3, and Commercial License'
57 57 __author__ = 'RhodeCode GmbH'
@@ -261,8 +261,8 b' class PullrequestsController(BaseRepoCon'
261 261
262 262 # recalculate reviewers logic, to make sure we can validate this
263 263 reviewer_rules = get_default_reviewers_data(
264 c.rhodecode_user, source_db_repo, source_commit, target_db_repo,
265 target_commit)
264 c.rhodecode_user.get_instance(), source_db_repo,
265 source_commit, target_db_repo, target_commit)
266 266
267 267 reviewers = validate_default_reviewers(
268 268 _form['review_members'], reviewer_rules)
@@ -634,13 +634,18 b' class PullrequestsController(BaseRepoCon'
634 634
635 635 c.forbid_adding_reviewers = False
636 636 c.forbid_author_to_review = False
637 c.forbid_commit_author_to_review = False
637 638
638 639 if pull_request_latest.reviewer_data and \
639 640 'rules' in pull_request_latest.reviewer_data:
640 641 rules = pull_request_latest.reviewer_data['rules'] or {}
641 642 try:
642 c.forbid_adding_reviewers = rules.get('forbid_adding_reviewers')
643 c.forbid_author_to_review = rules.get('forbid_author_to_review')
643 c.forbid_adding_reviewers = rules.get(
644 'forbid_adding_reviewers')
645 c.forbid_author_to_review = rules.get(
646 'forbid_author_to_review')
647 c.forbid_commit_author_to_review = rules.get(
648 'forbid_commit_author_to_review')
644 649 except Exception:
645 650 pass
646 651
@@ -3907,6 +3907,7 b' class RepoReviewRule(Base, BaseModel):'
3907 3907
3908 3908 use_authors_for_review = Column("use_authors_for_review", Boolean(), nullable=False, default=False)
3909 3909 forbid_author_to_review = Column("forbid_author_to_review", Boolean(), nullable=False, default=False)
3910 forbid_commit_author_to_review = Column("forbid_commit_author_to_review", Boolean(), nullable=False, default=False)
3910 3911 forbid_adding_reviewers = Column("forbid_adding_reviewers", Boolean(), nullable=False, default=False)
3911 3912
3912 3913 rule_users = relationship('RepoReviewRuleUser')
@@ -175,6 +175,21 b' ReviewersController = function () {'
175 175 _gettext('Author is not allowed to be a reviewer.'))
176 176 )
177 177 }
178 if (data.rules.forbid_commit_author_to_review) {
179
180 if (data.rules_data.forbidden_users) {
181 $.each(data.rules_data.forbidden_users, function(index, member_data) {
182 self.forbidReviewUsers.push(member_data)
183 });
184
185 }
186
187 self.$rulesList.append(
188 self.addRule(
189 _gettext('Commit Authors are not allowed to be a reviewer.'))
190 )
191 }
192
178 193 return self.forbidReviewUsers
179 194 };
180 195
General Comments 0
You need to be logged in to leave comments. Login now