changeset 5438:68011c4e6f33

pull requests: call it 'owner' instead of 'author' Prepare for making it possible to transfer ownership of PRs.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 26 Aug 2015 17:28:59 +0200
parents 3f017db297c4
children b9c9216d6fa7
files kallithea/controllers/pullrequests.py kallithea/model/comment.py kallithea/model/db.py kallithea/model/pull_request.py kallithea/templates/changeset/changeset_file_comment.html kallithea/templates/pullrequests/pullrequest_data.html kallithea/templates/pullrequests/pullrequest_show.html
diffstat 7 files changed, 22 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/pullrequests.py	Wed Aug 26 17:28:59 2015 +0200
+++ b/kallithea/controllers/pullrequests.py	Wed Aug 26 17:28:59 2015 +0200
@@ -479,7 +479,7 @@
             raise HTTPForbidden()
         assert pull_request.other_repo.repo_name == repo_name
         #only owner or admin can update it
-        owner = pull_request.author.user_id == c.authuser.user_id
+        owner = pull_request.owner.user_id == c.authuser.user_id
         repo_admin = h.HasRepoPermissionAny('repository.admin')(c.repo_name)
         if not (h.HasPermissionAny('hg.admin') or repo_admin or owner):
             raise HTTPForbidden()
@@ -517,7 +517,7 @@
     def delete(self, repo_name, pull_request_id):
         pull_request = PullRequest.get_or_404(pull_request_id)
         #only owner can delete it !
-        if pull_request.author.user_id == c.authuser.user_id:
+        if pull_request.owner.user_id == c.authuser.user_id:
             PullRequestModel().delete(pull_request)
             Session().commit()
             h.flash(_('Successfully deleted pull request'),
--- a/kallithea/model/comment.py	Wed Aug 26 17:28:59 2015 +0200
+++ b/kallithea/model/comment.py	Wed Aug 26 17:28:59 2015 +0200
@@ -92,7 +92,7 @@
             )
             # get the current participants of this changeset
             recipients = ChangesetComment.get_users(revision=revision)
-            # add changeset author if it's in kallithea system
+            # add changeset author if it's known locally
             cs_author = User.get_from_cs_author(cs.author)
             if not cs_author:
                 #use repo owner if we cannot extract the author correctly
@@ -136,7 +136,7 @@
             recipients = ChangesetComment.get_users(pull_request_id=
                                                 pull_request.pull_request_id)
             # add pull request author
-            recipients += [pull_request.author]
+            recipients += [pull_request.owner]
 
             # add the reviewers to notification
             recipients += [x.user for x in pull_request.reviewers]
--- a/kallithea/model/db.py	Wed Aug 26 17:28:59 2015 +0200
+++ b/kallithea/model/db.py	Wed Aug 26 17:28:59 2015 +0200
@@ -2303,7 +2303,7 @@
     def other_ref_parts(self):
         return self.other_ref.split(':')
 
-    author = relationship('User')
+    owner = relationship('User')
     reviewers = relationship('PullRequestReviewers',
                              cascade="all, delete-orphan")
     org_repo = relationship('Repository', primaryjoin='PullRequest.org_repo_id==Repository.repo_id')
--- a/kallithea/model/pull_request.py	Wed Aug 26 17:28:59 2015 +0200
+++ b/kallithea/model/pull_request.py	Wed Aug 26 17:28:59 2015 +0200
@@ -87,7 +87,7 @@
         new.revisions = revisions
         new.title = title
         new.description = description
-        new.author = created_by_user
+        new.owner = created_by_user
         Session().add(new)
         Session().flush()
 
