Class: Decidim::Proposals::Admin::ProposalForm

Inherits:
ProposalBaseForm show all
Includes:
HasUploadValidations
Defined in:
decidim-proposals/app/forms/decidim/proposals/admin/proposal_form.rb

Overview

A form object to be used when admin users want to create a proposal.

Constant Summary

Constants included from AttributeObject::TypeMap

AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal

Instance Attribute Summary

Attributes inherited from AttributeObject::Form

#context

Instance Method Summary collapse

Methods included from HasUploadValidations

#attached_uploader, #maximum_avatar_size, #maximum_upload_size

Methods inherited from ProposalBaseForm

#author, #category, #component_automatic_hashtags, #component_suggested_hashtags, #extra_hashtags, #geocoded?, #geocoding_enabled?, #has_address?, #meeting_as_author, #meetings, #scope, #scope_id, #suggested_hashtag_checked?, #suggested_hashtags

Methods included from TranslatableAttributes

#default_locale?

Methods inherited from AttributeObject::Form

ensure_hash, from_model, from_params, hash_from, infer_model_name, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context

Methods included from AttributeObject::Model

#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h

Instance Method Details

#map_model(model) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'decidim-proposals/app/forms/decidim/proposals/admin/proposal_form.rb', line 19

def map_model(model)
  super(model)
  presenter = ProposalPresenter.new(model)

  self.title = presenter.title(all_locales: title.is_a?(Hash))
  self.body = presenter.body(all_locales: body.is_a?(Hash))
  self.attachment = if model.documents.first.present?
                      { file: model.documents.first.file, title: translated_attribute(model.documents.first.title) }
                    else
                      {}
                    end
end