# HG changeset patch # User Mads Kiilerich # Date 1421858111 -3600 # Node ID fee908b9bd2d4096df76e307abbedde463c39ff7 # Parent dba66b0768f4880d300f2f5c95d38caa503c745d pullrequests: introduce 'editable' flag to avoid repeated permission checks diff -r dba66b0768f4 -r fee908b9bd2d kallithea/templates/pullrequests/pullrequest_show.html --- a/kallithea/templates/pullrequests/pullrequest_show.html Wed Jan 21 17:35:11 2015 +0100 +++ b/kallithea/templates/pullrequests/pullrequest_show.html Wed Jan 21 17:35:11 2015 +0100 @@ -16,6 +16,7 @@ <%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) %> ${self.repo_context_bar('showpullrequest')}
@@ -35,7 +36,7 @@
- %if not c.pull_request.is_closed() and (h.HasPermissionAny('hg.admin', 'repository.admin')() or c.pull_request.author.user_id == c.authuser.user_id): + %if editable:
${_("Edit")}
@@ -46,7 +47,7 @@
- %if not c.pull_request.is_closed() and (h.HasPermissionAny('hg.admin', 'repository.admin')() or c.pull_request.author.user_id == c.authuser.user_id): + %if editable: - %if c.available and not c.pull_request.is_closed(): + %if editable and c.available:
${h.submit('copy_update',_('Create Pull Request Update'),class_="btn btn-small")}
@@ -220,7 +221,7 @@
gravatar
${member.full_name} (${_('owner') if c.pull_request.user_id == member.user_id else _('reviewer')})
- %if not c.pull_request.is_closed() and (h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or c.pull_request.user_id == c.authuser.user_id): + %if editable:
@@ -230,9 +231,8 @@ %endfor
- %if not c.pull_request.is_closed(): + %if editable:
- %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or c.pull_request.author.user_id == c.authuser.user_id:
${h.text('user', class_='yui-ac-input',placeholder=_('Type name of reviewer to add'))}
@@ -240,7 +240,6 @@
${_('Save Changes')}
- %endif
%endif
@@ -359,7 +358,7 @@ if (window.location.hash != "") { window.location.href = window.location.href; } - }) + });