Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add: watchers related rights

  • Loading branch information...
commit f9154583fdc0e6de1710489844a9d942302524aa 1 parent f2a8fb2
Sven Krzyzak authored
View
12 app/helpers/mylyn_connector/issues_helper.rb
@@ -33,6 +33,18 @@ def time_entries_new_allowed?(issue)
return (issue.project.module_enabled?(:time_tracking) && User.current.allowed_to?(:log_time, issue.project)) ? true : false
end
+ def watchers_view_allowed?(issue)
+ return User.current.allowed_to?(:view_issue_watchers, issue.project) ? true : false
+ end
+
+ def watchers_add_allowed?(issue)
+ return User.current.allowed_to?(:add_issue_watchers, issue.project) ? true : false
+ end
+
+ def watchers_delete_allowed?(issue)
+ return User.current.allowed_to?(:delete_issue_watchers, issue.project) ? true : false
+ end
+
def watched?(issue)
return false unless User.current.logged?
return issue.watched_by?(User.current)
View
7 app/views/mylyn_connector/issues/_issue.rxml
@@ -14,7 +14,12 @@ xml.issue({:id => issue.id, :editAllowed => edit_allowed?(issue)}.merge(attr||={
#Watchers
xml.watched watched?(issue)
- xml.watchers integer_list(issue.watcher_users)
+ showWatchers = watchers_view_allowed?(issue)
+ if (showWatchers && issue.watcher_users)
+ xml.watchers integer_list(issue.watcher_users), :viewAllowed => showWatchers, :addAllowed => watchers_add_allowed?(issue), :deleteAllowed => watchers_delete_allowed?(issue)
+ else
+ xml.watchers :viewAllowed => showWatchers, :addAllowed => watchers_add_allowed?(issue), :deleteAllowed => watchers_delete_allowed?(issue)
+ end
#Work/Progress(optional)
xml.startDate issue.start_date.to_s if issue.start_date
View
2  lib/mylyn_connector/version.rb
@@ -8,7 +8,7 @@ module Version
BRANCH = 'stable'
def self.revision
- return :RC5
+ return nil
end
REVISION = self.revision
View
19 test/fixtures/1.0/watchers.yml
@@ -0,0 +1,19 @@
+---
+watchers_001:
+ watchable_type: Issue
+ watchable_id: 2
+ user_id: 3
+watchers_002:
+ watchable_type: Message
+ watchable_id: 1
+ user_id: 1
+watchers_003:
+ watchable_type: Issue
+ watchable_id: 2
+ user_id: 1
+
+watchers_004:
+ watchable_type: Issue
+ watchable_id: 3
+ user_id: 2
+
View
4 test/functional/issues_controller_test.rb
@@ -33,7 +33,7 @@ def test_show_unauthenticated
assert_tag :tag => 'priorityid', :content => '4', :parent => i
assert_tag :tag => 'watched', :content => 'false', :parent => i
- assert_tag :tag => 'watchers', :content => '', :parent => i
+ assert_tag :tag => 'watchers', :attributes => {:viewallowed=>'false', :addallowed=>'false', :deleteallowed=>'false'}, :content => '', :parent => i
assert_tag :tag=> 'startdate', :content => 1.day.ago.to_date.to_s, :parent => i
assert_tag :tag=> 'duedate', :content => 10.day.from_now.to_date.to_s, :parent => i
@@ -103,6 +103,8 @@ def test_authenticated_attachments
assert_tag :tag => 'assignedtoid', :content => '3', :parent => i
+ assert_tag :tag => 'watchers', :attributes => {:viewallowed=>'true', :addallowed=>'false', :deleteallowed=>'false'}, :content => '2', :parent => i
+
atts = {:tag => 'attachments', :children => {:count => 4},:parent => i}
att = {:tag => 'attachment', :attributes => {:id => 1}, :parent => atts}
assert_tag :tag => 'authorid', :content => '2', :parent => att
View
17 test/schema/types/issue.xsd
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://redmin-mylyncon.sf.net/api"
targetNamespace="http://redmin-mylyncon.sf.net/api"
@@ -33,13 +32,25 @@
<xsd:element name="statusId" type="xsd:integer" />
<xsd:element name="priorityId" type="xsd:integer" />
<xsd:element name="watched" type="xsd:boolean"/><!-- watched by current user-->
- <xsd:element name="watchers" type="tns:idList"/>
+ <xsd:element name="watchers">
+ <xsd:complexType>
+ <xsd:simpleContent >
+ <xsd:extension base="tns:idList" >
+ <xsd:attribute name="viewAllowed" type="xsd:boolean" use="required"/>
+ <xsd:attribute name="addAllowed" type="xsd:boolean" use="required"/>
+ <xsd:attribute name="deleteAllowed" type="xsd:boolean" use="required"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+
+ </xsd:complexType>
+ </xsd:element>
+
<!-- OPTIONAL -->
<xsd:element name="startDate" type="xsd:date" minOccurs="0" />
<xsd:element name="dueDate" type="xsd:date" minOccurs="0" />
<xsd:element name="doneRatio" type="xsd:integer" minOccurs="0"/>
- <xsd:element name="estimatedHours" type="xsd:integer" minOccurs="0" />
+ <xsd:element name="estimatedHours" type="xsd:float" minOccurs="0" />
<xsd:element name="authorId" type="xsd:integer" minOccurs="0"/><!-- missing, when anonymous -->
<xsd:element name="categoryId" type="xsd:integer" minOccurs="0"/>
Please sign in to comment.
Something went wrong with that request. Please try again.