#706: some refactoring, updated build_list API response

This commit is contained in:
Vokhmin Alexey V 2012-10-19 18:24:28 +04:00
parent 4680e9c62c
commit f67a8b3692
5 changed files with 28 additions and 17 deletions

View File

@ -12,32 +12,41 @@ json.build_list do |json|
json.updated_at @build_list.updated_at.to_i json.updated_at @build_list.updated_at.to_i
json.project do |json_project| json.project do |json_project|
json_project.(@build_list.project, :id, :name) json.partial! 'api/v1/projects/project',
json_project.fullname @build_list.project.name_with_owner :project => @build_list.project, :json => json_project
json_project.url api_v1_project_path(@build_list.project, :format => :json)
end end
json.save_to_repository do |json_save_to_repository| json.save_to_repository do |json_save_to_repository|
json_save_to_repository.(@build_list.save_to_repository, :id, :name) json.partial! 'api/v1/repositories/repository',
:repository => @build_list.save_to_repository,
:json => json_save_to_repository
json_save_to_repository.platform do |json_str_platform| json_save_to_repository.platform do |json_str_platform|
json_str_platform.(@build_list.save_to_repository.platform, :id, :name) json.partial! 'api/v1/platforms/platform',
json_str_platform.url api_v1_platform_path(@build_list.save_to_repository.platform, :format => :json) :platform => @build_list.save_to_repository.platform,
:json => json_str_platform
end end
json_save_to_repository.url api_v1_repository_path(@build_list.save_to_repository, :format => :json)
end end
json.build_for_platform do |json_build_for_platform| json.build_for_platform do |json_build_for_platform|
json_build_for_platform.(@build_list.build_for_platform, :id, :name) json.partial! 'api/v1/platforms/platform',
json_build_for_platform.url api_v1_platform_path(@build_list.build_for_platform, :format => :json) :platform => @build_list.build_for_platform,
:json => json_build_for_platform
end end
json.partial! 'api/v1/shared/owner', :owner => @build_list.project.owner json.partial! 'api/v1/shared/owner', :owner => @build_list.project.owner
inc_repos = Repository.includes(:platform).where(:id => @build_list.include_repos) inc_repos = Repository.includes(:platform).where(:id => @build_list.include_repos)
json.include_repos inc_repos do |json_include_repos, repo| json.include_repos inc_repos do |json_include_repos, repo|
json_include_repos.(repo, :id, :name) json.partial! 'api/v1/repositories/repository',
:repository => repo,
:json => json_include_repos
json_include_repos.platform do |json_str_platform|
json.partial! 'api/v1/platforms/platform',
:platform => repo.platform,
:json => json_str_platform
end
end end
json.advisory do |json_advisory| json.advisory do |json_advisory|

View File

@ -0,0 +1,2 @@
json.(platform, :id, :name)
json.url api_v1_platform_path(platform.id, :format => :json)

View File

@ -1,11 +1,11 @@
json.platforms @platforms do |json, platform| json.platforms @platforms do |json, platform|
json.(platform, :id, :name, :platform_type, :visibility) json.partial! 'platform', :platform => platform, :json => json
json.(platform, :platform_type, :visibility)
json.partial! 'api/v1/shared/owner', :owner => platform.owner json.partial! 'api/v1/shared/owner', :owner => platform.owner
json.repositories platform.repositories do |json_repos, repo| json.repositories platform.repositories do |json_repos, repo|
json_repos.(repo, :id, :name) json_repos.(repo, :id, :name)
json_repos.url api_v1_repository_path(repo.id, :format => :json) json_repos.url api_v1_repository_path(repo.id, :format => :json)
end end
json.url api_v1_platform_path(platform.id, :format => :json)
end end
json.url api_v1_platforms_path(:format => :json) json.url api_v1_platforms_path(:format => :json)

View File

@ -1,5 +1,5 @@
json.platform do |json| json.platform do |json|
json.(@platform, :id) json.partial! 'platform', :platform => @platform, :json => json
json.partial! 'api/v1/shared/members' json.partial! 'api/v1/shared/members'
end end
json.url members_api_v1_platform_path(@platform.id, :format => :json) json.url members_api_v1_platform_path(@platform.id, :format => :json)

View File

@ -1,5 +1,6 @@
json.platform do |json| json.platform do |json|
json.(@platform, :id, :name, :description, :parent_platform_id, :released, :visibility, :platform_type, :distrib_type) json.partial! 'platform', :platform => @platform, :json => json
json.(@platform, :description, :parent_platform_id, :released, :visibility, :platform_type, :distrib_type)
json.created_at @platform.created_at.to_i json.created_at @platform.created_at.to_i
json.updated_at @platform.updated_at.to_i json.updated_at @platform.updated_at.to_i
json.partial! 'api/v1/shared/owner', :owner => @platform.owner json.partial! 'api/v1/shared/owner', :owner => @platform.owner
@ -7,5 +8,4 @@ json.platform do |json|
json_repos.(repo, :id, :name) json_repos.(repo, :id, :name)
json_repos.url api_v1_repository_path(repo.id, :format => :json) json_repos.url api_v1_repository_path(repo.id, :format => :json)
end end
end end
json.url api_v1_platform_path(@platform.id, :format => :json)