-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbase_controller.rb
More file actions
90 lines (76 loc) · 2.21 KB
/
base_controller.rb
File metadata and controls
90 lines (76 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# frozen_string_literal: true
module ParentInterface
class ConsentForms::BaseController < ApplicationController
skip_before_action :authenticate_user!
skip_after_action :verify_policy_scoped
prepend_before_action :set_team
prepend_before_action :set_programmes
prepend_before_action :set_organisation
prepend_before_action :set_session
prepend_before_action :set_consent_form
before_action :authenticate_consent_form_user!
before_action :set_privacy_policy_url
private
def set_consent_form
@consent_form =
ConsentForm.includes(:programmes, :vaccines).find(
params[:consent_form_id] || params[:id]
)
end
def set_session
if params[:session_slug]
@session = Session.find_by!(slug: params[:session_slug])
elsif @consent_form.present?
@session = @consent_form.original_session
end
end
def set_organisation
@organisation =
if @consent_form.present?
@consent_form.organisation
elsif @session.present?
@session.organisation
end
end
def set_programmes
@programmes =
if @consent_form.present?
@consent_form.programmes
elsif @session.present? && params[:programme_types].present?
@session.programmes.where(type: params[:programme_types].split("-"))
end
end
def set_team
@team =
if @consent_form.present?
@consent_form.team
elsif @session.present?
@session.team
end
end
def authenticate_consent_form_user!
unless session[:consent_form_id] == @consent_form.id
redirect_to @header_path
end
end
def set_header_path
@header_path =
start_parent_interface_consent_forms_path(
@session,
@programmes.map(&:to_param).join("-")
)
end
def set_service_name
@service_name = "Give or refuse consent for vaccinations"
end
def set_secondary_navigation
@show_secondary_navigation = false
end
def set_service_guide_url
@service_guide_url = nil
end
def set_privacy_policy_url
@privacy_policy_url = @organisation.privacy_policy_url
end
end
end