|
|
|
@ -18,6 +18,7 @@ class SchemesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def show |
|
|
|
|
@scheme = Scheme.find_by(id: params[:id]) |
|
|
|
|
render_not_found and return unless @scheme |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def new |
|
|
|
@ -42,7 +43,13 @@ class SchemesController < ApplicationController
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def edit |
|
|
|
|
render_not_found and return unless @scheme |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def update |
|
|
|
|
render_not_found and return unless @scheme |
|
|
|
|
|
|
|
|
|
check_answers = params[:scheme][:check_answers] |
|
|
|
|
page = params[:scheme][:page] |
|
|
|
|
|
|
|
|
@ -64,34 +71,50 @@ class SchemesController < ApplicationController
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def primary_client_group |
|
|
|
|
render_not_found and return unless @scheme |
|
|
|
|
|
|
|
|
|
render "schemes/primary_client_group" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def confirm_secondary_client_group |
|
|
|
|
render_not_found and return unless @scheme |
|
|
|
|
|
|
|
|
|
render "schemes/confirm_secondary" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def secondary_client_group |
|
|
|
|
render_not_found and return unless @scheme |
|
|
|
|
|
|
|
|
|
render "schemes/secondary_client_group" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def support |
|
|
|
|
render_not_found and return unless @scheme |
|
|
|
|
|
|
|
|
|
render "schemes/support" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def details |
|
|
|
|
render_not_found and return unless @scheme |
|
|
|
|
|
|
|
|
|
render "schemes/details" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def check_answers |
|
|
|
|
render_not_found and return unless @scheme |
|
|
|
|
|
|
|
|
|
render "schemes/check_answers" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def edit_name |
|
|
|
|
render_not_found and return unless @scheme |
|
|
|
|
|
|
|
|
|
render "schemes/edit_name" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def support_services_provider |
|
|
|
|
render_not_found and return unless @scheme |
|
|
|
|
|
|
|
|
|
render "schemes/support_services_provider" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -193,11 +216,15 @@ private
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def arrangement_type_set_to_same_org?(required_params) |
|
|
|
|
arrangement_type_value(required_params[:arrangement_type]) == "D" || (required_params[:arrangement_type].blank? && @scheme.present? && @scheme.arrangement_type_same?) |
|
|
|
|
return unless @scheme |
|
|
|
|
|
|
|
|
|
arrangement_type_value(required_params[:arrangement_type]) == "D" || (required_params[:arrangement_type].blank? && @scheme.arrangement_type_same?) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def arrangement_type_changed_to_different_org?(required_params) |
|
|
|
|
@scheme.present? && @scheme.arrangement_type_same? && arrangement_type_value(required_params[:arrangement_type]) != "D" && required_params[:managing_organisation_id].blank? |
|
|
|
|
return unless @scheme |
|
|
|
|
|
|
|
|
|
@scheme.arrangement_type_same? && arrangement_type_value(required_params[:arrangement_type]) != "D" && required_params[:managing_organisation_id].blank? |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def arrangement_type_value(key) |
|
|
|
@ -215,7 +242,7 @@ private
|
|
|
|
|
def authenticate_scope! |
|
|
|
|
head :unauthorized and return unless current_user.data_coordinator? || current_user.support? |
|
|
|
|
|
|
|
|
|
if %w[show locations primary_client_group confirm_secondary_client_group secondary_client_group support details check_answers edit_name].include?(action_name) && !((current_user.organisation == @scheme.owning_organisation) || current_user.support?) |
|
|
|
|
if %w[show locations primary_client_group confirm_secondary_client_group secondary_client_group support details check_answers edit_name].include?(action_name) && !((current_user.organisation == @scheme&.owning_organisation) || current_user.support?) |
|
|
|
|
render_not_found and return |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|