File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ class Sessions ::BaseController < ApplicationController
4+ before_action :set_session
5+
6+ private
7+
8+ def set_session
9+ @session =
10+ policy_scope ( Session ) . includes (
11+ :location_programme_year_groups ,
12+ programmes : :vaccines
13+ ) . find_by! ( slug : params [ :session_slug ] )
14+ end
15+ end
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3- class Sessions ::ConsentController < ApplicationController
3+ class Sessions ::ConsentController < Sessions :: BaseController
44 include PatientSearchFormConcern
55
6- before_action :set_session
76 before_action :set_statuses
87 before_action :set_patient_search_form
98
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3- class Sessions ::InviteToClinicController < ApplicationController
4- before_action :set_session
3+ class Sessions ::InviteToClinicController < Sessions :: BaseController
4+ before_action :check_can_send_clinic_invitations
55 before_action :set_generic_clinic_session
66 before_action :set_patients_to_invite
77 before_action :set_invitations_to_send
@@ -31,12 +31,7 @@ def update
3131
3232 private
3333
34- def set_session
35- @session =
36- authorize Session . includes ( :programmes ) . find_by! (
37- slug : params [ :session_slug ]
38- )
39-
34+ def check_can_send_clinic_invitations
4035 render status : :not_found unless @session . can_send_clinic_invitations?
4136 end
4237
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3- class Sessions ::ManageConsentRemindersController < ApplicationController
4- before_action :set_session
5-
3+ class Sessions ::ManageConsentRemindersController < Sessions ::BaseController
64 def show
75 end
86
@@ -14,10 +12,4 @@ def create
1412 success : "Manual consent reminders sent"
1513 }
1614 end
17-
18- private
19-
20- def set_session
21- @session = policy_scope ( Session ) . find_by! ( slug : params [ :session_slug ] )
22- end
2315end
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3- class Sessions ::PatientSpecificDirectionsController < ApplicationController
3+ class Sessions ::PatientSpecificDirectionsController < Sessions :: BaseController
44 include PatientSearchFormConcern
55
6- before_action :set_session
76 before_action :set_programme
87 before_action :set_vaccine
98 before_action :set_patient_search_form
@@ -38,10 +37,6 @@ def create
3837
3938 private
4039
41- def set_session
42- @session = policy_scope ( Session ) . find_by! ( slug : params [ :session_slug ] )
43- end
44-
4540 def set_programme
4641 # TODO: Handle PSDs in sessions with multiple programmes.
4742 @programme = @session . programmes . supports_delegation . first
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3- class Sessions ::PatientsController < ApplicationController
3+ class Sessions ::PatientsController < Sessions :: BaseController
44 include PatientSearchFormConcern
55
6- before_action :set_session
76 before_action :set_patient_search_form
87
98 layout "full"
@@ -18,13 +17,4 @@ def show
1817 @pagy , @patients =
1918 patients . is_a? ( Array ) ? pagy_array ( patients ) : pagy ( patients )
2019 end
21-
22- private
23-
24- def set_session
25- @session =
26- policy_scope ( Session ) . includes ( :location_programme_year_groups ) . find_by! (
27- slug : params [ :session_slug ]
28- )
29- end
3020end
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3- class Sessions ::RecordController < ApplicationController
3+ class Sessions ::RecordController < Sessions :: BaseController
44 include PatientSearchFormConcern
55 include TodaysBatchConcern
66
7- before_action :set_session
87 before_action :set_patient_search_form
98
109 before_action :set_programme , except : :show
@@ -68,13 +67,6 @@ def update_batch
6867
6968 private
7069
71- def set_session
72- @session =
73- policy_scope ( Session ) . includes ( programmes : :vaccines ) . find_by! (
74- slug : params [ :session_slug ]
75- )
76- end
77-
7870 def set_programme
7971 @programme = policy_scope ( Programme ) . find_by! ( type : params [ :programme_type ] )
8072 end
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3- class Sessions ::RegisterController < ApplicationController
3+ class Sessions ::RegisterController < Sessions :: BaseController
44 include PatientSearchFormConcern
55
6- before_action :set_session
76 before_action :set_patient_search_form , only : :show
87 before_action :set_session_date , only : :create
98 before_action :set_patient , only : :create
@@ -52,13 +51,6 @@ def create
5251
5352 private
5453
55- def set_session
56- @session =
57- policy_scope ( Session ) . includes ( programmes : :vaccines ) . find_by! (
58- slug : params [ :session_slug ]
59- )
60- end
61-
6254 def set_session_date
6355 @session_date = @session . session_dates . find_by! ( value : Date . current )
6456 end
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3- class Sessions ::TriageController < ApplicationController
3+ class Sessions ::TriageController < Sessions :: BaseController
44 include PatientSearchFormConcern
55
6- before_action :set_session
76 before_action :set_statuses
87 before_action :set_patient_search_form
98
@@ -29,13 +28,6 @@ def show
2928
3029 private
3130
32- def set_session
33- @session =
34- policy_scope ( Session ) . includes ( programmes : :vaccines ) . find_by! (
35- slug : params [ :session_slug ]
36- )
37- end
38-
3931 def set_statuses
4032 programmes = @session . programmes
4133
You can’t perform that action at this time.
0 commit comments