Changeset - e99a33d7d7f5
[Not reviewed]
default
0 10 0
Søren Løvborg - 9 years ago 2016-09-15 17:22:56
sorenl@unity3d.com
cleanup: use obj.foo_id instead of obj.foo.foo_id

Don't use constructs like obj.user.user_id when obj.user_id works
equally well (and potentially saves a database load).
10 files changed with 18 insertions and 18 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/notifications.py
Show inline comments
 
@@ -93,7 +93,7 @@ class NotificationsController(BaseContro
 
    def update(self, notification_id):
 
        try:
 
            no = Notification.get(notification_id)
 
            owner = all(un.user.user_id == c.authuser.user_id
 
            owner = all(un.user_id == c.authuser.user_id
 
                        for un in no.notifications_to_users)
 
            if h.HasPermissionAny('hg.admin')() or owner:
 
                # deletes only notification2user
 
@@ -108,7 +108,7 @@ class NotificationsController(BaseContro
 
    def delete(self, notification_id):
 
        try:
 
            no = Notification.get(notification_id)
 
            owner = any(un.user.user_id == c.authuser.user_id
 
            owner = any(un.user_id == c.authuser.user_id
 
                        for un in no.notifications_to_users)
 
            if h.HasPermissionAny('hg.admin')() or owner:
 
                # deletes only notification2user
kallithea/controllers/admin/repos.py
Show inline comments
 
@@ -423,7 +423,7 @@ class ReposController(BaseRepoController
 
                         if x.repo_id != c.repo_info.repo_id]
 

	
 
        defaults = {
 
            'id_fork_of': c.repo_info.fork.repo_id if c.repo_info.fork else ''
 
            'id_fork_of': c.repo_info.fork_id if c.repo_info.fork_id else ''
 
        }
 

	
 
        c.active = 'advanced'
kallithea/controllers/changeset.py
Show inline comments
 
@@ -422,7 +422,7 @@ class ChangesetController(BaseRepoContro
 
        co = ChangesetComment.get_or_404(comment_id)
 
        if co.repo.repo_name != repo_name:
 
            raise HTTPNotFound()
 
        owner = co.author.user_id == c.authuser.user_id
 
        owner = co.author_id == c.authuser.user_id
 
        repo_admin = h.HasRepoPermissionAny('repository.admin')(repo_name)
 
        if h.HasPermissionAny('hg.admin')() or repo_admin or owner:
 
            ChangesetCommentsModel().delete(comment=co)
kallithea/controllers/journal.py
Show inline comments
 
@@ -78,10 +78,10 @@ class JournalController(BaseController):
 
        return groups
 

	
 
    def _get_journal_data(self, following_repos):
 
        repo_ids = [x.follows_repository.repo_id for x in following_repos
 
                    if x.follows_repository is not None]
 
        user_ids = [x.follows_user.user_id for x in following_repos
 
                    if x.follows_user is not None]
 
        repo_ids = [x.follows_repo_id for x in following_repos
 
                    if x.follows_repo_id is not None]
 
        user_ids = [x.follows_user_id for x in following_repos
 
                    if x.follows_user_id is not None]
 

	
 
        filtering_criterion = None
 

	
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -473,7 +473,7 @@ class PullrequestsController(BaseRepoCon
 

	
 
        ChangesetCommentsModel().create(
 
            text=_('Closed, next iteration: %s .') % pull_request.url(canonical=True),
 
            repo=old_pull_request.other_repo.repo_id,
 
            repo=old_pull_request.other_repo_id,
 
            author=c.authuser.user_id,
 
            pull_request=old_pull_request.pull_request_id,
 
            closing_pr=True)
 
@@ -536,7 +536,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.owner.user_id == c.authuser.user_id:
 
        if pull_request.owner_id == c.authuser.user_id:
 
            PullRequestModel().delete(pull_request)
 
            Session().commit()
 
            h.flash(_('Successfully deleted pull request'),
 
@@ -758,7 +758,7 @@ class PullrequestsController(BaseRepoCon
 
                raise HTTPForbidden()
 

	
 
        if delete == "delete":
 
            if (pull_request.owner.user_id == c.authuser.user_id or
 
            if (pull_request.owner_id == c.authuser.user_id or
 
                h.HasPermissionAny('hg.admin')() or
 
                h.HasRepoPermissionAny('repository.admin')(pull_request.org_repo.repo_name) or
 
                h.HasRepoPermissionAny('repository.admin')(pull_request.other_repo.repo_name)
 
@@ -830,7 +830,7 @@ class PullrequestsController(BaseRepoCon
 
            #don't allow deleting comments on closed pull request
 
            raise HTTPForbidden()
 

	
 
        owner = co.author.user_id == c.authuser.user_id
 
        owner = co.author_id == c.authuser.user_id
 
        repo_admin = h.HasRepoPermissionAny('repository.admin')(c.repo_name)
 
        if h.HasPermissionAny('hg.admin')() or repo_admin or owner:
 
            ChangesetCommentsModel().delete(comment=co)
kallithea/model/user_group.py
Show inline comments
 
@@ -202,7 +202,7 @@ class UserGroupModel(BaseModel):
 

	
 
        user_group_member = None
 
        for m in user_group.members:
 
            if m.user.user_id == user.user_id:
 
            if m.user_id == user.user_id:
 
                # Found this user's membership row
 
                user_group_member = m
 
                break
kallithea/templates/changeset/changeset_file_comment.html
Show inline comments
 
@@ -24,7 +24,7 @@
 
              <a class="permalink" href="${co.url()}">&para;</a>
 
          </span>
 

	
 
          %if co.author.user_id == c.authuser.user_id or h.HasRepoPermissionAny('repository.admin')(c.repo_name):
 
          %if co.author_id == c.authuser.user_id or h.HasRepoPermissionAny('repository.admin')(c.repo_name):
 
            %if co.deletable():
 
              <div onClick="confirm('${_("Delete comment?")}') && deleteComment(${co.comment_id})" class="buttons delete-comment btn btn-mini" style="margin:0 5px">${_('Delete')}</div>
 
            %endif
 
@@ -81,7 +81,7 @@
 

	
 
                %if c.pull_request is not None and ( \
 
                    h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) \
 
                    or c.pull_request.owner.user_id == c.authuser.user_id):
 
                    or c.pull_request.owner_id == c.authuser.user_id):
 
                <div>
 
                  ${_('Finish pull request')}:
 
                  <label>
kallithea/templates/pullrequests/pullrequest_data.html
Show inline comments
 
@@ -59,7 +59,7 @@
 
        </a>
 
      </td>
 
      <td style="text-align:right">
 
        %if pr.owner.user_id == c.authuser.user_id:
 
        %if pr.owner_id == c.authuser.user_id:
 
          ${h.form(url('pullrequest_delete', repo_name=pr.other_repo.repo_name, pull_request_id=pr.pull_request_id), 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.owner.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_id == c.authuser.user_id) %>
 
${self.repo_context_bar('showpullrequest')}
 
<div class="box">
 
  <!-- box / title -->
kallithea/tests/models/test_notifications.py
Show inline comments
 
@@ -70,7 +70,7 @@ class TestNotifications(TestController):
 
            .filter(UserNotification.notification == notification).all()
 

	
 
        assert len(unotification) == len(usrs)
 
        assert set([x.user.user_id for x in unotification]) == set(usrs)
 
        assert set([x.user_id for x in unotification]) == set(usrs)
 

	
 
    def test_user_notifications(self):
 
        notification1 = NotificationModel().create(created_by=self.u1,
0 comments (0 inline, 0 general)