Class: Decidim::Meetings::JoinMeeting
- Inherits:
-
Command
- Object
- Command
- Decidim::Meetings::JoinMeeting
- Defined in:
- app/commands/decidim/meetings/join_meeting.rb
Overview
This command is executed when the user joins a meeting.
Instance Method Summary collapse
-
#call ⇒ Object
Creates a meeting registration if the meeting has registrations enabled and there are available slots.
-
#initialize(meeting, form) ⇒ JoinMeeting
constructor
Initializes a JoinMeeting Command.
Constructor Details
#initialize(meeting, form) ⇒ JoinMeeting
Initializes a JoinMeeting Command.
meeting - The current instance of the meeting to be joined. form - A form object with params; can be a questionnaire.
12 13 14 15 16 |
# File 'app/commands/decidim/meetings/join_meeting.rb', line 12 def initialize(meeting, form) @meeting = meeting @user_group = Decidim::UserGroup.find_by(id: form.user_group_id) @form = form end |
Instance Method Details
#call ⇒ Object
Creates a meeting registration if the meeting has registrations enabled and there are available slots.
Broadcasts :ok if successful, :invalid otherwise.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/commands/decidim/meetings/join_meeting.rb', line 22 def call return broadcast(:invalid) unless can_join_meeting? return broadcast(:invalid_form) unless form.valid? return broadcast(:invalid) if answer_questionnaire == :invalid meeting.with_lock do create_registration accept_invitation send_email_confirmation send_notification_confirmation notify_admin_over_percentage increment_score end follow_meeting broadcast(:ok) end |