Skip to content

Commit

Permalink
Merge pull request #1168 from sparc-request/sj-fixes_for_settings
Browse files Browse the repository at this point in the history
SJ - Fixing numerous incorrect names in settings import file
  • Loading branch information
Stuart-Johnson committed Oct 26, 2017
2 parents ddf03ff + 8bfd802 commit be8f0a6
Show file tree
Hide file tree
Showing 30 changed files with 115 additions and 75 deletions.
8 changes: 4 additions & 4 deletions app/controllers/dashboard/protocols_controller.rb
Expand Up @@ -96,8 +96,8 @@ def new
@protocol.requester_id = current_user.id
@protocol.populate_for_edit
session[:protocol_type] = params[:protocol_type]
gon.rm_id_api_url = Setting.find_by_key("research_master_api_url").value
gon.rm_id_api_token = Setting.find_by_key("research_master_api_token").value
gon.rm_id_api_url = Setting.find_by_key("research_master_api").value
gon.rm_id_api_token = Setting.find_by_key("rmid_api_token").value
rmid_server_status(@protocol)
end

Expand Down Expand Up @@ -135,8 +135,8 @@ def edit
@permission_to_edit = @authorization.nil? ? false : @authorization.can_edit?
@in_dashboard = true
@protocol.populate_for_edit
gon.rm_id_api_url = Setting.find_by_key("research_master_api_url").value
gon.rm_id_api_token = Setting.find_by_key("research_master_api_token").value
gon.rm_id_api_url = Setting.find_by_key("research_master_api").value
gon.rm_id_api_token = Setting.find_by_key("rmid_api_token").value

session[:breadcrumbs].
clear.
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/protocols_controller.rb
Expand Up @@ -34,8 +34,8 @@ def new
@protocol.requester_id = current_user.id
@service_request = ServiceRequest.find(params[:srid])
@protocol.populate_for_edit
gon.rm_id_api_url = Setting.find_by_key("research_master_api_url").value
gon.rm_id_api_token = Setting.find_by_key("research_master_api_token").value
gon.rm_id_api_url = Setting.find_by_key("research_master_api").value
gon.rm_id_api_token = Setting.find_by_key("rmid_api_token").value
rmid_server_status(@protocol)
end

Expand Down Expand Up @@ -83,8 +83,8 @@ def edit
@protocol.populate_for_edit
@protocol.valid?
@errors = @protocol.errors
gon.rm_id_api_url = Setting.find_by_key("research_master_api_url").value
gon.rm_id_api_token = Setting.find_by_key("research_master_api_token").value
gon.rm_id_api_url = Setting.find_by_key("research_master_api").value
gon.rm_id_api_token = Setting.find_by_key("rmid_api_token").value
rmid_server_status(@protocol)

respond_to do |format|
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/protocols_helper.rb
Expand Up @@ -52,7 +52,7 @@ def display_readonly_answer(answer)
end

