diff options
author | Jean-Baptiste Barth <jeanbaptiste.barth@gmail.com> | 2014-09-06 03:17:51 +0000 |
---|---|---|
committer | Jean-Baptiste Barth <jeanbaptiste.barth@gmail.com> | 2014-09-06 03:17:51 +0000 |
commit | 63cb3680c14b8582bc587917cac6d3ede604e412 (patch) | |
tree | e14a83ee2a89368555729534550769e979549709 /app | |
parent | c190496f240f0f438d7babcbb068adbe26986a56 (diff) | |
download | redmine-63cb3680c14b8582bc587917cac6d3ede604e412.tar.gz redmine-63cb3680c14b8582bc587917cac6d3ede604e412.zip |
Include enabled modules in projects API (#17602).
Contributed by Jan Schulz-Hofen <jan@plan.io>
git-svn-id: http://svn.redmine.org/redmine/trunk@13363 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/projects_helper.rb | 21 | ||||
-rw-r--r-- | app/views/projects/index.api.rsb | 1 | ||||
-rw-r--r-- | app/views/projects/show.api.rsb | 13 |
3 files changed, 23 insertions, 12 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 8337d43ab..8e23ccdda 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -91,4 +91,25 @@ module ProjectsHelper sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing) l("label_version_sharing_#{sharing}") end + + def render_api_includes(project, api) + api.array :trackers do + project.trackers.each do |tracker| + api.tracker(:id => tracker.id, :name => tracker.name) + end + end if include_in_api_response?('trackers') + + api.array :issue_categories do + project.issue_categories.each do |category| + api.issue_category(:id => category.id, :name => category.name) + end + end if include_in_api_response?('issue_categories') + + api.array :enabled_modules do + project.enabled_modules.each do |enabled_module| + api.enabled_module(:id => enabled_module.id, :name => enabled_module.name) + end + end if include_in_api_response?('enabled_modules') + + end end diff --git a/app/views/projects/index.api.rsb b/app/views/projects/index.api.rsb index a07db1b71..d309af241 100644 --- a/app/views/projects/index.api.rsb +++ b/app/views/projects/index.api.rsb @@ -10,6 +10,7 @@ api.array :projects, api_meta(:total_count => @project_count, :offset => @offset api.is_public project.is_public? render_api_custom_values project.visible_custom_field_values, api + render_api_includes(project, api) api.created_on project.created_on api.updated_on project.updated_on diff --git a/app/views/projects/show.api.rsb b/app/views/projects/show.api.rsb index 7a1e07c02..6e1958a34 100644 --- a/app/views/projects/show.api.rsb +++ b/app/views/projects/show.api.rsb @@ -9,19 +9,8 @@ api.project do api.is_public @project.is_public? render_api_custom_values @project.visible_custom_field_values, api + render_api_includes(@project, api) api.created_on @project.created_on api.updated_on @project.updated_on - - api.array :trackers do - @project.trackers.each do |tracker| - api.tracker(:id => tracker.id, :name => tracker.name) - end - end if include_in_api_response?('trackers') - - api.array :issue_categories do - @project.issue_categories.each do |category| - api.issue_category(:id => category.id, :name => category.name) - end - end if include_in_api_response?('issue_categories') end |