diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb
index c0457c635..ec1de08f1 100644
--- a/app/controllers/my_modules_controller.rb
+++ b/app/controllers/my_modules_controller.rb
@@ -2,6 +2,8 @@ class MyModulesController < ApplicationController
include SampleActions
include TeamsHelper
include InputSanitizeHelper
+ include Rails.application.routes.url_helpers
+ include ActionView::Helpers::UrlHelper
before_action :load_vars,
only: %I[show update destroy description due_date protocols
@@ -564,6 +566,32 @@ class MyModulesController < ApplicationController
message: message,
type_of: completed ? :complete_task : :uncomplete_task
)
+ start_work_on_next_task_notification
+ end
+
+ def start_work_on_next_task_notification
+ if @my_module.completed?
+ title = t('notifications.start_work_on_next_task',
+ user: current_user.full_name,
+ module: @my_module.name)
+ message = t('notifications.start_work_on_next_task_message',
+ project: link_to(@project.name, project_url(@project)),
+ experiment: link_to(@experiment.name,
+ canvas_experiment_url(@experiment)),
+ my_module: link_to(@my_module.name,
+ protocols_my_module_url(@my_module)))
+ notification = Notification.create(
+ type_of: :recent_changes,
+ title: sanitize_input(title, %w(strong a)),
+ message: sanitize_input(message, %w(strong a)),
+ generator_user_id: current_user.id
+ )
+ # create notification for all users on the next modules in the workflow
+ @my_module.my_modules.map(&:users).flatten.uniq.each do |target_user|
+ next if target_user == current_user
+ UserNotification.create(notification: notification, user: target_user)
+ end
+ end
end
def load_vars
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 9aa80d57a..dd23ea935 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1771,6 +1771,8 @@ en:
assign_user_to_team: "%{assigned_user} was added as %{role} to team %{team} by %{assigned_by_user}."
unassign_user_from_team: "%{unassigned_user} was removed from team %{team} by %{unassigned_by_user}."
task_completed: "%{user} completed task %{module}. %{date} | Project: %{project} | Experiment: %{experiment}"
+ start_work_on_next_task: "%{user} has completed the task %{module}. You can now start working on the next task in the workflow."
+ start_work_on_next_task_message: "Project: %{project} | Experiment: %{experiment} | Task: %{my_module}"
assets:
head_title: