changeset 6231:d1ed15ef8714

model: change ChangesetComment 'user' to 'author' Rename the 'user_id' field to 'author_id' and replace other references to the comment 'user' throughout the model. The database column name 'user_id' remain unchanged for now; a later Alembic script can fix the name of these and other columns to match their Python name.
author Søren Løvborg <sorenl@unity3d.com>
date Wed, 14 Sep 2016 16:27:05 +0200
parents cd6176c0634a
children 90af0cdf02d8
files kallithea/controllers/changeset.py kallithea/controllers/pullrequests.py kallithea/model/comment.py kallithea/model/db.py kallithea/model/pull_request.py
diffstat 5 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/changeset.py	Wed Sep 14 16:24:05 2016 +0200
+++ b/kallithea/controllers/changeset.py	Wed Sep 14 16:27:05 2016 +0200
@@ -180,7 +180,7 @@
     comment = ChangesetCommentsModel().create(
         text=text,
         repo=c.db_repo.repo_id,
-        user=c.authuser.user_id,
+        author=c.authuser.user_id,
         revision=revision,
         pull_request=pull_request_id,
         f_path=f_path,
--- a/kallithea/controllers/pullrequests.py	Wed Sep 14 16:24:05 2016 +0200
+++ b/kallithea/controllers/pullrequests.py	Wed Sep 14 16:27:05 2016 +0200
@@ -474,7 +474,7 @@
         ChangesetCommentsModel().create(
             text=_('Closed, next iteration: %s .') % pull_request.url(canonical=True),
             repo=old_pull_request.other_repo.repo_id,
-            user=c.authuser.user_id,
+            author=c.authuser.user_id,
             pull_request=old_pull_request.pull_request_id,
             closing_pr=True)
         PullRequestModel().close_pull_request(old_pull_request.pull_request_id)
--- a/kallithea/model/comment.py	Wed Sep 14 16:24:05 2016 +0200
+++ b/kallithea/model/comment.py	Wed Sep 14 16:27:05 2016 +0200
@@ -43,7 +43,7 @@
 
 class ChangesetCommentsModel(BaseModel):
 
-    def _get_notification_data(self, repo, comment, user, comment_text,
+    def _get_notification_data(self, repo, comment, author, comment_text,
                                line_no=None, revision=None, pull_request=None,
                                status_change=None, closing_pr=False):
         """
@@ -85,7 +85,7 @@
             recipients += [cs_author]
             email_kwargs = {
                 'status_change': status_change,
-                'cs_comment_user': user.full_name_and_username,
+                'cs_comment_user': author.full_name_and_username,
                 'cs_target_repo': h.canonical_url('summary_home', repo_name=repo.repo_name),
                 'cs_comment_url': comment_url,
                 'cs_url': h.canonical_url('changeset_home', repo_name=repo.repo_name, revision=revision),
@@ -96,7 +96,7 @@
                 'repo_name': repo.repo_name,
                 'short_id': h.short_id(revision),
                 'branch': cs.branch,
-                'comment_username': user.username,
+                'comment_username': author.username,
                 'threading': threading,
             }
         #pull request
@@ -139,7 +139,7 @@
                 'closing_pr': closing_pr,
                 'pr_comment_url': comment_url,
                 'pr_url': pull_request.url(canonical=True),
-                'pr_comment_user': user.full_name_and_username,
+                'pr_comment_user': author.full_name_and_username,
                 'pr_target_repo': h.canonical_url('summary_home',
                                    repo_name=pull_request.other_repo.repo_name),
                 'pr_target_branch': other_ref_name,
@@ -149,13 +149,13 @@
                 'pr_owner': pull_request.owner,
                 'pr_owner_username': pull_request.owner.username,
                 'repo_name': pull_request.other_repo.repo_name,
-                'comment_username': user.username,
+                'comment_username': author.username,
                 'threading': threading,
             }
 
         return subj, body, recipients, notification_type, email_kwargs
 
-    def create(self, text, repo, user, revision=None, pull_request=None,
+    def create(self, text, repo, author, revision=None, pull_request=None,
                f_path=None, line_no=None, status_change=None, closing_pr=False,
                send_email=True):
         """
@@ -169,10 +169,10 @@
             return None
 
         repo = self._get_repo(repo)
-        user = self._get_user(user)
+        author = self._get_user(author)
         comment = ChangesetComment()
         comment.repo = repo
-        comment.author = user
+        comment.author = author
         comment.text = text
         comment.f_path = f_path
         comment.line_no = line_no
@@ -191,7 +191,7 @@
         if send_email:
             (subj, body, recipients, notification_type,
              email_kwargs) = self._get_notification_data(
-                                repo, comment, user,
+                                repo, comment, author,
                                 comment_text=text,
                                 line_no=line_no,
                                 revision=revision,
@@ -201,7 +201,7 @@
             email_kwargs['is_mention'] = False
             # create notification objects, and emails
             NotificationModel().create(
-                created_by=user, subject=subj, body=body,
+                created_by=author, subject=subj, body=body,
                 recipients=recipients, type_=notification_type,
                 email_kwargs=email_kwargs,
             )
@@ -212,7 +212,7 @@
                 subj = _('[Mention]') + ' ' + subj
                 # FIXME: this subject is wrong and unused!
                 NotificationModel().create(
-                    created_by=user, subject=subj, body=body,
+                    created_by=author, subject=subj, body=body,
                     recipients=mention_recipients,
                     type_=notification_type,
                     email_kwargs=email_kwargs
--- a/kallithea/model/db.py	Wed Sep 14 16:24:05 2016 +0200
+++ b/kallithea/model/db.py	Wed Sep 14 16:27:05 2016 +0200
@@ -2212,7 +2212,7 @@
     pull_request_id = Column(Integer(), ForeignKey('pull_requests.pull_request_id'), nullable=True)
     line_no = Column(Unicode(10), nullable=True)
     f_path = Column(Unicode(1000), nullable=True)
-    user_id = Column(Integer(), ForeignKey('users.user_id'), nullable=False)
+    author_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=False)
     text = Column(UnicodeText(), nullable=False)
     created_on = Column(DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
     modified_at = Column(DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
--- a/kallithea/model/pull_request.py	Wed Sep 14 16:24:05 2016 +0200
+++ b/kallithea/model/pull_request.py	Wed Sep 14 16:27:05 2016 +0200
@@ -83,7 +83,7 @@
         comment = ChangesetCommentsModel().create(
             text=u'',
             repo=org_repo,
-            user=new.owner,
+            author=new.owner,
             pull_request=new,
             send_email=False,
             status_change=ChangesetStatus.STATUS_UNDER_REVIEW,