diff --git a/Gemfile.lock b/Gemfile.lock index a330277..2c2ea35 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -100,7 +100,7 @@ activesupport (>= 4.2.0) hashdiff (0.3.7) hashie (3.5.7) - htmltoword (0.7.0) + htmltoword (1.0.0) actionpack nokogiri rubyzip (>= 1.0) diff --git a/app/controllers/org_admin/phases_controller.rb b/app/controllers/org_admin/phases_controller.rb index 827f4f3..ed47690 100644 --- a/app/controllers/org_admin/phases_controller.rb +++ b/app/controllers/org_admin/phases_controller.rb @@ -26,12 +26,9 @@ def edit phase = Phase.includes(:template).find(params[:id]) authorize phase - if !phase.template.latest? - flash[:notice] = _('You are viewing a historical version of this template. You will not be able to make changes.') - end section = params.fetch(:section, nil) # User cannot edit a phase if its a customization so redirect to show - if phase.template.customization_of.present? + if phase.template.customization_of.present? || !phase.template.latest? redirect_to org_admin_template_phase_path(template_id: phase.template, id: phase.id, section: section) else render('container', diff --git a/app/controllers/org_admin/sections_controller.rb b/app/controllers/org_admin/sections_controller.rb index 27e1b14..38bfd62 100644 --- a/app/controllers/org_admin/sections_controller.rb +++ b/app/controllers/org_admin/sections_controller.rb @@ -36,7 +36,8 @@ def edit section = Section.includes({phase: :template}, questions: [:question_options, { annotations: :org }]).find(params[:id]) authorize section - render partial: 'edit', + # User cannot edit a section if its not modifiable or the template is not the latest redirect to show + render partial: (section.modifiable? && section.phase.template.latest? ? 'edit' : 'show'), locals: { template: section.phase.template, phase: section.phase, diff --git a/app/controllers/org_admin/templates_controller.rb b/app/controllers/org_admin/templates_controller.rb index bea37d6..826dcd1 100644 --- a/app/controllers/org_admin/templates_controller.rb +++ b/app/controllers/org_admin/templates_controller.rb @@ -96,13 +96,14 @@ order('phases.number', 'sections.number', 'questions.number', 'question_options.number'). select('phases.title', 'phases.description', 'sections.title', 'questions.text', 'question_options.text') if !template.latest? - flash[:notice] = _("You are viewing a historical version of this #{template_type(template)}. You will not be able to make changes.") + redirect_to org_admin_template_path(id: template.id) + else + render 'container', locals: { + partial_path: 'edit', + template: template, + phases: phases, + referrer: get_referrer(template, request.referrer) } end - render 'container', locals: { - partial_path: 'edit', - template: template, - phases: phases, - referrer: get_referrer(template, request.referrer) } end # GET /org_admin/templates/new diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 0eca997..46509f0 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -16,7 +16,11 @@ end + def privacy + end + +end def tutorials end -end \ No newline at end of file +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c759af8..5482157 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -91,7 +91,7 @@ def update_email_preferences prefs = params[:prefs] - authorize current_user, :update? + authorize User pref = current_user.pref # does user not have prefs? if pref.blank? diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb index e55a870..4a3bc31 100644 --- a/app/policies/user_policy.rb +++ b/app/policies/user_policy.rb @@ -1,43 +1,52 @@ class UserPolicy < ApplicationPolicy + attr_reader :signed_in_user attr_reader :user - def initialize(user, users) - raise Pundit::NotAuthorizedError, "must be logged in" unless user + def initialize(signed_in_user, user) + raise Pundit::NotAuthorizedError, "must be logged in" unless signed_in_user + @signed_in_user = signed_in_user @user = user - @users = users - end - - def admin_index? - @user.can_grant_permissions? end def index? admin_index? end + def admin_index? + signed_in_user.can_grant_permissions? + end + def admin_grant_permissions? - @user.can_grant_permissions? && ((@users.org_id == @user.org_id) || @user.can_super_admin?) + (signed_in_user.can_grant_permissions? && user.org_id == signed_in_user.org_id) || signed_in_user.can_super_admin? end def admin_update_permissions? - @user.can_grant_permissions? && ((@users.org_id == @user.org_id) || @user.can_super_admin?) + (signed_in_user.can_grant_permissions? && user.org_id == signed_in_user.org_id) || signed_in_user.can_super_admin? end # Allows the user to swap their org affiliation on the fly def org_swap? - user.can_super_admin? + signed_in_user.can_super_admin? end def activate? - user.can_super_admin? + signed_in_user.can_super_admin? end def edit? - user.can_super_admin? + signed_in_user.can_super_admin? end def update? - user.can_super_admin? + signed_in_user.can_super_admin? + end + + def update_email_preferences? + true + end + + def acknowledge_notification? + true end class Scope < Scope @@ -45,8 +54,4 @@ scope.where(org_id: user.org_id) end end - - def acknowledge_notification? - true - end end diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index 862d5c5..ecd75c0 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -13,7 +13,7 @@
<%= _("Last modified: ") + l(@plan.updated_at.to_date, formats: :short) %>
<%= _("Copyright information:") %>
-<%= _(" The above plan creator(s) have agreed that others may use as much of the text of this plan as they would like in their own plans, and customise it as necessary. You do not need to credit the creator(s) as the source of the language used, but using any of the plan's text does not imply that the creator(s) endorse, or have any relationship to, your project or proposal") %>
<%= _("Copyright information:") %>
+<%= _(" The above plan creator(s) have agreed that others may use as much of the text of this plan as they would like in their own plans, and customise it as necessary. You do not need to credit the creator(s) as the source of the language used, but using any of the plan's text does not imply that the creator(s) endorse, or have any relationship to, your project or proposal") %>
<%= _("The information you provide will be used by the %{org_name} to offer you access to and personalisation of the %{application_name} service.") % + { :application_name => Rails.configuration.branding[:application][:name], :org_name => Rails.configuration.branding[:organisation][:name] } %>
+<%= _("The %{org_name} processes the personal data of %{application_name} users in order to deliver and improve the %{application_name} service in a customised manner and to ensure each user receives relevant information.") % + { :application_name => Rails.configuration.branding[:application][:name], :org_name => Rails.configuration.branding[:organisation][:name] } %>
+<%= _("The processing of your personal data by the %{org_name} is necessary for pursuing the following legitimate interests:") % + { :application_name => Rails.configuration.branding[:application][:name], :org_name => Rails.configuration.branding[:organisation][:name] } %>
+<%= _("We will hold the personal data you provided us for as long as you continue using the %{application_name} service. Your personal data can be removed from this service upon request to the %{application_name} team within a period of 30 days.") % + { :application_name => Rails.configuration.branding[:application][:name] } %>
+<%= raw _("If you have any questions, please contact the %{application_name} team at: %{helpdesk_email}") % + { :application_name => Rails.configuration.branding[:application][:name], :helpdesk_email => Rails.configuration.branding[:organisation][:helpdesk_email] } %>
+<%= _("This statement was last revised on %{revdate} and may be revised at any time with prior notice.") % + { :revdate => "May 21st, 2018" }%>
+