app/commands/decidim/proposals/admin/answer_proposal.rb in decidim-proposals-0.26.1 vs app/commands/decidim/proposals/admin/answer_proposal.rb in decidim-proposals-0.26.2
- old
+ new
@@ -44,16 +44,21 @@
form.current_user
) do
attributes = {
state: form.state,
answer: form.answer,
- answered_at: Time.current,
cost: form.cost,
cost_report: form.cost_report,
execution_period: form.execution_period
}
- attributes[:state_published_at] = Time.current if !initial_has_state_published && form.publish_answer?
+ if form.state == "not_answered"
+ attributes[:answered_at] = nil
+ attributes[:state_published_at] = nil
+ else
+ attributes[:answered_at] = Time.current
+ attributes[:state_published_at] = Time.current if !initial_has_state_published && form.publish_answer?
+ end
proposal.update!(attributes)
end
end