|
1class Admin::Archived::DebateOutcomesController < Admin::AdminController
|
|
2 before_action :fetch_petition
|
|
3 before_action :fetch_debate_outcome
|
|
|
|
5 rescue_from ActiveRecord::RecordNotUnique do
|
|
6 @debate_outcome = @petition.debate_outcome(true) and update
|
|
|
|
|
|
|
|
10 render 'admin/archived/petitions/show'
|
|
|
|
|
|
|
|
14 if @debate_outcome.update(debate_outcome_params)
|
|
15 if send_email_to_petitioners?
|
|
16 ::Archived::EmailDebateOutcomesJob.run_later_tonight(petition: @petition)
|
|
17 message = :email_sent_overnight
|
|
|
|
19 message = :debate_outcome_updated
|
|
|
|
|
|
22 redirect_to admin_archived_petition_url(@petition), notice: message
|
|
|
|
24 render 'admin/archived/petitions/show'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 @petition = ::Archived::Petition.debateable.find(params[:petition_id])
|
|
|
|
|
|
34 def fetch_debate_outcome
|
|
35 @debate_outcome = @petition.debate_outcome || @petition.build_debate_outcome
|
|
|
|
|
|
38 def debate_outcome_params
|
|
39 params.require(:archived_debate_outcome).permit(*debate_outcome_attributes)
|
|
|
|
|
|
42 def debate_outcome_attributes
|
|
43 %i[debated_on overview transcript_url video_url debate_pack_url debated commons_image]
|
|
|
|
|
|
46 def send_email_to_petitioners?
|
|
47 params.key?(:save_and_email)
|
|
|
|
|