Class: Decidim::Elections::Admin::AnswerForm

Inherits:
Form
  • Object
show all
Includes:
AttachmentAttributes, TranslatableAttributes
Defined in:
decidim-elections/app/forms/decidim/elections/admin/answer_form.rb

Overview

This class holds a Form to create/update answers from Decidim's admin panel.

Instance Method Summary collapse

Methods included from TranslatableAttributes

#default_locale?

Instance Method Details

#electionObject


33
34
35
# File 'decidim-elections/app/forms/decidim/elections/admin/answer_form.rb', line 33

def election
  @election ||= context[:election]
end

#map_model(model) ⇒ Object


22
23
24
# File 'decidim-elections/app/forms/decidim/elections/admin/answer_form.rb', line 22

def map_model(model)
  self.proposal_ids = model.linked_resources(:proposals, "related_proposals").pluck(:id)
end

#proposalsObject


26
27
28
29
30
31
# File 'decidim-elections/app/forms/decidim/elections/admin/answer_form.rb', line 26

def proposals
  @proposals ||= Decidim.find_resource_manifest(:proposals)
                        .try(:resource_scope, current_component)
                        &.where(id: proposal_ids)
                        &.order(title: :asc)
end

#questionObject


37
38
39
# File 'decidim-elections/app/forms/decidim/elections/admin/answer_form.rb', line 37

def question
  @question ||= context[:question]
end