Class: Decidim::Meetings::RegistrationsController
- Inherits:
-
ApplicationController
- Object
- Components::BaseController
- ApplicationController
- Decidim::Meetings::RegistrationsController
- Includes:
- Forms::Concerns::HasQuestionnaire
- Defined in:
- app/controllers/decidim/meetings/registrations_controller.rb
Overview
Exposes the registration resource so users can join and leave meetings.
Instance Method Summary collapse
- #after_response_path ⇒ Object
- #allow_responses? ⇒ Boolean
- #create ⇒ Object
- #decline_invitation ⇒ Object
- #destroy ⇒ Object
- #join_waitlist ⇒ Object
- #questionnaire_for ⇒ Object
- #respond ⇒ Object
- #should_join_waitlist? ⇒ Boolean
-
#update_url ⇒ Object
You can implement this method in your controller to change the URL where the questionnaire will be submitted.
Instance Method Details
#after_response_path ⇒ Object
113 114 115 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 113 def after_response_path meeting_path(meeting) end |
#allow_responses? ⇒ Boolean
107 108 109 110 111 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 107 def allow_responses? return false unless meeting.registrations_enabled? && meeting.registration_form_enabled? meeting.has_available_slots? || should_join_waitlist? end |
#create ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 35 def create (:register, :meeting, meeting:) @form = JoinMeetingForm.from_params(params).with_context(current_user:) JoinMeeting.call(meeting, @form) do on(:ok) do flash[:notice] = I18n.t("registrations.create.success", scope: "decidim.meetings") redirect_after_path end on(:invalid) do flash.now[:alert] = I18n.t("registrations.create.invalid", scope: "decidim.meetings") redirect_after_path end end end |
#decline_invitation ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 87 def decline_invitation (:decline_invitation, :meeting, meeting:) DeclineInvitation.call(meeting, current_user) do on(:ok) do flash[:notice] = I18n.t("registrations.decline_invitation.success", scope: "decidim.meetings") redirect_after_path end on(:invalid) do flash.now[:alert] = I18n.t("registrations.decline_invitation.invalid", scope: "decidim.meetings") redirect_after_path end end end |
#destroy ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 71 def destroy (:leave, :meeting, meeting:) LeaveMeeting.call(meeting, current_user) do on(:ok) do flash[:notice] = I18n.t("registrations.destroy.success", scope: "decidim.meetings") redirect_after_path end on(:invalid) do flash.now[:alert] = I18n.t("registrations.destroy.invalid", scope: "decidim.meetings") redirect_after_path end end end |
#join_waitlist ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 53 def join_waitlist (:join_waitlist, :meeting, meeting:) @form = JoinMeetingForm.from_params(params).with_context(current_user:) JoinWaitlist.call(meeting, @form) do on(:ok) do flash[:notice] = I18n.t("registrations.waitlist.success", scope: "decidim.meetings") redirect_after_path end on(:invalid) do flash.now[:alert] = I18n.t("registrations.waitlist.invalid", scope: "decidim.meetings") redirect_after_path end end end |
#questionnaire_for ⇒ Object
123 124 125 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 123 def questionnaire_for meeting end |
#respond ⇒ Object
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 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 9 def respond (:join, :meeting, meeting:) @form = form(Decidim::Forms::QuestionnaireForm).from_params(params, session_token:) command = should_join_waitlist? ? JoinWaitlist : JoinMeeting joining_waitlist = should_join_waitlist? command.call(meeting, @form) do on(:ok) do flash[:notice] = I18n.t(joining_waitlist ? "registrations.waitlist.success" : "registrations.create.success", scope: "decidim.meetings") redirect_to after_response_path end on(:invalid) do flash.now[:alert] = I18n.t(joining_waitlist ? "registrations.waitlist.invalid" : "registrations.create.invalid", scope: "decidim.meetings") render template: "decidim/forms/questionnaires/show", status: :unprocessable_entity end on(:invalid_form) do flash.now[:alert] = I18n.t("response.invalid", scope: i18n_flashes_scope) render template: "decidim/forms/questionnaires/show", status: :unprocessable_entity end end end |
#should_join_waitlist? ⇒ Boolean
103 104 105 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 103 def should_join_waitlist? meeting.waitlist_enabled? && !meeting.has_available_slots? && !meeting.has_registration_for?(current_user) end |
#update_url ⇒ Object
You can implement this method in your controller to change the URL where the questionnaire will be submitted.
119 120 121 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 119 def update_url respond_meeting_registration_path(meeting_id: meeting.id) end |