diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index bccf089..3c83335 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,4 +1,7 @@
+# frozen_string_literal: true
+
class ApplicationController < ActionController::Base
+
protect_from_forgery with: :exception
# Look for template overrides before rendering
@@ -22,9 +25,9 @@
def user_not_authorized
if user_signed_in?
- redirect_to plans_url, alert: _('You are not authorized to perform this action.')
+ redirect_to plans_url, alert: _("You are not authorized to perform this action.")
else
- redirect_to root_url, alert: _('You need to sign in or sign up before continuing.')
+ redirect_to root_url, alert: _("You need to sign in or sign up before continuing.")
end
end
@@ -34,7 +37,8 @@
end
def store_location
- # store last url - this is needed for post-login redirect to whatever the user last visited.
+ # store last url - this is needed for post-login redirect to whatever the user last
+ # visited.
unless ["/users/sign_in",
"/users/sign_up",
"/users/password",
@@ -47,7 +51,9 @@
def after_sign_in_path_for(resource)
referer_path = URI(request.referer).path unless request.referer.nil? or nil
- if from_external_domain? || referer_path.eql?(new_user_session_path) || referer_path.eql?(new_user_registration_path) || referer_path.nil?
+ if from_external_domain? || referer_path.eql?(new_user_session_path) ||
+ referer_path.eql?(new_user_registration_path) ||
+ referer_path.nil?
root_path
else
request.referer
@@ -55,8 +61,10 @@
end
def after_sign_up_path_for(resource)
- referer_path = URI(request.referer).path unless request.referer.nil? or nil
- if from_external_domain? || referer_path.eql?(new_user_session_path) || referer_path.nil?
+ referer_path = URI(request.referer).path unless request.referer.nil?
+ if from_external_domain? ||
+ referer_path.eql?(new_user_session_path) ||
+ referer_path.nil?
root_path
else
request.referer
@@ -73,23 +81,27 @@
def authenticate_admin!
# currently if admin has any super-admin task, they can view the super-admin
- redirect_to root_path unless user_signed_in? && (current_user.can_add_orgs? || current_user.can_change_org? || current_user.can_super_admin?)
+ unless user_signed_in? && (current_user.can_add_orgs? ||
+ current_user.can_change_org? ||
+ current_user.can_super_admin?)
+ redirect_to root_path
+ end
end
def failed_create_error(obj, obj_name)
- "#{_('Could not create your %{o}.') % {o: obj_name}} #{errors_to_s(obj)}"
+ "#{_('Could not create your %{o}.') % { o: obj_name }} #{errors_to_s(obj)}"
end
def failed_update_error(obj, obj_name)
- "#{_('Could not update your %{o}.') % {o: obj_name}} #{errors_to_s(obj)}"
+ "#{_('Could not update your %{o}.') % { o: obj_name }} #{errors_to_s(obj)}"
end
def failed_destroy_error(obj, obj_name)
- "#{_('Could not delete the %{o}.') % {o: obj_name}} #{errors_to_s(obj)}"
+ "#{_('Could not delete the %{o}.') % { o: obj_name }} #{errors_to_s(obj)}"
end
def success_message(obj_name, action)
- "#{_('Successfully %{action} your %{object}.') % {object: obj_name, action: action}}"
+ _("Successfully %{action} your %{object}.") % { object: obj_name, action: action }
end
# Override rails default render action to look for a branded version of a
@@ -106,8 +118,8 @@
def errors_to_s(obj)
if obj.errors.count > 0
msg = "
"
- obj.errors.each do |e,m|
- if m.include?('empty') || m.include?('blank')
+ obj.errors.each do |e, m|
+ if m.include?("empty") || m.include?("blank")
msg += "#{_(e)} - #{_(m)}
"
else
msg += "'#{obj[e]}' - #{_(m)}
"
@@ -139,4 +151,5 @@
false
end
end
+
end
diff --git a/app/helpers/template_helper.rb b/app/helpers/template_helper.rb
index eabff9a..3905e98 100644
--- a/app/helpers/template_helper.rb
+++ b/app/helpers/template_helper.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
module TemplateHelper
def template_details_path(template)
@@ -24,10 +26,11 @@
template.org_id = current_user.org.id
end
- def links_to_a_elements(links, separator = ', ')
+ def links_to_a_elements(links, separator = ", ")
a = links.map do |l|
"#{l['text']}"
end
a.join(separator)
end
-end
\ No newline at end of file
+
+end
diff --git a/app/models/section.rb b/app/models/section.rb
index 2aef5b1..49f9237 100644
--- a/app/models/section.rb
+++ b/app/models/section.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# == Schema Information
#
# Table name: sections
@@ -21,6 +23,7 @@
#
class Section < ActiveRecord::Base
+
include ValidationMessages
include ValidationValues
include ActsAsSortable
@@ -108,8 +111,8 @@
copy.phase_id = options.fetch(:phase_id, nil)
copy.save!(validate: false) if options.fetch(:save, false)
options[:section_id] = copy.id
- self.questions.map{ |question| copy.questions << question.deep_copy(options) }
- return copy
+ self.questions.map { |question| copy.questions << question.deep_copy(options) }
+ copy
end
# Can't be modified as it was duplicatd over from another Phase.
@@ -131,4 +134,5 @@
return if phase.nil?
self.number ||= phase.sections.maximum(:number).to_i + 1
end
+
end