@@ -96,7 +96,7 @@
         comment = ChangesetCommentsModel().create(
             text=u'',
             repo=org_repo,
-            user=new.author,
+            user=new.owner,
             pull_request=new,
             send_email=False,
             status_change=ChangesetStatus.STATUS_UNDER_REVIEW,
@@ -104,7 +104,7 @@
         ChangesetStatusModel().set_status(
             org_repo,
             ChangesetStatus.STATUS_UNDER_REVIEW,
-            new.author,
+            new.owner,
             comment,
             pull_request=new
         )
@@ -135,7 +135,7 @@
         subject = safe_unicode(
             h.link_to(
               _('%(user)s wants you to review pull request %(pr_nice_id)s: %(pr_title)s') % \
-                {'user': pr.author.username,
+                {'user': pr.owner.username,
                  'pr_title': pr.title,
                  'pr_nice_id': pr.nice_id()},
                 pr_url)
@@ -144,19 +144,19 @@
         _org_ref_type, org_ref_name, _org_rev = pr.org_ref.split(':')
         email_kwargs = {
             'pr_title': pr.title,
-            'pr_user_created': h.person(pr.author),
+            'pr_user_created': h.person(pr.owner),
             'pr_repo_url': h.canonical_url('summary_home', repo_name=pr.other_repo.repo_name),
             'pr_url': pr_url,
             'pr_revisions': revision_data,
             'repo_name': pr.other_repo.repo_name,
             'pr_nice_id': pr.nice_id(),
             'ref': org_ref_name,
-            'pr_username': pr.author.username,
+            'pr_username': pr.owner.username,
             'threading': threading,
             'is_mention': False,
             }
         if reviewers:
-            NotificationModel().create(created_by=pr.author, subject=subject, body=body,
+            NotificationModel().create(created_by=pr.owner, subject=subject, body=body,
                                        recipients=reviewers,
                                        type_=Notification.TYPE_PULL_REQUEST,
                                        email_kwargs=email_kwargs)
@@ -167,8 +167,7 @@
         if mention_recipients:
             email_kwargs['is_mention'] = True
             subject = _('[Mention]') + ' ' + subject
-
-            NotificationModel().create(created_by=pr.author, subject=subject, body=body,
+            NotificationModel().create(created_by=pr.owner, subject=subject, body=body,
                                        recipients=mention_recipients,
                                        type_=Notification.TYPE_PULL_REQUEST,
                                        email_kwargs=email_kwargs)
--- a/kallithea/templates/changeset/changeset_file_comment.html	Wed Aug 26 17:28:59 2015 +0200
+++ b/kallithea/templates/changeset/changeset_file_comment.html	Wed Aug 26 17:28:59 2015 +0200
@@ -171,7 +171,7 @@
 
                 %if is_pr and ( \
                     h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) \
-                    or c.pull_request.author.user_id == c.authuser.user_id):
+                    or c.pull_request.owner.user_id == c.authuser.user_id):
                   <input id="save_close" type="checkbox" name="save_close">
                   <label id="save_close_label" for="save_close">${_("Close")}</label>
                 %endif
--- a/kallithea/templates/pullrequests/pullrequest_data.html	Wed Aug 26 17:28:59 2015 +0200
+++ b/kallithea/templates/pullrequests/pullrequest_data.html	Wed Aug 26 17:28:59 2015 +0200
@@ -13,7 +13,7 @@
       <tr>
         <th class="left">${_('Vote')}</th>
         <th class="left">${_('Title')}</th>
-        <th class="left">${_('Author')}</th>
+        <th class="left">${_('Owner')}</th>
         <th class="left">${_('Age')}</th>
         <th class="left">${_('From')}</th>
         <th class="left">${_('To')}</th>
@@ -39,7 +39,7 @@
         </a>
       </td>
       <td>
-        ${pr.author.full_name_and_username}
+        ${pr.owner.full_name_and_username}
       </td>
       <td>
         <span class="tooltip" title="${h.fmt_date(pr.created_on)}">
@@ -59,7 +59,7 @@
         </a>
       </td>
       <td style="text-align:right">
-        %if pr.author.user_id == c.authuser.user_id:
+        %if pr.owner.user_id == c.authuser.user_id:
           ${h.form(url('pullrequest_delete', repo_name=pr.other_repo.repo_name, pull_request_id=pr.pull_request_id),method='delete', style="display:inline-block")}
           <button class="action_button"
                   id="remove_${pr.pull_request_id}"
--- a/kallithea/templates/pullrequests/pullrequest_show.html	Wed Aug 26 17:28:59 2015 +0200
+++ b/kallithea/templates/pullrequests/pullrequest_show.html	Wed Aug 26 17:28:59 2015 +0200
@@ -15,7 +15,7 @@
 </%block>
 
 <%def name="main()">
-<% editable = not c.pull_request.is_closed() and (h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or c.pull_request.author.user_id == c.authuser.user_id) %>
+<% editable = not c.pull_request.is_closed() and (h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or c.pull_request.owner.user_id == c.authuser.user_id) %>
 ${self.repo_context_bar('showpullrequest')}
 <div class="box">
   <!-- box / title -->
@@ -151,16 +151,14 @@
         </div>
         <div class="field">
           <div class="label-summary">
-              <label>${_('Created by')}:</label>
+              <label>${_('Owner')}:</label>
           </div>
           <div class="input">
-              <div class="author">
                   <div class="gravatar">
-                    ${h.gravatar(c.pull_request.author.email, size=20)}
+                    ${h.gravatar(c.pull_request.owner.email, size=20)}
                   </div>
-                  <span>${c.pull_request.author.full_name_and_username}</span><br/>
-                  <span><a href="mailto:${c.pull_request.author.email}">${c.pull_request.author.email}</a></span><br/>
-              </div>
+                  <span>${c.pull_request.owner.full_name_and_username}</span><br/>
+                  <span><a href="mailto:${c.pull_request.owner.email}">${c.pull_request.owner.email}</a></span><br/>
           </div>
         </div>