• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / tigerdata-app / 7efe1a86-aa29-4caa-b857-e235c8c3959f

22 Nov 2025 01:36AM UTC coverage: 40.628% (-50.7%) from 91.317%
7efe1a86-aa29-4caa-b857-e235c8c3959f

Pull #2234

circleci

carolyncole
Close the custom storage div when a user chooses a preset option
fixes #2115
Pull Request #2234: Close the custom storage div when a user chooses a preset option

1487 of 3660 relevant lines covered (40.63%)

52.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/presenters/project_xml_presenter.rb
1
# frozen_string_literal: true
2

3
# rubocop:disable Metrics/ClassLength
4
class ProjectXmlPresenter
×
5
  attr_reader :project, :project_metadata
×
6

7
  # Delegate methods to the project and project_metadata objects
8
  delegate(
×
9
    "id",
×
10
    "in_mediaflux?",
×
11
    "mediaflux_id",
×
12
    "title",
×
13
    to: :project
×
14
  )
×
15

16
  delegate(
×
17
    "approval_note",
×
18
    "description",
×
19
    "data_manager",
×
20
    "data_sponsor",
×
21
    "data_user_read_only",
×
22
    "data_user_read_write",
×
23
    "departments",
×
24
    "project_id",
×
25
    "project_purpose",
×
26
    "storage_capacity",
×
27
    "storage_performance_expectations",
×
28
    "created_by",
×
29
    "created_on",
×
30
    "updated_by",
×
31
    "updated_on",
×
32
    "schema_version",
×
33
    to: :project_metadata
×
34
  )
×
35

36
  # @param project [Project] The project for the presenter
37
  def initialize(project)
×
38
    @project = project
×
39
    @project_metadata = @project.metadata_model
×
40
  end
×
41

42
  # @return [Nokogiri::XML::Document] The XML document
43
  delegate :document, to: :build
×
44

45
  # @return [Boolean] Whether the request for a Globus mount is approved
46
  def globus_enable_approved?
×
47
    project_metadata.globus_request == "Yes"
×
48
  end
×
49

50
  # @return [String] Whether the request for a Globus mount is approved
51
  def globus_enable_approved
×
52
    if globus_enable_approved?
×
53
      "true"
×
54
    else
×
55
      "false"
×
56
    end
×
57
  end
×
58

59
  # @return [Boolean] Whether there is a request for a Globus mount
60
  def globus_enable_requested?
×
61
    project_metadata.globus_request == "Yes"
×
62
  end
×
63

64
  # @return [String] Whether the request for a Globus mount is requested
65
  def globus_enable_requested
×
66
    if globus_enable_requested?
×
67
      "true"
×
68
    else
×
69
      "false"
×
70
    end
×
71
  end
×
72

73
  # @return [Boolean] Whether the request for the SMB mount is approved
74
  def smb_enable_approved?
×
75
    project_metadata.smb_request == "Yes"
×
76
  end
×
77

78
  # @return [String] Whether the request for the SMB mount is approved
79
  def smb_enable_approved
×
80
    if smb_enable_approved?
×
81
      "true"
×
82
    else
×
83
      "false"
×
84
    end
×
85
  end
×
86

87
  # @return [Boolean] Whether there is a request for SMB mount
88
  def smb_enable_requested?
×
89
    project_metadata.smb_request == "Yes"
×
90
  end
×
91

92
  # @return [String] Whether the request for the SMB mount is requested
93
  def smb_enable_requested
×
94
    if smb_enable_requested?
×
95
      "true"
×
96
    else
×
97
      "false"
×
98
    end
×
99
  end
×
100

101
  # @return [String] The project status (mapped to values specified by the TigerData XML schema)
102
  # NOTE: Valid values are one of: 'AdminReview', 'Approved', 'Active', 'Retired', 'Published'
103
  def status
×
104
    project_status = project.status
×
105
    return if project_status.nil?
×
106

107
    project_status.capitalize
×
108
  end
×
109

110
  # @return [ProvenanceEvent] The first project submission event
111
  def submission
×
112
    @submission ||= project.provenance_events.find_by(event_type: ProvenanceEvent::SUBMISSION_EVENT_TYPE)
×
113
  end
×
114

115
  # @return [Array<ProvenanceEvent>] The project submission events
116
  def submissions
×
117
    [submission]
×
118
  end
×
119

120
  # @return [String] The user ID of the user who requested the project
121
  def requested_by
