diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-07-09 11:41:04 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-07-09 11:41:04 +0000 |
commit | 3c2ebd7aa2bd4663b0c4a4ab06906cd1554ed095 (patch) | |
tree | 7b97b33b443d6761844c0d7896e06fc053156638 | |
parent | 95f332af5a448fb2aedf1af1a41f7001937d8cfd (diff) | |
download | redmine-3c2ebd7aa2bd4663b0c4a4ab06906cd1554ed095.tar.gz redmine-3c2ebd7aa2bd4663b0c4a4ab06906cd1554ed095.zip |
Adds visibility condition on parent project in API.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6204 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/project.rb | 5 | ||||
-rw-r--r-- | app/views/projects/index.api.rsb | 2 | ||||
-rw-r--r-- | app/views/projects/show.api.rsb | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index c9d00e9b7..c3b553083 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -118,6 +118,11 @@ class Project < ActiveRecord::Base visible(user).find(:all, :limit => count, :order => "created_on DESC") end + # Returns true if the project is visible to +user+ or to the current user. + def visible?(user=User.current) + user.allowed_to?(:view_project, self) + end + def self.visible_by(user=nil) ActiveSupport::Deprecation.warn "Project.visible_by is deprecated and will be removed in Redmine 1.3.0. Use Project.visible_condition instead." visible_condition(user || User.current) diff --git a/app/views/projects/index.api.rsb b/app/views/projects/index.api.rsb index 121300c12..552c1f65e 100644 --- a/app/views/projects/index.api.rsb +++ b/app/views/projects/index.api.rsb @@ -5,7 +5,7 @@ api.array :projects, api_meta(:total_count => @project_count, :offset => @offset api.name project.name api.identifier project.identifier api.description project.description - api.parent(:id => project.parent_id, :name => project.parent.name) unless project.parent.nil? + api.parent(:id => project.parent.id, :name => project.parent.name) if project.parent && project.parent.visible? render_api_custom_values project.visible_custom_field_values, api diff --git a/app/views/projects/show.api.rsb b/app/views/projects/show.api.rsb index b35ffebbb..561896a64 100644 --- a/app/views/projects/show.api.rsb +++ b/app/views/projects/show.api.rsb @@ -4,7 +4,7 @@ api.project do api.identifier @project.identifier api.description @project.description api.homepage @project.homepage - api.parent(:id => @project.parent_id, :name => @project.parent.name) unless @project.parent.nil? + api.parent(:id => @project.parent.id, :name => @project.parent.name) if @project.parent && @project.parent.visible? render_api_custom_values @project.visible_custom_field_values, api |