Skip to content

Commit e07ea47

Browse files
committed
Add snooze option to curation tasks
1 parent 55612e5 commit e07ea47

11 files changed

Lines changed: 78 additions & 6 deletions

app/controllers/names_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ def new_correspondence
481481
@name_correspondence.name = @name
482482
if @name_correspondence.save
483483
@name.add_observer(current_user)
484+
@name.register.try(:unsnooze_curation!)
484485
flash[:notice] = 'Correspondence recorded'
485486
else
486487
flash[:alert] = 'An unexpected error occurred with the correspondence'

app/controllers/registers_controller.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class RegistersController < ApplicationController
55
show table list certificate_image cite edit update destroy
66
submit return return_commit endorse notify notify_commit
77
validate editorial_checks publish publish_commit new_correspondence
8-
internal_notes nomenclature_review genomics_review
8+
internal_notes nomenclature_review genomics_review snooze_curation
99
observe unobserve merge merge_commit sample_map
1010
reviewer_token reviewer_token_create reviewer_token_delete
1111
]
@@ -19,7 +19,7 @@ class RegistersController < ApplicationController
1919
:authenticate_curator!,
2020
only: %i[
2121
return return_commit endorse validate
22-
internal_notes nomenclature_review genomics_review
22+
internal_notes nomenclature_review genomics_review snooze_curation
2323
]
2424
)
2525
before_action(
@@ -315,6 +315,7 @@ def new_correspondence
315315
@register_correspondence.register = @register
316316
if @register_correspondence.save
317317
@register.add_observer(current_user)
318+
@register.unsnooze_curation!
318319
flash[:notice] = 'Correspondence recorded'
319320
else
320321
flash[:alert] = 'An unexpected error occurred with the correspondence'
@@ -379,6 +380,12 @@ def genomics_review
379380
redirect_back(fallback_location: @register)
380381
end
381382

383+
# POST /registers/r:abc/snooze_curation?time=10
384+
def snooze_curation
385+
@register.snooze_curation!(Time.now + params[:time].to_i.days)
386+
redirect_back(fallback_location: @register)
387+
end
388+
382389
# GET /registers/r:abc/merge
383390
def merge
384391
@crumbs = [

app/controllers/users_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def dashboard
5353
end
5454

5555
if current_user.curator?
56-
@pending_registers = Register.pending_for_curation
56+
@pending_registers =
57+
params[:snoozed] ?
58+
Register.snoozed_for_curation : Register.pending_for_curation
5759
@pending[:curator] = @pending_registers.count
5860
end
5961

app/models/register.rb

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Register < ApplicationRecord
4242
before_validation(:propose_and_save_title, if: :submitted?)
4343
before_destroy(:return_names_to_draft)
4444
before_save(:update_name_order)
45+
after_save(:unsnooze_curation!)
4546

4647
validates(:publication_id, presence: true, if: :validated?)
4748
validates(:publication_pdf, presence: true, if: :validated?)
@@ -84,11 +85,17 @@ def nom_nov(name)
8485
end
8586

8687
def pending_for_curation
87-
where(validated: false, notified: true)
88-
.or(where(validated: false, submitted: true))
88+
where(validated: false)
89+
.where('notified = ? OR submitted = ?', true, true)
90+
.where('snooze_curation is null or snooze_curation <= ?', Time.now)
8991
.order(updated_at: :asc)
9092
.select { |i| i.notified? || !i.endorsed? }
9193
end
94+
95+
def snoozed_for_curation
96+
where('snooze_curation > ?', Time.now)
97+
.order(updated_at: :asc)
98+
end
9299
end
93100

94101
def acc_url(protocol = false)
@@ -256,6 +263,19 @@ def doi_url
256263
'https://doi.org/%s' % doi
257264
end
258265

266+
def snoozed_curation?
267+
snooze_curation.present? && snooze_curation > Time.now
268+
end
269+
270+
def snooze_curation!(time)
271+
time = nil if time && time <= Time.now
272+
update_column(:snooze_curation, time)
273+
end
274+
275+
def unsnooze_curation!
276+
snooze_curation!(nil)
277+
end
278+
259279
def citations
260280
@citations ||=
261281
([publication] + sorted_names.map(&:citations).flatten).compact.uniq

app/views/registers/_curator.html.erb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,27 @@
109109
<dl class="main-section name-details">
110110
<h2>Curator team tracking</h2>
111111
<dd>
112+
<% if @register.snoozed_curation? %>
113+
<%= link_to(
114+
snooze_curation_register_url(@register),
115+
method: :post, class: 'btn btn-primary btn-sm'
116+
) do %>
117+
<%= fa_icon('stopwatch') %> Unsnooze for curation
118+
<% end %>
119+
&raquo; Display again in pending curation tasks with other submitted
120+
lists
121+
<% else %>
122+
<%= link_to(
123+
snooze_curation_register_url(@register, time: 20),
124+
method: :post, class: 'btn btn-primary btn-sm'
125+
) do %>
126+
<%= fa_icon('stopwatch-20') %> Snooze for curation
127+
<% end %>
128+
&raquo; Hide from curation tasks for 20 days or until correspondance
129+
is posted
130+
<% end %>
131+
<hr/>
132+
112133
<%= render(partial: 'registers/curator_review_checks') %>
113134
<br/><br/>
114135
<%= render(partial: 'registers/curator_internal_notes') %>

app/views/registers/_curator_review_checks.html.erb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@
1313
<%= what.to_s.capitalize %> review
1414
<% end %>
1515
<% end %>
16+
17+
<% if register.snoozed_curation? %>
18+
<span class="text-muted btn">
19+
<%= fa_icon('stopwatch') %>
20+
Curation snoozed for <%= time_ago_in_words(register.snooze_curation) %>
21+
</span>
22+
<% end %>

app/views/users/_curator.html.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
<%= render(partial: 'pending_registers') %>
33
<ul class="nav flex-column">
44
<li class="nav-item mt-3"><h2>Review Register Lists</h2></li>
5+
<li class="nav-item">
6+
<%= link_to(dashboard_path(tab: :curator, snoozed: true)) do %>
7+
<%= fa_icon('stopwatch') %>
8+
Register lists snoozed for curation
9+
<% end %>
10+
</li>
511
<li class="nav-item">
612
<%= link_to(registers_path(status: :notified)) do %>
713
<%= fa_icon('check-circle') %>

app/views/users/_pending_registers.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<h2>
22
Pending submissions
3+
<%= 'snoozed' if params[:snoozed] %>
34
<div class="badge badge-count"><%= @pending_registers.count %></div>
45
</h2>
56

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
post :genomics_review
166166
get :merge
167167
post :merge, action: :merge_commit
168+
post :snooze_curation
168169
# --> Edit user relationship to register list
169170
get :observe
170171
get :unobserve
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddSnoozeCurationToRegisters < ActiveRecord::Migration[6.1]
2+
def change
3+
add_column :registers, :snooze_curation, :datetime, default: nil
4+
end
5+
end

0 commit comments

Comments
 (0)