Class: Decidim::Proposals::ProposalForm

Inherits:
Form
  • Object
show all
Includes:
AttachmentAttributes, HasTaxonomyFormAttributes, HasUploadValidations, TranslatableAttributes
Defined in:
app/forms/decidim/proposals/proposal_form.rb

Overview

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

Direct Known Subclasses

CollaborativeDraftForm

Instance Method Summary collapse

Instance Method Details

#geocoded?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'app/forms/decidim/proposals/proposal_form.rb', line 60

def geocoded?
  latitude.present? && longitude.present?
end

#geocoding_enabled?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'app/forms/decidim/proposals/proposal_form.rb', line 52

def geocoding_enabled?
  Decidim::Map.available?(:geocoding) && current_component.settings.geocoding_enabled?
end

#has_address?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'app/forms/decidim/proposals/proposal_form.rb', line 56

def has_address?
  geocoding_enabled? && address.present?
end

#map_model(model) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'app/forms/decidim/proposals/proposal_form.rb', line 38

def map_model(model)
  self.title = translated_attribute(model.title)
  self.body = translated_attribute(model.body)

  presenter = ProposalPresenter.new(model)
  self.body = presenter.editor_body(all_locales: body.is_a?(Hash))

  self.documents = model.attachments
end

#participatory_space_manifestObject



48
49
50
# File 'app/forms/decidim/proposals/proposal_form.rb', line 48

def participatory_space_manifest
  @participatory_space_manifest ||= current_component.participatory_space.manifest.name
end