×
122
    return if submission.nil?
×
123

124
    submission.event_person
×
125
  end
×
126

127
  # @return [String] The date and time of the request
128
  def request_date_time
×
129
    return if submission.nil?
×
130

131
    value = submission.created_at
×
132
    value.strftime("%Y-%m-%dT%H:%M:%S%:z")
×
133
  end
×
134

135
  # @return [String] The user ID of the user who approved the project
136
  def approved_by
×
137
    return if approval_note.nil?
×
138

139
    approval_note[:note_by]
×
140
  end
×
141

142
  # @return [String] The date and time of the approval
143
  def approval_date_time
×
144
    return nil if approval_note.nil?
×
145

146
    approval_note[:note_date_time]
×
147
  end
×
148

149
  # @return [String] Whether or not the project data use agreement
150
  def data_use_agreement?
×
151
    project_metadata.data_use_agreement.present?
×
152
  end
×
153

154
  # @return [String] The project resource type
155
  def project_resource_type
×
156
    project_metadata.resource_type
×
157
  end
×
158

159
  # @return [Boolean] Whether the project is provisional
160
  def provisional_project?
×
161
    project_metadata.provisional
×
162
  end
×
163

164
  # @return [String] Whether or not the project is associated with HPC
165
  delegate :hpc, to: :project_metadata
×
166

167
  # @return [String] The project visibility
168
  delegate :project_visibility, to: :project_metadata
×
169

170
  # @return [Boolean] Whether the project directory request is approved
171
  def project_directory_approved?
×
172
    expectations = storage_performance_expectations
×
173
    expectations[:approved] || false
×
174
  end
×
175

176
  # @return [Boolean] Whether the project storage capacity request is approved
177
  def storage_capacity_approved?
×
178
    storage_capacity_size = storage_capacity["size"] || {}
×
179
    return false unless storage_capacity_size.key?(:approved)
×
180

181
    approved_size = storage_capacity_size[:approved] || 0
×
182
    approved_size > 0
×
183
  end
×
184

185
  # @return [Boolean] Whether the project storage request is approved
186
  def storage_performance_requested?
×
187
    requested = storage_performance_expectations[:requested]
×
188
    requested.present?
×
189
  end
×
190

191
  # @return [Array<String>] The project directory paths
192
  def project_directory
×
193
    [project.project_directory]
×
194
  end
×
195

196
  # @param index [Integer] The index of the project directory
197
  # @return [String] The project directory path
198
  def project_directory_path(index)
×
199
    entry = project_directory[index]
×
200
    entry
×
201
  end
×
202

203
  # @param index [Integer] The index of the project directory
204
  # @return [String] The protocol for the project directory
205
  def project_directory_protocol(index)
×
206
    entry = project_directory[index]
×
207
    segments = entry.split("://")
×
208

209
    if segments.length > 1
×
210
      value = segments[0]
×
211
      value.upcase
×
212
    else
×
213
      ProjectMetadata.default_directory_protocol
×
214
    end
×
215
  end
×
216

217
  # @param index [Integer] The index of the department code to retrieve
218
  # @return [String] The department code for departments associated with the project
219
  def department(index)
×
220
    value = departments[index]
×
221
    if value.length < 6
×
222
      value = value.rjust(6, "0")
×
223
    end
×
224
    value
×
225
  end
×
226

227
  # @return [String] The department code for the project
228
  def department_code(index)
×
229
    departments[index]
×
230
  end
×
231

232
  # @return [String] The requested project storage capacity
233
  def requested_storage
×
234
    storage_performance_expectations[:requested] || nil
×
235
  end
×
236

237
  private
×
238

239
    def xml_builder_config
×
240
      Rails.configuration.xml_builder
×
241
    end
×
242

243
    def presenter_builder_config
×
244
      xml_builder_config[:project] || {}
×
245
    end
×
246

247
    def find_builder_args(key)
×
248
      raise "No builder config for #{key}" unless presenter_builder_config.key?(key)
×
249

250
      values = presenter_builder_config[key]
×
251
      values[:presenter] = self
×
252
      values
×
253
    end
×
254

255
    def builder
×
256
      @builder ||= begin
×
257
                     builder_args = find_builder_args(:resource)
×
258
                     XmlTreeBuilder.new(**builder_args)
×
259
                   end
×
260
    end
×
261

262
    delegate :build, to: :builder
×
263
end
×
264
# rubocop:enable Metrics/ClassLength
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc