Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a hold_emails attrirbute to super users #2313

Merged
merged 2 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/assets/javascripts/catalog_manager/form.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ $ ->
type: 'PUT'
url: "/catalog_manager/super_user?super_user[identity_id]=#{identity_id}&super_user[organization_id]=#{organization_id}&super_user[access_empty_protocols]=#{access_empty_protocols}"

$(document).on 'change', '.su-hold-emails', ->
identity_id = $(this).data('identity-id')
organization_id = $(this).data('organization-id')
hold_emails = $(this).prop('checked')

$.ajax
type: 'PUT'
url: "/catalog_manager/super_user?super_user[identity_id]=#{identity_id}&super_user[organization_id]=#{organization_id}&super_user[hold_emails]=#{hold_emails}"

$(document).on 'change', '.su-allow-credit', ->
identity_id = $(this).data('identity-id')
organization_id = $(this).data('organization-id')
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/catalog_manager/super_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def super_user_params
:organization_id,
:access_empty_protocols,
:billing_manager,
:allow_credit)
:allow_credit,
:hold_emails)
end
end
4 changes: 3 additions & 1 deletion app/controllers/surveyor/responses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ def destroy
def complete
@response = Response.find(params[:response_id])
if @response.respondable_id && @response.respondable.organization.survey_completion_alerts
### sent emails to all relevant super users for an organization of which survey_completion_alerts is true
### Per discussions, if Survey Alert is checked for the organization, email alerts go out
### to those relevant super users who want to receive emails.
@response.respondable.organization.all_super_users.each do |su|
next if su.hold_emails
SurveyNotification.service_survey_completed(@response, @response.respondable, su).deliver_later
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@
- if !su.nil?
.form_row
.row
.col-sm-6
.col-sm-4
= label_tag :hold_emails, t(:catalog_manager)[:organization_form][:user_rights][:su_hold_emails], class: 'non_bold_label'
.col-sm-4
= label_tag :access_empty_protocols, t(:catalog_manager)[:organization_form][:user_rights][:access_empty_protocols], class: 'non_bold_label'
.col-sm-6
.col-sm-4
= label_tag :billing_manager, t(:catalog_manager)[:organization_form][:user_rights][:billing_manager], class: 'non_bold_label'
.row
.col-sm-6
.col-sm-4
= check_box_tag :hold_emails, true, su.hold_emails, { id: "su-hold-emails-#{user.id}", class: "su-hold-emails", data: { identity_id: user.id, organization_id: organization.id } }
.col-sm-4
= check_box_tag :access_empty_protocols, true, su.try(:access_empty_protocols), { id: "su-access-empty-protocols-#{user.id}", class: "su-access-empty-protocols", data: { identity_id: user.id, organization_id: organization.id } }
.col-sm-6
.col-sm-4
= check_box_tag :billing_manager, true, su.try(:billing_manager), { id: "su-billing-manager-#{user.id}", class: "su-billing-manager", data: { identity_id: user.id, organization_id: organization.id } }
- if su.try(:billing_manager).present?
.form_row
Expand Down
1 change: 1 addition & 0 deletions config/locales/catalog_manager.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ en:
allow_credit: "Allow Credit"
name_email: "Name, Email"
super_user: "Super User"
su_hold_emails: "Hold Email"
access_empty_protocols: "Empty Protocols"
billing_manager: "Billing Manager"
catalog_manager: "Catalog Manager"
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20200423153027_add_hold_emails_to_super_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddHoldEmailsToSuperUsers < ActiveRecord::Migration[5.2]
def change
add_column :super_users, :hold_emails, :boolean, default: true
end
end