Skip to content

Commit e5ca073

Browse files
committed
RC for prenotification
1 parent 3df0756 commit e5ca073

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

app/controllers/registers_controller.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,24 @@ def endorse
204204

205205
# GET /registers/r:abc/prenotify
206206
def prenotify
207+
@errored ||= {}
207208
@genomes = @register.names.map(&:type_genome).compact.select(&:pending?)
208209
redirect_to(notify_register_path(@register)) if @genomes.empty?
209210
end
210211

211212
# POST /registers/r:abc/prenotify
212213
def prenotify_commit
214+
genomes = params.require(:genome)
215+
@errored = {}
216+
genomes.each do |k, v|
217+
genome = Genome.find(k)
218+
unless genome.update_accession(v['accession'], v['database'])
219+
@errored[k.to_i] = 'Cannot update accession'
220+
end
221+
end
222+
213223
prenotify
214-
render(:prenotify)
224+
render(:prenotify) unless @genomes.empty?
215225
end
216226

217227
# GET /registers/r:abc/notify

app/views/registers/prenotify.html.erb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<th scope=col>Temporary designation</th>
2323
<th scope=col>Database</th>
2424
<th scope=col>Accession</th>
25+
<% unless @errored.present? %>
26+
<th scope=col>Errors</th>
27+
<% end %>
2528
</tr>
2629
</thead>
2730
<tbody>
@@ -38,6 +41,9 @@
3841
<td><%= text_field_tag(
3942
"genome[#{genome.id}][accession]", nil, class: 'form-control'
4043
) %></td>
44+
<% if @errored[genome.id] %>
45+
<td class="text-danger"><%= @errored[genome.id] %></td>
46+
<% end %>
4147
</tr>
4248
<% end %>
4349
</tbody>
@@ -49,7 +55,3 @@
4955
<br/><br/>
5056
<% end %>
5157

52-
<pre>
53-
<%= params.inspect %>
54-
</pre>
55-

0 commit comments

Comments
 (0)