Skip to content

Commit

Permalink
Close #139
Browse files Browse the repository at this point in the history
  • Loading branch information
lmrodriguezr committed Jan 4, 2024
1 parent 734d912 commit 2dc8c07
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
19 changes: 18 additions & 1 deletion app/controllers/registers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def submit
change_status(
:submit, 'Register list successfully submitted for review', current_user
)
add_automatic_correspondence('Register list submitted')
end

# GET /registers/r:abcd/return
Expand Down Expand Up @@ -190,6 +191,7 @@ def notify
# the standard +change_status+ call used in all other status changes
if @register.notify(current_user, register_notify_params, params[:doi])
flash[:notice] = 'The list has been successfully submitted for validation'
add_automatic_correspondence('SeqCode Register notified')
redirect_to(@register)
else
@register.title = par[:title]
Expand Down Expand Up @@ -300,12 +302,20 @@ def nomenclature_review
@register.update_column(
:nomenclature_review, !@register.nomenclature_review
)
if @register.nomenclature_review
add_automatic_correspondence('Nomenclature review complete')
end
redirect_back(fallback_location: @register)
end

# POST /registers/r:abc/genomics_review
def genomics_review
@register.update_column(:genomics_review, !@register.genomics_review)
@register.update_column(
:genomics_review, !@register.genomics_review
)
if @register.genomics_review
add_automatic_correspondence('Genomics review complete')
end
redirect_back(fallback_location: @register)
end

Expand Down Expand Up @@ -364,6 +374,13 @@ def ensure_valid!
@register&.validated?
end

def add_automatic_correspondence(message)
RegisterCorrespondence.new(
message: message, notify: '0', automatic: true,
user: current_user, register: @register
).save
end

def change_status(fun, success_msg, *extra_opts)
if @register.send(fun, *extra_opts)
flash[:notice] = success_msg
Expand Down
3 changes: 2 additions & 1 deletion app/models/register/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def submit(user)
name.update!(par)
end
update_status_with_alert(
submitted: true, submitted_at: Time.now
submitted: true, submitted_at: Time.now,
genomics_review: false, nomenclature_review: false
) or return false
end
notify_status_change(:submit, user)
Expand Down
4 changes: 2 additions & 2 deletions app/views/genomes/_genome.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ end
<% if @genome.source? %>
<% def show_genome_sources(n = nil) %>
<% content_tag(:ul) do %>
<% content_tag(:ul, class: 'mb-1') do %>
<% @genome.source_links.each_with_index.map do |link, k| %>
<li>
<%= link_to(link[0], target: '_blank', title: link[2]) do %>
Expand All @@ -171,7 +171,7 @@ end
<% id = modal('Data sources') do %>
<%= show_genome_sources %>
<% end %>
<%= modal_button(id) do %>
<%= modal_button(id, class: 'btn btn-secondary') do %>
See all sources
<% end %>
<% else %>
Expand Down
9 changes: 7 additions & 2 deletions app/views/shared/_correspondence_message.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<% automatic =
correspondence.respond_to?(:automatic) && correspondence.automatic %>
<dt>
<%= fa_icon('comment') %>
<%= fa_icon(automatic ? 'robot' : 'comment') %>
<%= link_to(correspondence.user) do %>
<%= correspondence.user.username %>
<% if correspondence.user.curator? %>
Expand All @@ -8,8 +10,11 @@
</span>
<% end %>
<% end %>
<% if automatic %>
<span class="text-muted">(automatic message)</span>
<% end %>
<span title="<%= correspondence.created_at %>">
<%= time_ago_in_words(correspondence.created_at) %> ago:
<%= time_ago_in_words(correspondence.created_at) %> ago
</span>
</dt>
<dd><%= correspondence.message %></dd>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddAutomaticToRegisterCorrespondence < ActiveRecord::Migration[6.1]
def change
add_column :register_correspondences, :automatic, :boolean, default: false
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddAutomaticToNameCorrespondence < ActiveRecord::Migration[6.1]
def change
add_column :name_correspondences, :automatic, :boolean, default: false
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2024_01_02_013502) do
ActiveRecord::Schema.define(version: 2024_01_04_204413) do

create_table "action_text_rich_texts", force: :cascade do |t|
t.string "name", null: false
Expand Down Expand Up @@ -113,6 +113,7 @@
t.integer "user_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.boolean "automatic", default: false
t.index ["name_id"], name: "index_name_correspondences_on_name_id"
t.index ["user_id"], name: "index_name_correspondences_on_user_id"
end
Expand Down Expand Up @@ -277,6 +278,7 @@
t.integer "user_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.boolean "automatic", default: false
t.index ["register_id"], name: "index_register_correspondences_on_register_id"
t.index ["user_id"], name: "index_register_correspondences_on_user_id"
end
Expand Down

0 comments on commit 2dc8c07

Please sign in to comment.