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_answer_path ⇒ Object
- #allow_answers? ⇒ Boolean
- #answer ⇒ Object
- #create ⇒ Object
- #decline_invitation ⇒ Object
- #destroy ⇒ Object
- #questionnaire_for ⇒ Object
-
#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_answer_path ⇒ Object
86 87 88 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 86 def after_answer_path meeting_path(meeting) end |
#allow_answers? ⇒ Boolean
82 83 84 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 82 def allow_answers? meeting.registrations_enabled? && meeting.registration_form_enabled? && meeting.has_available_slots? end |
#answer ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 9 def answer (:join, :meeting, meeting:) @form = form(Decidim::Forms::QuestionnaireForm).from_params(params, session_token:) JoinMeeting.call(meeting, @form) do on(:ok) do flash[:notice] = I18n.t("registrations.create.success", scope: "decidim.meetings") redirect_to after_answer_path end on(:invalid) do flash.now[:alert] = I18n.t("registrations.create.invalid", scope: "decidim.meetings") render template: "decidim/forms/questionnaires/show" end on(:invalid_form) do flash.now[:alert] = I18n.t("answer.invalid", scope: i18n_flashes_scope) render template: "decidim/forms/questionnaires/show" end end end |
#create ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 32 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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 66 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
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 50 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 |
#questionnaire_for ⇒ Object
96 97 98 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 96 def questionnaire_for meeting end |
#update_url ⇒ Object
You can implement this method in your controller to change the URL where the questionnaire will be submitted.
92 93 94 |
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 92 def update_url answer_meeting_registration_path(meeting_id: meeting.id) end |