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

KG - Display SRID on Proper Pages (1.7.0) #380

Merged
merged 8 commits into from
May 20, 2016
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
37 changes: 19 additions & 18 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def prepare_catalog

@events.reverse!

Alert.where(:alert_type => ALERT_TYPES['google_calendar'], :status => ALERT_STATUSES['active']).update_all(:status => ALERT_STATUSES['clear'])
Alert.where(alert_type: ALERT_TYPES['google_calendar'], status: ALERT_STATUSES['active']).update_all(status: ALERT_STATUSES['clear'])
rescue Exception => e
active_alert = Alert.where(alert_type: ALERT_TYPES['google_calendar'], status: ALERT_STATUSES['active']).first_or_initialize
if Rails.env == 'production' && active_alert.new_record?
Expand All @@ -75,9 +75,9 @@ def prepare_catalog
headers = page.css('.entry-header').take(3)
@news = []
headers.each do |header|
@news << {:title => header.at_css('.entry-title').text,
:link => header.at_css('.entry-title a')[:href],
:date => header.at_css('.date').text }
@news << {title: header.at_css('.entry-title').text,
link: header.at_css('.entry-title a')[:href],
date: header.at_css('.date').text }
end
end
end
Expand All @@ -86,13 +86,13 @@ def create_calendar_event event
all_day = !event.dtstart.to_s.include?("UTC")
start_time = Time.parse(event.dtstart.to_s).in_time_zone("Eastern Time (US & Canada)")
end_time = Time.parse(event.dtend.to_s).in_time_zone("Eastern Time (US & Canada)")
{ :month => start_time.strftime("%b"),
:day => start_time.day,
:title => event.summary,
:all_day => all_day,
:start_time => start_time.strftime("%l:%M %p"),
:end_time => end_time.strftime("%l:%M %p"),
:where => event.location
{ month: start_time.strftime("%b"),
day: start_time.day,
title: event.summary,
all_day: all_day,
start_time: start_time.strftime("%l:%M %p"),
end_time: end_time.strftime("%l:%M %p"),
where: event.location
}
end

Expand All @@ -102,7 +102,7 @@ def authorization_error msg, ref
error += "<br />If you believe this is in error please contact, #{I18n.t 'error_contact'}, and provide the following information:"
error += "<br /> Reference #: "
error += ref
render :partial => 'service_requests/authorization_error', :locals => {:error => error}
render 'service_requests/authorization_error', error: error
end

def clean_errors errors
Expand Down Expand Up @@ -166,8 +166,8 @@ def initialize_service_request
if session[:service_request_id]
use_existing_service_request
else
@service_request = ServiceRequest.new :status => 'first_draft'
@service_request.save :validate => false
@service_request = ServiceRequest.new(status: 'first_draft')
@service_request.save(validate: false)
@line_items = []
session[:service_request_id] = @service_request.id
end
Expand Down Expand Up @@ -228,9 +228,10 @@ def validate_existing_service_request
# Create a new service request and assign it to @service_request.
def create_new_service_request(from_portal=false)
status = from_portal ? 'draft' : 'first_draft'
@service_request = ServiceRequest.new :status => status
@service_request = ServiceRequest.new(status: status)

if params[:protocol_id] # we want to create a new service request that belongs to an existing protocol
if current_user and current_user.protocols.where(:id => params[:protocol_id]).empty? # this user doesn't have permission to create service request under this protocol
if current_user and current_user.protocols.where(id: params[:protocol_id]).empty? # this user doesn't have permission to create service request under this protocol
authorization_error "You are attempting to create a service request under a study/project that you do not have permissions to access.",
"PROTOCOL#{params[:protocol_id]}"
else # otherwise associate the service request with this protocol
Expand All @@ -245,9 +246,9 @@ def create_new_service_request(from_portal=false)
signed_up_but_not_approved = true
end

@service_request.save :validate => false
@service_request.save(validate: false)
session[:service_request_id] = @service_request.id
redirect_to catalog_service_request_path(@service_request, :signed_up_but_not_approved => signed_up_but_not_approved)
redirect_to catalog_service_request_path(@service_request, signed_up_but_not_approved: signed_up_but_not_approved)
end

def authorize_identity
Expand Down
44 changes: 22 additions & 22 deletions app/controllers/service_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def navigate
validates = params["validates"]

if (@validation_groups[location].nil? or @validation_groups[location].map{|vg| @service_request.group_valid? vg.to_sym}.all?) and (validates.blank? or @service_request.group_valid? validates.to_sym) and errors.empty?
@service_request.save(:validate => false)
@service_request.save(validate: false)
redirect_to "/service_requests/#{@service_request.id}/#{location}#{additional_params}"
else
if @validation_groups[location]
Expand Down Expand Up @@ -226,13 +226,13 @@ def obtain_research_pricing
@protocol = @service_request.protocol
# As the service request leaves draft, so too do the arms
@protocol.arms.each do |arm|
arm.update_attributes({:new_with_draft => false})
arm.update_attributes({new_with_draft: false})
end
@service_list = @service_request.service_list

send_confirmation_notifications

render :formats => [:html]
render formats: [:html]
end

def confirmation
Expand All @@ -243,15 +243,15 @@ def confirmation
@protocol = @service_request.protocol
# As the service request leaves draft, so too do the arms
@protocol.arms.each do |arm|
arm.update_attributes({:new_with_draft => false})
arm.update_attributes({new_with_draft: false})
if @protocol.service_requests.map {|x| x.sub_service_requests.map {|y| y.in_work_fulfillment}}.flatten.include?(true)
arm.populate_subjects
end
end
@service_list = @service_request.service_list

@service_request.sub_service_requests.each do |ssr|
ssr.update_attributes(:nursing_nutrition_approved => false, :lab_approved => false, :imaging_approved => false, :committee_approved => false)
ssr.update_attributes(nursing_nutrition_approved: false, lab_approved: false, imaging_approved: false, committee_approved: false)
end

send_confirmation_notifications
Expand All @@ -263,22 +263,22 @@ def confirmation
if @protocol.selected_for_epic
@protocol.ensure_epic_user
if QUEUE_EPIC
EpicQueue.create(:protocol_id => @protocol.id) unless EpicQueue.where(:protocol_id => @protocol.id).size == 1
EpicQueue.create(protocol_id: @protocol.id) unless EpicQueue.where(protocol_id: @protocol.id).size == 1
else
@protocol.awaiting_approval_for_epic_push
send_epic_notification_for_user_approval(@protocol)
end
end
end

render :formats => [:html]
render formats: [:html]
end

def send_confirmation_notifications
if @service_request.previous_submitted_at.nil?
send_notifications(@service_request, @sub_service_request)
elsif service_request_has_changed_ssr?(@service_request)
xls = render_to_string :action => 'show', :formats => [:xlsx]
xls = render_to_string action: 'show', formats: [:xlsx]
@service_request.sub_service_requests.each do |ssr|
if ssr_has_changed?(@service_request, ssr)
send_ssr_service_provider_notifications(@service_request, ssr, xls)
Expand All @@ -289,11 +289,11 @@ def send_confirmation_notifications

def approve_changes
@service_request = ServiceRequest.find params[:id]
@approval = @service_request.approvals.where(:id => params[:approval_id]).first
@approval = @service_request.approvals.where(id: params[:approval_id]).first
@previously_approved = true

if @approval and @approval.identity.nil?
@approval.update_attributes(:identity_id => current_user.id, :approval_date => Time.now)
@approval.update_attributes(identity_id: current_user.id, approval_date: Time.now)
@previously_approved = false
end
end
Expand Down Expand Up @@ -331,7 +331,7 @@ def add_service
existing_service_ids = @service_request.line_items.map(&:service_id)

if existing_service_ids.include? id
render :text => 'Service exists in line items'
render text: 'Service exists in line items'
else
service = Service.find id

Expand Down Expand Up @@ -391,7 +391,7 @@ def remove_service
ssr = @service_request.sub_service_requests.find_by_organization_id(org_id)
if !['first_draft', 'draft'].include?(@service_request.status) and !@service_request.submitted_at.nil? and @service_request.submitted_at > ssr.created_at
@protocol = @service_request.protocol
xls = @protocol.nil? ? nil : render_to_string(:action => 'show', :formats => [:xlsx])
xls = @protocol.nil? ? nil : render_to_string(action: 'show', formats: [:xlsx])
send_ssr_service_provider_notifications(@service_request, ssr, xls, ssr_deleted=true)
end
ssr.destroy
Expand All @@ -400,25 +400,25 @@ def remove_service
@service_request.reload

@line_items = (@sub_service_request.nil? ? @service_request.line_items : @sub_service_request.line_items)
render :formats => [:js]
render formats: [:js]
end

def ask_a_question
from = params['quick_question']['email'].blank? ? NO_REPLY_FROM : params['quick_question']['email']
body = params['quick_question']['body'].blank? ? 'No question asked' : params['quick_question']['body']

quick_question = QuickQuestion.create :to => DEFAULT_MAIL_TO, :from => from, :body => body
quick_question = QuickQuestion.create to: DEFAULT_MAIL_TO, from: from, body: body
Notifier.ask_a_question(quick_question).deliver
end

def feedback
feedback = Feedback.new(params[:feedback])
if feedback.save
Notifier.provide_feedback(feedback).deliver_now
render :nothing => true
render nothing: true
else
respond_to do |format|
format.js { render :status => 403, :json => feedback.errors.to_a.map {|k,v| "#{k.humanize} #{v}".rstrip + '.'} }
format.js { render status: 403, json: feedback.errors.to_a.map {|k,v| "#{k.humanize} #{v}".rstrip + '.'} }
end
end
end
Expand Down Expand Up @@ -450,7 +450,7 @@ def new_document

# Send notifications to all users.
def send_notifications(service_request, sub_service_request)
xls = render_to_string :action => 'show', :formats => [:xlsx]
xls = render_to_string action: 'show', formats: [:xlsx]
send_user_notifications(service_request, xls)

if sub_service_request then
Expand Down Expand Up @@ -562,7 +562,7 @@ def document_save_update errors

# add access
to_add.each do |org_id|
sub_service_request = @service_request.sub_service_requests.find_or_create_by(:organization_id => org_id.to_i)
sub_service_request = @service_request.sub_service_requests.find_or_create_by(organization_id: org_id.to_i)
sub_service_request.documents << doc_object
sub_service_request.save
end
Expand All @@ -579,17 +579,17 @@ def document_save_update errors
if doc_object
if @sub_service_request and doc_object.sub_service_requests.size > 1
new_doc = document ? document : doc_object.document # if no new document provided use the old document
newDocument = Document.create :document => new_doc, :doc_type => params[:doc_type], :doc_type_other => params[:doc_type_other], :service_request_id => @service_request.id
newDocument = Document.create(document: new_doc, doc_type: params[:doc_type], doc_type_other: params[:doc_type_other], service_request_id: @service_request.id)
@sub_service_request.documents << newDocument
@sub_service_request.documents.delete doc_object
@sub_service_request.save
else
new_doc = document || doc_object.document
doc_object.update_attributes(:document => new_doc, :doc_type => doc_type, :doc_type_other => doc_type_other)
doc_object.update_attributes(document: new_doc, doc_type: doc_type, doc_type_other: doc_type_other)
end
end
else # new document
newDocument = Document.create :document => document, :doc_type => doc_type, :doc_type_other => doc_type_other, :service_request_id => @service_request.id
newDocument = Document.create(document: document, doc_type: doc_type, doc_type_other: doc_type_other, service_request_id: @service_request.id)
process_ssr_organization_ids.each do |org_id|
sub_service_request = @service_request.sub_service_requests.find_by_organization_id org_id.to_i
sub_service_request.documents << newDocument
Expand Down Expand Up @@ -628,7 +628,7 @@ def authorize_protocol_edit_request
unless authorized
@service_request = nil
@sub_service_request = nil
render partial: 'service_requests/authorization_error', locals: { error: 'You are not allowed to edit this Request.' }
render 'service_requests/authorization_error', error: 'You are not allowed to edit this Request.'
end
end
end
Expand Down