Add proposal translations
Adapt retire form to include needed translations and move validations from controller to model. Also change sanitizable concern to sanitize not marked for destruction translations.
This commit is contained in:
committed by
voodoorai2000
parent
5343448c5a
commit
02be0c61f9
@@ -62,7 +62,7 @@ class ProposalsController < ApplicationController
|
||||
end
|
||||
|
||||
def retire
|
||||
if valid_retired_params? && @proposal.update(retired_params.merge(retired_at: Time.current))
|
||||
if @proposal.update(retired_params.merge(retired_at: Time.current))
|
||||
redirect_to proposal_path(@proposal), notice: t("proposals.notice.retired")
|
||||
else
|
||||
render action: :retire_form
|
||||
@@ -107,13 +107,8 @@ class ProposalsController < ApplicationController
|
||||
end
|
||||
|
||||
def retired_params
|
||||
params.require(:proposal).permit(:retired_reason, :retired_explanation)
|
||||
end
|
||||
|
||||
def valid_retired_params?
|
||||
@proposal.errors.add(:retired_reason, I18n.t("errors.messages.blank")) if params[:proposal][:retired_reason].blank?
|
||||
@proposal.errors.add(:retired_explanation, I18n.t("errors.messages.blank")) if params[:proposal][:retired_explanation].blank?
|
||||
@proposal.errors.empty?
|
||||
attributes = [:retired_reason]
|
||||
params.require(:proposal).permit(attributes, translation_params(Proposal))
|
||||
end
|
||||
|
||||
def resource_model
|
||||
|
||||
Reference in New Issue
Block a user