Changeset - 409eaadc0054
[Not reviewed]
default
0 2 0
Mads Kiilerich - 11 years ago 2015-03-11 01:17:33
madski@unity3d.com
pullrequests: on 'my pullrequests' show the user's own vote as second column next to 'latest vote'
2 files changed with 20 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/model/db.py
Show inline comments
 
@@ -2185,12 +2185,13 @@ class ChangesetStatus(Base, BaseModel):
 
    __tablename__ = 'changeset_statuses'
 
    __table_args__ = (
 
        Index('cs_revision_idx', 'revision'),
 
        Index('cs_version_idx', 'version'),
 
        Index('cs_pull_request_id_idx', 'pull_request_id'),
 
        Index('cs_changeset_comment_id_idx', 'changeset_comment_id'),
 
        Index('cs_pull_request_id_user_id_version_idx', 'pull_request_id', 'user_id', 'version'),
 
        UniqueConstraint('repo_id', 'revision', 'version'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
 
         'mysql_charset': 'utf8', 'sqlite_autoincrement': True}
 
    )
 
    STATUS_NOT_REVIEWED = DEFAULT = 'not_reviewed'
 
    STATUS_APPROVED = 'approved'
 
@@ -2289,12 +2290,22 @@ class PullRequest(Base, BaseModel):
 
        return self.status == self.STATUS_CLOSED
 

	
 
    @property
 
    def last_review_status(self):
 
        return str(self.statuses[-1].status) if self.statuses else ''
 

	
 
    def user_review_status(self, user_id):
 
        """Return the user's latest status votes on PR"""
 
        # note: no filtering on repo - that would be redundant
 
        status = ChangesetStatus.query()\
 
            .filter(ChangesetStatus.pull_request == self)\
 
            .filter(ChangesetStatus.user_id == user_id)\
 
            .order_by(ChangesetStatus.version)\
 
            .first()
 
        return str(status.status) if status else ''
 

	
 
    def __json__(self):
 
        return dict(
 
            revisions=self.revisions
 
        )
 

	
 
    def url(self, **kwargs):
kallithea/templates/pullrequests/pullrequest_data.html
Show inline comments
 
@@ -18,20 +18,27 @@
 
        <th class="left">${_('From')}</th>
 
        <th class="left">${_('To')}</th>
 
      </tr>
 
    </thead>
 
% for pr in pullrequests:
 
    <tr class="${'pr-closed' if pr.is_closed() else ''}">
 
      <td width="60px">
 
      <td width="80px">
 
        ## review status
 
        %if pr.last_review_status:
 
          <i class="icon-circle changeset-status-${pr.last_review_status}" title="${_("Someone voted: %s") % pr.last_review_status}"></i>
 
          <i class="icon-circle changeset-status-${pr.last_review_status}" title="${_("Latest vote: %s") % pr.last_review_status}"></i>
 
        %else:
 
          <i class="icon-circle changeset-status-not_reviewed" title="${_("Nobody voted")}"></i>
 
        %endif
 

	
 
        <% status = pr.user_review_status(c.authuser.user_id) %>
 
        %if status:
 
          <i class="icon-circle changeset-status-${status}" title="${_("You voted: %s") % status}"></i>
 
        %else:
 
          <i class="icon-circle changeset-status-not_reviewed" title="${_("You didn't vote")}"></i>
 
        %endif
 

	
 
        ## delete button
 
        %if pr.author.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}"
 
                  name="remove_${pr.pull_request_id}"
0 comments (0 inline, 0 general)