Check if debate phase is open to create answers
This commit is contained in:
@@ -9,12 +9,19 @@ class Legislation::AnswersController < Legislation::BaseController
|
||||
respond_to :html, :js
|
||||
|
||||
def create
|
||||
@answer.user = current_user
|
||||
@answer.save
|
||||
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
format.html { redirect_to legislation_process_question_path(@process, @question) }
|
||||
if @process.open_phase?(:debate)
|
||||
@answer.user = current_user
|
||||
@answer.save
|
||||
track_event
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html { redirect_to legislation_process_question_path(@process, @question) }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html { redirect_to legislation_process_question_path(@process, @question), alert: t('legislation.questions.participation.phase_not_open') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,4 +31,11 @@ class Legislation::AnswersController < Legislation::BaseController
|
||||
:legislation_question_option_id,
|
||||
)
|
||||
end
|
||||
|
||||
def track_event
|
||||
ahoy.track "legislation_answer_created".to_sym,
|
||||
"legislation_answer_id": @answer.id,
|
||||
"legislation_question_option_id": @answer.legislation_question_option_id,
|
||||
"legislation_question_id": @answer.legislation_question_id
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user