def display_rmid_validated_protocol(protocol, option)
if Setting.find_by_key("use_research_master").value
if Setting.find_by_key("research_master_enabled").value
if protocol.rmid_validated?
content_tag(
:h6,
Expand Down
4 changes: 2 additions & 2 deletions app/lib/default_settings_populator.rb
Expand Up @@ -23,7 +23,7 @@ class DefaultSettingsPopulator

def initialize()
@records = JSON.parse(File.read('config/defaults.json'))
@application_config =
@application_config =
if File.exists? Rails.root.join('config', 'application.yml')
YAML.load_file(Rails.root.join('config', 'application.yml'))[Rails.env]
else
Expand Down Expand Up @@ -68,4 +68,4 @@ def get_type(value)
'string'
end
end
end
end
4 changes: 2 additions & 2 deletions app/lib/redcap_survey_emitter.rb
Expand Up @@ -59,7 +59,7 @@ def send_form
data = [record].to_json

fields = {
:token => Setting.find_by_key("redcap_api_token").value,
:token => Setting.find_by_key("redcap_token").value,
:content => 'record',
:format => 'json',
:type => 'flat',
Expand All @@ -78,7 +78,7 @@ def send_form

def latest_letter_id
fields = {
:token => Setting.find_by_key("redcap_api_token").value,
:token => Setting.find_by_key("redcap_token").value,
:content => 'record',
:format => 'json',
:type => 'flat'
Expand Down
8 changes: 4 additions & 4 deletions app/mailers/notifier.rb
Expand Up @@ -213,7 +213,7 @@ def notify_for_epic_user_approval protocol

subject = "#{@protocol.id} - Epic Rights Approval"

mail(:to => Setting.find_by_key("epic_rights_mail_to").value, :from => Setting.find_by_key("no_reply_from").value, :subject => subject)
mail(:to => Setting.find_by_key("approve_epic_rights_mail_to").value, :from => Setting.find_by_key("no_reply_from").value, :subject => subject)
end

def notify_primary_pi_for_epic_user_final_review protocol
Expand All @@ -233,7 +233,7 @@ def notify_primary_pi_for_epic_user_removal protocol, project_role

subject = "#{@protocol.id} - Epic User Removal"

mail(:to => Setting.find_by_key("epic_rights_mail_to").value, :from => Setting.find_by_key("no_reply_from").value, :subject => subject)
mail(:to => Setting.find_by_key("approve_epic_rights_mail_to").value, :from => Setting.find_by_key("no_reply_from").value, :subject => subject)
end

def notify_for_epic_access_removal protocol, project_role
Expand All @@ -242,7 +242,7 @@ def notify_for_epic_access_removal protocol, project_role

subject = "#{@protocol.id} - Remove Epic Access"

mail(:to => Setting.find_by_key("epic_rights_mail_to").value, :from => Setting.find_by_key("no_reply_from").value, :subject => subject)
mail(:to => Setting.find_by_key("approve_epic_rights_mail_to").value, :from => Setting.find_by_key("no_reply_from").value, :subject => subject)
end

def notify_for_epic_rights_changes protocol, project_role, previous_rights
Expand All @@ -253,7 +253,7 @@ def notify_for_epic_rights_changes protocol, project_role, previous_rights

subject = "#{@protocol.id} - Update Epic Access"

mail(:to => Setting.find_by_key("epic_rights_mail_to").value, :from => Setting.find_by_key("no_reply_from").value, :subject => subject)
mail(:to => Setting.find_by_key("approve_epic_rights_mail_to").value, :from => Setting.find_by_key("no_reply_from").value, :subject => subject)
end

def epic_queue_error protocol, error=nil
Expand Down
8 changes: 4 additions & 4 deletions app/models/protocol.rb
Expand Up @@ -96,18 +96,18 @@ class Protocol < ApplicationRecord

def rmid_requires_validation?
# bypassing rmid validations for overlords, admins, and super users only when in Dashboard [#139885925] & [#151137513]
self.bypass_rmid_validation ? false : Setting.find_by_key('use_research_master').value && has_human_subject_info?
self.bypass_rmid_validation ? false : Setting.find_by_key('research_master_enabled').value && has_human_subject_info?
end

def has_human_subject_info?
self.research_types_info.try(:human_subjects) || false
end

validate :existing_rm_id,
if: -> record { Setting.find_by_key("use_research_master").value && !record.research_master_id.nil? }
if: -> record { Setting.find_by_key("research_master_enabled").value && !record.research_master_id.nil? }

validate :unique_rm_id_to_protocol,
if: -> record { Setting.find_by_key("use_research_master").value && !record.research_master_id.nil? }
if: -> record { Setting.find_by_key("research_master_enabled").value && !record.research_master_id.nil? }

def self.to_csv(protocols)
CSV.generate do |csv|
Expand All @@ -121,7 +121,7 @@ def self.to_csv(protocols)
end

def existing_rm_id
rm_ids = HTTParty.get(Setting.find_by_key("research_master_api_url").value + 'research_masters.json', headers: {'Content-Type' => 'application/json', 'Authorization' => "Token token=\"#{Setting.find_by_key("research_master_api_token").value}\""})
rm_ids = HTTParty.get(Setting.find_by_key("research_master_api").value + 'research_masters.json', headers: {'Content-Type' => 'application/json', 'Authorization' => "Token token=\"#{Setting.find_by_key("rmid_api_token").value}\""})
ids = rm_ids.map{ |rm_id| rm_id['id'] }

if research_master_id.present? && !ids.include?(research_master_id)
Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/protocols/_summary.html.haml
Expand Up @@ -32,7 +32,7 @@
= display_archive_button(protocol, permission_to_edit)
.clearfix
.panel-body#protocol-summary.text-left
- if Setting.find_by_key("use_research_master").value && protocol.is_study?
- if Setting.find_by_key("research_master_enabled").value && protocol.is_study?
.row
.col-sm-2
%label
Expand Down
Expand Up @@ -25,7 +25,7 @@
.sub_text
= t(:protocols)[:studies][:information][:subtext]
.panel-body.container-fluid
- if Setting.find_by_key("use_research_master").value
- if Setting.find_by_key("research_master_enabled").value
.form-group.row
= form.label :research_master_id, class: 'col-lg-2 control-label rm-id' do
= link_to t(:protocols)[:studies][:information][:research_master_id], Setting.find_by_key("research_master_link").value, target: '_blank'
Expand All @@ -45,8 +45,8 @@
title: t(:protocols)[:tooltips][:short_title]
.col-lg-10
= form.text_field :short_title,
class: [('form-control'), (Setting.find_by_key("use_research_master").value ? 'rm-id-dependent rm-locked-fields' : '')],
disabled: Setting.find_by_key("use_research_master").value && protocol.research_master_id.present?
class: [('form-control'), (Setting.find_by_key("research_master_enabled").value ? 'rm-id-dependent rm-locked-fields' : '')],
disabled: Setting.find_by_key("research_master_enabled").value && protocol.research_master_id.present?

.form-group.row
= form.label :title,
Expand All @@ -56,8 +56,8 @@
title: t(:protocols)[:tooltips][:title]
.col-lg-10
= form.text_field :title,
class: [('form-control'), (Setting.find_by_key("use_research_master").value ? 'rm-id-dependent rm-locked-fields' : '')],
disabled: Setting.find_by_key("use_research_master").value && protocol.research_master_id.present?
class: [('form-control'), (Setting.find_by_key("research_master_enabled").value ? 'rm-id-dependent rm-locked-fields' : '')],
disabled: Setting.find_by_key("research_master_enabled").value && protocol.research_master_id.present?

.form-group.row#funding-status
= form.label :funding_status,
Expand Down
2 changes: 1 addition & 1 deletion app/views/protocols/_summary.html.haml
Expand Up @@ -28,7 +28,7 @@
= link_to I18n.t('protocols.edit', protocol_type: protocol_type), edit_protocol_path(protocol, srid: service_request.id, sub_service_request_id: sub_service_request_id), class: 'btn btn-warning edit-protocol-information-button'
.clearfix
.panel-body#protocol-summary.text-left
- if Setting.find_by_key("use_research_master").value && protocol.is_study?
- if Setting.find_by_key("research_master_enabled").value && protocol.is_study?
.row
.col-sm-3
%label
Expand Down
Expand Up @@ -25,7 +25,7 @@
.sub_text
= t(:protocols)[:studies][:information][:subtext]
.panel-body.container-fluid
- if Setting.find_by_key("use_research_master").value
- if Setting.find_by_key("research_master_enabled").value
.form-group.row
= form.label :research_master_id, class: 'col-lg-2 control-label rm-id' do
= link_to t(:protocols)[:studies][:information][:research_master_id], Setting.find_by_key("research_master_link").value, target: '_blank'
Expand All @@ -41,8 +41,8 @@
title: t(:protocols)[:tooltips][:short_title]
.col-lg-10
= form.text_field :short_title,
class: [('form-control'), (Setting.find_by_key("use_research_master").value ? 'rm-id-dependent rm-locked-fields' : '')],
disabled: Setting.find_by_key("use_research_master").value && protocol.research_master_id.present?
class: [('form-control'), (Setting.find_by_key("research_master_enabled").value ? 'rm-id-dependent rm-locked-fields' : '')],
disabled: Setting.find_by_key("research_master_enabled").value && protocol.research_master_id.present?

.form-group.row
= form.label :title,
Expand All @@ -52,8 +52,8 @@
title: t(:protocols)[:tooltips][:title]
.col-lg-10
= form.text_field :title,
class: [('form-control'), (Setting.find_by_key("use_research_master").value ? 'rm-id-dependent rm-locked-fields' : '')],
disabled: Setting.find_by_key("use_research_master").value && protocol.research_master_id.present?
class: [('form-control'), (Setting.find_by_key("research_master_enabled").value ? 'rm-id-dependent rm-locked-fields' : '')],
disabled: Setting.find_by_key("research_master_enabled").value && protocol.research_master_id.present?

.form-group.row#funding-status
= form.label :funding_status,
Expand Down
Expand Up @@ -24,7 +24,7 @@
= t(:protocols)[:studies][:information][:header]
%table.table
%tbody
- if Setting.find_by_key("use_research_master").value
- if Setting.find_by_key("research_master_enabled").value
%tr.row
%td
%label.col-lg-4
Expand Down
2 changes: 1 addition & 1 deletion app/views/service_requests/navigation/_footer.html.haml
Expand Up @@ -32,7 +32,7 @@
- if service_request.submitted_at.blank? && service_request.protocol.present?
= save_as_draft_button(sub_service_request_id)
-# This was extracted because the surveyor gem requires an href location to redirect to post-submit and it was being cranky
- if Setting.find_by_key("use_system_satisfaction_survey").value && action_name == 'review'
- if Setting.find_by_key("system_satisfaction_survey").value && action_name == 'review'
.col-sm-3.text-right
= link_to t(:proper)[:navigation][:bottom][:submit],
confirmation_service_request_path(service_request, sub_service_request_id: sub_service_request_id),
Expand Down
2 changes: 1 addition & 1 deletion app/views/service_requests/review.html.haml
Expand Up @@ -33,7 +33,7 @@
= render 'service_requests/review/calendars', service_request: @service_request, sub_service_request: @sub_service_request, pages: @pages, tab: @tab, arm: @arm, portal: @portal, admin: @admin, review: @review, merged: @merged, consolidated: @consolidated, display_all_services: @display_all_services
= render 'service_requests/navigation/footer', service_request: @service_request, sub_service_request_id: @sub_service_request.try(:id), css_class: @css_class, back: @back, forward: @forward

- if Setting.find_by_key("use_system_satisfaction_survey").value
- if Setting.find_by_key("system_satisfaction_survey").value
= javascript_include_tag 'system_satisfaction'
= hidden_field_tag :use_system_satisfaction, 'true'
= render 'service_requests/modals/participate_in_survey_modal'
43 changes: 21 additions & 22 deletions config/defaults.json
Expand Up @@ -99,19 +99,18 @@
"parent_key": "queue_epic",
"parent_value": "true"
},
// This is not defined in application.yml.example. Is this still used?
// {
// "key": "epic_queue_report_to",
// "value": "jug2@musc.edu",
// "friendly_name": "Epic Queue Report To",
// "description": "Email addresses of users who are e-mailed the EPIC queue report.",
// "group": "",
// "version": "",
// "parent_key": "queue_epic",
// "parent_value": "true"
// },
{
"key": "epic_rights_mail_to",
{
"key": "epic_queue_report_to",
"value": "catesa@musc.edu, forney@musc.edu, crossoml@musc.edu, moreira@musc.edu, powersp@musc.edu, rogersbr@musc.edu",
"friendly_name": "Epic Queue Report To",
"description": "Email addresses of users who are e-mailed the EPIC queue report.",
"group": "",
"version": "",
"parent_key": "queue_epic",
"parent_value": "true"
},
{
"key": "approve_epic_rights_mail_to",
"value": "forney@musc.edu, crossoml@musc.edu",
"friendly_name": "EPIC Rights Mail-To",
"description": "Email addresses of users who are e-mailed for EPIC rights approval",
Expand Down Expand Up @@ -291,7 +290,7 @@
"parent_value": "true"
},
{
"key": "redcap_api_token",
"key": "redcap_token",
"value": "",
"friendly_name": "Redcap API Token",
"description": "The token used to access the Redcap API.",
Expand Down Expand Up @@ -361,27 +360,27 @@
"parent_value": ""
},
{
"key": "research_master_api_url",
"key": "research_master_api",
"value": "https://research-master-staging.musc.edu/api/",
"friendly_name": "Research Master API URL",
"description": "The URL of the Research Master ID API.",
"group": "",
"version": "",
"parent_key": "use_research_master",
"parent_key": "research_master_enabled",
"parent_value": "true"
},
{
"key": "research_master_api_token",
"key": "rmid_api_token",
"value": "e754d4e002bd58b4b1a55a3f5808ec37",
"friendly_name": "Research Master API Token",
"description": "The token used to access the Research Master ID API.",
"group": "",
"version": "",
"parent_key": "use_research_master",
"parent_key": "research_master_enabled",
"parent_value": "true"
},
{
"key": "use_research_master",
"key": "research_master_enabled",
"value": "false",
"friendly_name": "Use Research Master ID",
"description": "Determines whether the Research Master ID application should be used.",
Expand All @@ -397,7 +396,7 @@
"description": "The URL of the Research Master ID application.",
"group": "",
"version": "",
"parent_key": "use_research_master",
"parent_key": "research_master_enabled",
"parent_value": "true"
},
{
Expand Down Expand Up @@ -451,7 +450,7 @@
"parent_value": "true"
},
{
"key": "use_system_satisfaction_survey",
"key": "system_satisfaction_survey",
"value": "false",
"friendly_name": "Use System Satisfaction Survey",
"description": "Determines whether or not to display a System Satisfaction Survey prior to submitting a Service Request.",
Expand All @@ -467,7 +466,7 @@
"description": "This field will overwrite the system satisfaction survey mailers in the application to instead cc to this address. To be overwritten in development/testing/staging to prevent real emails being sent out to users.",
"group": "",
"version": "",
"parent_key": "use_system_satisfaction_survey",
"parent_key": "system_satisfaction_survey",
"parent_value": "true"
},
{
Expand Down

0 comments on commit be8f0a6

Please sign in to comment.