# HG changeset patch # User Mads Kiilerich # Date 1440602939 -7200 # Node ID 68011c4e6f33c6485740218e4d528ac452264e7f # Parent 3f017db297c4b79147e4535af5dff5a71ebf69ea pull requests: call it 'owner' instead of 'author' Prepare for making it possible to transfer ownership of PRs. diff -r 3f017db297c4 -r 68011c4e6f33 kallithea/controllers/pullrequests.py --- 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'), diff -r 3f017db297c4 -r 68011c4e6f33 kallithea/model/comment.py --- 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] diff -r 3f017db297c4 -r 68011c4e6f33 kallithea/model/db.py --- 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') diff -r 3f017db297c4 -r 68011c4e6f33 kallithea/model/pull_request.py --- 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) diff -r 3f017db297c4 -r 68011c4e6f33 kallithea/templates/changeset/changeset_file_comment.html --- 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): %endif diff -r 3f017db297c4 -r 68011c4e6f33 kallithea/templates/pullrequests/pullrequest_data.html --- 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 @@ ${_('Vote')} ${_('Title')} - ${_('Author')} + ${_('Owner')} ${_('Age')} ${_('From')} ${_('To')} @@ -39,7 +39,7 @@ - ${pr.author.full_name_and_username} + ${pr.owner.full_name_and_username} @@ -59,7 +59,7 @@ - %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")}