class Decidim::Meetings::LeaveMeeting
This command is executed when the user leaves a meeting.
def call
and the registration exists.
Destroys a meeting registration if the meeting has registrations enabled
def call @meeting.with_lock do return broadcast(:invalid) unless registration destroy_registration destroy_questionnaire_answers decrement_score end broadcast(:ok) end
def decrement_score
def decrement_score Decidim::Gamification.decrement_score(@user, :attended_meetings) end
def destroy_questionnaire_answers
def destroy_questionnaire_answers questionnaire_answers.destroy_all end
def destroy_registration
def destroy_registration registration.destroy! end
def initialize(meeting, user)
meeting - The current instance of the meeting to be left.
Initializes a LeaveMeeting Command.
def initialize(meeting, user) @meeting = meeting @user = user end
def questionnaire_answers
def questionnaire_answers questionnaire = Decidim::Forms::Questionnaire.find_by(questionnaire_for_id: @meeting) questionnaire.answers.where(user: @user) end
def registration
def registration @registration ||= Decidim::Meetings::Registration.find_by(meeting: @meeting, user: @user) end