class Decidim::Meetings::Admin::UpdateQuestionStatus
panel.
This command is executed when the user changes a Questionnaire from the admin
def call
Updates the questionnaire if valid.
def call Decidim::Meetings::Question.transaction do update_question end broadcast(:ok) rescue InvalidStatus broadcast(:invalid) end
def initialize(question, current_user)
form - The form from which to get the data.
Initializes a UpdateQuestionnaire Command.
def initialize(question, current_user) @question = question @current_user = current_user end
def new_status(question)
def new_status(question) if question.unpublished? Decidim::Meetings::Question.statuses[:published] elsif question.published? Decidim::Meetings::Question.statuses[:closed] else raise InvalidStatus end end
def update_question
def update_question Decidim.traceability.update!( question, current_user, status: new_status(question) ) end