-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1773 from datadryad/3379-abandoned-datasets----wi…
…thdrawing added withdrawn functionality and email notification, added final del…
- Loading branch information
Showing
44 changed files
with
1,533 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
module StashEngine | ||
|
||
# Mails users about submissions | ||
class ResourceMailer < ApplicationMailer | ||
|
||
def in_progress_delete_notification(resource) | ||
logger.warn('Unable to send in_progress_delete_notification; nil resource') unless resource.present? | ||
return unless resource.present? | ||
|
||
assign_variables(resource) | ||
return unless @user.present? && user_email(@user).present? | ||
|
||
mail(to: user_email(@user), | ||
subject: "#{rails_env}REMINDER: Dryad submission \"#{@resource.title}\"", | ||
template_path: 'stash_engine/user_mailer', | ||
template_name: 'in_progress_reminder') | ||
end | ||
|
||
def peer_review_delete_notification(resource) | ||
logger.warn('Unable to send peer_review_delete_notification; nil resource') unless resource.present? | ||
return unless resource.present? | ||
|
||
assign_variables(resource) | ||
return unless @user.present? && user_email(@user).present? | ||
|
||
mail(to: user_email(@user), | ||
subject: "#{rails_env}REMINDER: Dryad submission \"#{@resource.title}\"", | ||
template_path: 'stash_engine/user_mailer', | ||
template_name: 'peer_review_reminder') | ||
end | ||
|
||
def action_required_delete_notification(resource) | ||
logger.warn('Unable to send action_required_delete_notification; nil resource') unless resource.present? | ||
return unless resource.present? | ||
|
||
assign_variables(resource) | ||
return unless @user.present? && user_email(@user).present? | ||
|
||
mail(to: user_email(@user), | ||
subject: "#{rails_env}REMINDER: Dryad submission \"#{@resource.title}\"", | ||
template_path: 'stash_engine/user_mailer', | ||
template_name: 'chase_action_required1') | ||
end | ||
|
||
def send_set_to_withdrawn_notification(resource) | ||
logger.warn('Unable to send set_to_withdrawn_notification; nil resource') unless resource.present? | ||
return unless resource.present? | ||
|
||
assign_variables(resource) | ||
return unless @user.present? && user_email(@user).present? | ||
|
||
mail(to: user_email(@user), | ||
subject: "#{rails_env}NOTIFICATION: Dryad submission set to withdrawn \"#{@resource.title}\"") | ||
end | ||
|
||
def send_final_withdrawn_notification(resource) | ||
logger.warn('Unable to send send_final_withdrawn_notification; nil resource') unless resource.present? | ||
return unless resource.present? | ||
|
||
assign_variables(resource) | ||
return unless @user.present? && user_email(@user).present? | ||
|
||
mail(to: user_email(@user), | ||
subject: "#{rails_env}FINAL NOTIFICATION: Dryad submission will be deleted \"#{@resource.title}\"") | ||
end | ||
|
||
def delete_notification(resource) | ||
logger.warn('Unable to send delete_notification; nil resource') unless resource.present? | ||
return unless resource.present? | ||
|
||
assign_variables(resource) | ||
return unless @user.present? && user_email(@user).present? | ||
|
||
mail(to: user_email(@user), | ||
subject: "#{rails_env}DELETE NOTIFICATION: Dryad submission was deleted \"#{@resource.title}\"") | ||
end | ||
|
||
private | ||
|
||
# rubocop:disable Style/NestedTernaryOperator | ||
def user_email(user) | ||
user.present? ? (user.respond_to?(:author_email) ? user.author_email : user.email) : nil | ||
end | ||
|
||
def user_name(user) | ||
user.present? ? (user.respond_to?(:author_standard_name) ? user.author_standard_name : user.name) : nil | ||
end | ||
|
||
# rubocop:enable Style/NestedTernaryOperator | ||
|
||
def assign_variables(resource) | ||
@resource = resource | ||
@user = resource.owner_author || resource.user | ||
@user_name = user_name(@user) | ||
@helpdesk_email = APP_CONFIG['helpdesk_email'] || 'help@datadryad.org' | ||
@bcc_emails = APP_CONFIG['submission_bc_emails'] || [@helpdesk_email] | ||
@submission_error_emails = APP_CONFIG['submission_error_email'] || [@helpdesk_email] | ||
@page_error_emails = APP_CONFIG['page_error_email'] || [@helpdesk_email] | ||
end | ||
|
||
def rails_env | ||
return "[#{Rails.env}] " unless Rails.env.include?('production') | ||
|
||
'' | ||
end | ||
|
||
def address_list(addresses) | ||
addresses = [addresses] unless addresses.respond_to?(:join) | ||
addresses.flatten.reject(&:blank?).join(',') | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,8 @@ def waiver_add? | |
@user.superuser? | ||
end | ||
|
||
def change_delete_schedule? | ||
@user.superuser? | ||
end | ||
end | ||
end |
Oops, something went wrong.