-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy path_show.json.jbuilder
More file actions
85 lines (69 loc) · 2.35 KB
/
_show.json.jbuilder
File metadata and controls
85 lines (69 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# frozen_string_literal: true
# locals: plan
json.schema 'https://github.com/RDA-DMP-Common/RDA-DMP-Common-Standard/tree/master/examples/JSON/JSON-schema/1.0'
presenter = Api::V2::PlanPresenter.new(plan: plan)
# Note the symbol of the dmproadmap json object
# nested in extensions which is the container for the json template object, etc.
# A JSON representation of a Data Management Plan in the
# RDA Common Standard format
json.title plan.title
json.description plan.description
json.language Api::V2::LanguagePresenter.three_char_code(
lang: LocaleService.default_locale
)
json.created plan.created_at.to_formatted_s(:iso8601)
json.modified plan.updated_at.to_formatted_s(:iso8601)
json.ethical_issues_exist Api::V2::ConversionService.boolean_to_yes_no_unknown(plan.ethical_issues)
json.ethical_issues_description plan.ethical_issues_description
json.ethical_issues_report plan.ethical_issues_report
id = presenter.identifier
if id.present?
json.dmp_id do
json.partial! 'api/v2/identifiers/show', identifier: id
end
end
if presenter.data_contact.present?
json.contact do
json.partial! 'api/v2/contributors/show', contributor: presenter.data_contact,
is_contact: true
end
end
unless @minimal
if presenter.contributors.any?
json.contributor presenter.contributors do |contributor|
json.partial! 'api/v2/contributors/show', contributor: contributor,
is_contact: false
end
end
if presenter.costs.any?
json.cost presenter.costs do |cost|
json.partial! 'api/v2/plans/cost', cost: cost
end
end
json.project [plan] do |pln|
json.partial! 'api/v2/plans/project', plan: pln
end
outputs = plan.research_outputs.any? ? plan.research_outputs : [plan]
json.dataset outputs do |output|
json.partial! "api/v2/datasets/show", output: output
end
json.extension [plan.template] do |template|
json.set! :dmproadmap do
json.template do
json.id template.id
json.title template.title
end
end
if @complete
json.complete_plan do
q_and_a = presenter.send(:fetch_all_q_and_a)
next if q_and_a.blank?
json.array! q_and_a do |item|
json.title item[:title]
json.question item[:question]
json.answer item[:answer]
end
end
end
end
end