Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ GEM
zeitwerk (2.6.15)

PLATFORMS

aarch64-linux-gnu
aarch64-linux-musl
arm-linux
Expand All @@ -523,6 +524,7 @@ PLATFORMS
x86_64-linux-gnu
x86_64-linux-musl


DEPENDENCIES
better_errors
bootsnap
Expand Down
4 changes: 2 additions & 2 deletions app/api/users_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class UsersApi < Grape::API
change_self = (params[:id] == current_user.id)

params[:receive_portfolio_notifications] = true if params.key?(:receive_portfolio_notifications) && params[:receive_portfolio_notifications].nil?
params[:receive_portfolio_notifications] = true if params.key?(:receive_feedback_notifications) && params[:receive_feedback_notifications].nil?
params[:receive_portfolio_notifications] = true if params.key?(:receive_task_notifications) && params[:receive_task_notifications].nil?
params[:receive_feedback_notifications] = true if params.key?(:receive_feedback_notifications) && params[:receive_feedback_notifications].nil?
params[:receive_task_notifications] = true if params.key?(:receive_task_notifications) && params[:receive_task_notifications].nil?

# can only modify if current_user.id is same as :id provided
# (i.e., user wants to update their own data) or if update_user token
Expand Down
15 changes: 15 additions & 0 deletions app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def specific_permission_hash(role, perm_hash, _other)
delegate :update_task_stats, to: :project

after_update :update_task_stats, if: :saved_change_to_task_status_id? # TODO: consider moving to async task
after_update :send_feedback_notification, if: :saved_change_to_task_status_id?

validates :task_definition_id, uniqueness: { scope: :project,
message: 'must be unique within the project' }
Expand Down Expand Up @@ -1362,6 +1363,20 @@ def read_file_from_done(idx)
nil
end

def send_feedback_notification
return unless task_status.in?([TaskStatus.redo, TaskStatus.fail, TaskStatus.fix_and_resubmit, TaskStatus.feedback_exceeded, TaskStatus.discuss, TaskStatus.demonstrate, TaskStatus.complete])
return unless project.student.receive_feedback_notifications
return unless unit&.send_notifications

begin
logger.info "Checking feedback email for project #{project.id}"
logger.info "Emailing feedback notification to #{project.student.name}"
PortfolioEvidenceMailer.task_feedback_ready(project, [self]).deliver
rescue => e
logger.error "Failed to send feedback notification email. Error: #{e.message}"
end
end

private

def delete_associated_files
Expand Down
3 changes: 2 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
# Store uploaded files on the local file system (see config/storage.yml for options).
# config.active_storage.service = :local

# Don't care if the mailer can't send.
# Don't care if the mailer can't send.

config.action_mailer.raise_delivery_errors = false

config.action_mailer.perform_caching = false
Expand Down