Skip to content

Commit f7b4b0c

Browse files
committed
Resolve issue with batch submissions
Issue reported by Tomeu Viver now solved
1 parent 6bc6e9f commit f7b4b0c

4 files changed

Lines changed: 31 additions & 14 deletions

File tree

app/models/name.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ class Name < ApplicationRecord
114114
if: -> { nomenclatural_type_id? || nomenclatural_type_entry.present? }
115115
}
116116
)
117-
validates(:nomenclatural_type_id, presence: { if: :nomenclatural_type_type? })
117+
validates(
118+
:nomenclatural_type_id,
119+
presence: { if: :nomenclatural_type_type? }
120+
)
118121

119122
include HasObservers
120123
include HasExternalResources

app/models/tutorial/batch.rb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ def check_ephemeral_names(user)
123123

124124
# Is the etymology present?
125125
unless name.etymology?
126-
name.errors.add(:etymology_xx_description, :missing, message: 'is missing')
126+
name.errors.add(
127+
:etymology_xx_description, :missing, message: 'is missing'
128+
)
127129
end
128130

129131
# Is the name already registered?
@@ -158,11 +160,16 @@ def check_ephemeral_names(user)
158160
:nomenclatural_type_entry, :does_not_exist,
159161
message: 'is not an existing genome and is not described here'
160162
)
161-
elsif !genome_is_unique?(name)
162-
name.errors.add(
163-
:nomenclatural_type_entry, :is_a_type,
164-
message: 'is already the type genome for a different name'
165-
)
163+
# TODO
164+
# REVISE THIS: Note that a given genome could indeed be the type of two
165+
# different names. For example, a new position could be proposed (a
166+
# species name transferred to a different genus), or a species and a
167+
# subspecies could share the same type genome
168+
#elsif !genome_is_unique?(name)
169+
# name.errors.add(
170+
# :nomenclatural_type_entry, :is_a_type,
171+
# message: 'is already the type genome for a different name'
172+
# )
166173
end
167174
end
168175
end
@@ -297,9 +304,6 @@ def batch_step_01(params, user)
297304
# Remove foreign keys in first pass
298305
par = par_ori.dup
299306
par['parent'] = nil
300-
if par['nomenclatural_type_type'].to_s.downcase == 'name'
301-
par['nomenclatural_type_entry'] = nil
302-
end
303307

304308
# Claim/update or create
305309
name = Name.find_by_variants(par['name'])
@@ -332,7 +336,8 @@ def batch_step_01(params, user)
332336
par['nomenclatural_type_entry'].present?
333337
new_par[:nomenclatural_type] =
334338
Name.find_by_variants(par['nomenclatural_type_entry'])
335-
unless new_par[:type_accession]
339+
# Deal with legacy type accession definitions
340+
if new_par[:type_accession].present?
336341
name = Name.new(default_pars.merge(name: par['type_material']))
337342
name.save!
338343
new_par[:type_accession] = name.id

app/views/tutorials/_bar.html.erb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@
2121

2222
<% if @tutorial.invalid_record %>
2323
<div class="alert alert-danger">
24-
Errors detected for <%= display_link(@tutorial.invalid_record.record) %>:
24+
Errors detected for <%= display_link(@tutorial.invalid_record.record) %>
25+
<% id = modal('Record details', size: 'lg') do %>
26+
<% r = @tutorial.invalid_record.record %>
27+
<pre><%= JSON.pretty_generate(JSON.parse(r.to_json)) %></pre>
28+
<% end %>
29+
<%= modal_button(id, as_anchor: true) do %>(record details)<% end %>:
2530
<ul>
2631
<% @tutorial.invalid_record.record.errors.full_messages.each do |error| %>
27-
<li><%= error %></li>
32+
<li>
33+
<%= error %>
34+
</li>
2835
<% end %>
2936
</ul>
3037
</div>

app/views/tutorials/batch/_01.html.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
</p>
5252
<hr/>
5353
<p><b>Description:</b> <%= name.description %></p>
54-
<p><b>Nomenclatural type:</b> <%= name.type_text %></p>
54+
<p>
55+
<b>Nomenclatural type:</b> <%= name.type_text.try(:html_safe) %>
56+
</p>
5557
<% if name.errors.any? %>
5658
<div class="alert alert-danger">
5759
<h4>Issues detected in preliminary check:</h4>

0 commit comments

Comments
 (0)