changeset 6321:78a4bbc24b42

db: it should be "PullRequestReviewer" (singular) sed -i 's/\bPullRequestReviewers\b/PullRequestReviewer/g' $(hg files) Just as it's "User", "PullRequest", etc. It's not a collection.
author Søren Løvborg <sorenl@unity3d.com>
date Thu, 27 Oct 2016 18:37:14 +0200
parents 296581686f02
children 02d6a5b63331
files kallithea/controllers/pullrequests.py kallithea/model/db.py kallithea/model/pull_request.py
diffstat 3 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/pullrequests.py	Thu Oct 27 18:33:42 2016 +0200
+++ b/kallithea/controllers/pullrequests.py	Thu Oct 27 18:37:14 2016 +0200
@@ -49,7 +49,7 @@
 from kallithea.lib.vcs.utils import safe_str
 from kallithea.lib.vcs.utils.hgcompat import unionrepo
 from kallithea.model.db import PullRequest, ChangesetStatus, ChangesetComment, \
-    PullRequestReviewers, User
+    PullRequestReviewer, User
 from kallithea.model.pull_request import PullRequestModel
 from kallithea.model.meta import Session
 from kallithea.model.repo import RepoModel
@@ -182,9 +182,9 @@
             return False
 
         owner = self.authuser.user_id == pull_request.owner_id
-        reviewer = PullRequestReviewers.query() \
-            .filter(PullRequestReviewers.pull_request == pull_request) \
-            .filter(PullRequestReviewers.user_id == self.authuser.user_id) \
+        reviewer = PullRequestReviewer.query() \
+            .filter(PullRequestReviewer.pull_request == pull_request) \
+            .filter(PullRequestReviewer.user_id == self.authuser.user_id) \
             .count() != 0
 
         return self.authuser.admin or owner or reviewer
--- a/kallithea/model/db.py	Thu Oct 27 18:33:42 2016 +0200
+++ b/kallithea/model/db.py	Thu Oct 27 18:37:14 2016 +0200
@@ -2330,7 +2330,7 @@
         return self.other_ref.split(':')
 
     owner = relationship('User')
-    reviewers = relationship('PullRequestReviewers',
+    reviewers = relationship('PullRequestReviewer',
                              cascade="all, delete-orphan")
     org_repo = relationship('Repository', primaryjoin='PullRequest.org_repo_id==Repository.repo_id')
     other_repo = relationship('Repository', primaryjoin='PullRequest.other_repo_id==Repository.repo_id')
@@ -2351,7 +2351,7 @@
         q = super(PullRequest, cls).query()
 
         if reviewer_id is not None:
-            q = q.join(PullRequestReviewers).filter(PullRequestReviewers.user_id == reviewer_id)
+            q = q.join(PullRequestReviewer).filter(PullRequestReviewer.user_id == reviewer_id)
 
         if not include_closed:
             q = q.filter(PullRequest.status != PullRequest.STATUS_CLOSED)
@@ -2364,9 +2364,9 @@
     def get_reviewer_users(self):
         """Like .reviewers, but actually returning the users"""
         return User.query() \
-            .join(PullRequestReviewers) \
-            .filter(PullRequestReviewers.pull_request == self) \
-            .order_by(PullRequestReviewers.pull_request_reviewers_id) \
+            .join(PullRequestReviewer) \
+            .filter(PullRequestReviewer.pull_request == self) \
+            .order_by(PullRequestReviewer.pull_request_reviewers_id) \
             .all()
 
     def is_closed(self):
@@ -2411,7 +2411,7 @@
         return h.url('pullrequest_show', repo_name=self.other_repo.repo_name,
                      pull_request_id=self.pull_request_id, **kwargs)
 
-class PullRequestReviewers(Base, BaseDbModel):
+class PullRequestReviewer(Base, BaseDbModel):
     __tablename__ = 'pull_request_reviewers'
     __table_args__ = (
         Index('pull_request_reviewers_user_id_idx', 'user_id'),
--- a/kallithea/model/pull_request.py	Thu Oct 27 18:33:42 2016 +0200
+++ b/kallithea/model/pull_request.py	Thu Oct 27 18:37:14 2016 +0200
@@ -36,7 +36,7 @@
 from kallithea.lib import helpers as h
 from kallithea.lib.exceptions import UserInvalidException
 from kallithea.model.base import BaseModel
-from kallithea.model.db import PullRequest, PullRequestReviewers, Notification, \
+from kallithea.model.db import PullRequest, PullRequestReviewer, Notification, \
     ChangesetStatus, User
 from kallithea.model.notification import NotificationModel
 from kallithea.lib.utils2 import extract_mentioned_users, safe_unicode
@@ -108,7 +108,7 @@
         reviewer_users = set(self._get_valid_reviewers(reviewers))
         #members
         for reviewer in reviewer_users:
-            prr = PullRequestReviewers(reviewer, pr)
+            prr = PullRequestReviewer(reviewer, pr)
             Session().add(prr)
 
         #notification to reviewers
@@ -180,9 +180,9 @@
     def remove_reviewers(self, user, pull_request, reviewer_ids):
         """Remove users in the given user_id list from being reviewers of the PR."""
 
-        PullRequestReviewers.query() \
+        PullRequestReviewer.query() \
             .filter_by(pull_request=pull_request) \
-            .filter(PullRequestReviewers.user_id.in_(reviewer_ids)) \
+            .filter(PullRequestReviewer.user_id.in_(reviewer_ids)) \
             .delete(synchronize_session='fetch') # the default of 'evaluate' is not available
 
     def delete(self, pull_request):