Changeset - 68011c4e6f33
[Not reviewed]
default
0 7 0
Mads Kiilerich - 10 years ago 2015-08-26 17:28:59
madski@unity3d.com
pull requests: call it 'owner' instead of 'author'

Prepare for making it possible to transfer ownership of PRs.
7 files changed with 22 insertions and 25 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -479,7 +479,7 @@ class PullrequestsController(BaseRepoCon
 
            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 @@ class PullrequestsController(BaseRepoCon
 
    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'),
kallithea/model/comment.py
Show inline comments
 
@@ -92,7 +92,7 @@ class ChangesetCommentsModel(BaseModel):
 
            )
 
            # 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 @@ class ChangesetCommentsModel(BaseModel):
 
            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]
kallithea/model/db.py
Show inline comments
 
@@ -2303,7 +2303,7 @@ class PullRequest(Base, BaseModel):
 
    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')
kallithea/model/pull_request.py
Show inline comments
 
@@ -87,7 +87,7 @@ class PullRequestModel(BaseModel):
 
        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 @@ class PullRequestModel(BaseModel):
 
        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 @@ class PullRequestModel(BaseModel):
 
        ChangesetStatusModel().set_status(
 
            org_repo,
 
            ChangesetStatus.STATUS_UNDER_REVIEW,
 
            new.author,
 
            new.owner,
 
            comment,
 
            pull_request=new
 
        )
 
@@ -135,7 +135,7 @@ class PullRequestModel(BaseModel):
 
        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 @@ class PullRequestModel(BaseModel):
 
        _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 @@ class PullRequestModel(BaseModel):
 
        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)
kallithea/templates/changeset/changeset_file_comment.html
Show inline comments
 
@@ -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
kallithea/templates/pullrequests/pullrequest_data.html
Show inline comments
 
@@ -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}"
kallithea/templates/pullrequests/pullrequest_show.html
Show inline comments
 
@@ -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 @@ ${self.repo_context_bar('showpullrequest
 
        </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>
 

	
0 comments (0 inline, 0 general)