#813: Adjusting relations permissions so TICKET_VIEW sufficient to view.
git-svn-id: https://svn.apache.org/repos/asf/bloodhound/trunk@1689326 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html b/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html
index 38aa89c..79400f0 100644
--- a/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html
+++ b/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html
@@ -22,7 +22,14 @@
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:i18n="http://genshi.edgewall.org/i18n"
- i18n:domain="bhdashboard">
+ i18n:domain="bhdashboard"
+ py:with="can_append = 'TICKET_APPEND' in perm(ticket.resource);
+ can_create = 'TICKET_CREATE' in perm(ticket.resource) and not ticket.exists;
+ can_modify = 'TICKET_CHGPROP' in perm(ticket.resource);
+ can_edit = 'TICKET_EDIT_DESCRIPTION' in perm(ticket.resource);
+ has_property_editor = not version and version != 0 and not cnum_edit
+ and (can_append or can_modify or can_edit or can_create);
+ ">
<py:choose test="">
<py:when test="relations">
@@ -64,7 +71,7 @@
</py:otherwise>
</py:choose>
- <div class="btn-group">
+ <div py:if="has_property_editor" class="btn-group">
<form method="get" action="${href.ticket(ticket.id, 'relations')}">
<button type="submit" class="btn" id="manage-relations"><i class="icon-retweet"></i> Manage relations</button>
</form>
diff --git a/bloodhound_relations/bhrelations/web_ui.py b/bloodhound_relations/bhrelations/web_ui.py
index 898cf58..3e05b0a 100644
--- a/bloodhound_relations/bhrelations/web_ui.py
+++ b/bloodhound_relations/bhrelations/web_ui.py
@@ -65,7 +65,8 @@
except ValueError:
raise TracError(_('Invalid ticket id.'))
- req.perm.require('TICKET_VIEW')
+ # For access to the relation management, TICKET_MODIFY is required.
+ req.perm.require('TICKET_MODIFY')
relsys = RelationsSystem(self.env)
data = {
@@ -74,7 +75,6 @@
if req.method == 'POST':
# for modifying the relations TICKET_MODIFY is required for
# both the source and the destination tickets
- req.perm.require('TICKET_MODIFY')
if 'remove' in req.args:
rellist = req.args.get('sel')
diff --git a/bloodhound_theme/bhtheme/templates/bh_ticket.html b/bloodhound_theme/bhtheme/templates/bh_ticket.html
index 6fd8df3..c6741c4 100644
--- a/bloodhound_theme/bhtheme/templates/bh_ticket.html
+++ b/bloodhound_theme/bhtheme/templates/bh_ticket.html
@@ -445,7 +445,7 @@
</div>
</form>
- <div py:if="bhrelations and ticket.exists and has_property_editor" class="relations">
+ <div py:if="bhrelations and ticket.exists" class="relations">
<bh:widget urn="TicketRelations">
<bh:args>
<bh:arg name="tid">$ticket.id</bh:arg>