Class: Decidim::Votings::Admin::VotingForm

Inherits:
Form show all
Includes:
TranslatableAttributes
Defined in:
decidim-elections/app/forms/decidim/votings/admin/voting_form.rb

Overview

This class holds a Form to create/update votings from Decidim’s admin panel.

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 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



39
40
41
# File 'decidim-elections/app/forms/decidim/votings/admin/voting_form.rb', line 39

def map_model(model)
  self.scope_id = model.decidim_scope_id
end

#options_for_voting_type_selectObject



47
48
49
50
51
52
53
54
# File 'decidim-elections/app/forms/decidim/votings/admin/voting_form.rb', line 47

def options_for_voting_type_select
  Voting.voting_types.map do |key, value|
    [
      I18n.t("voting_type.#{key}", scope: "decidim.votings.admin.votings.form"),
      value
    ]
  end
end

#scopeObject



43
44
45
# File 'decidim-elections/app/forms/decidim/votings/admin/voting_form.rb', line 43

def scope
  @scope ||= current_organization.scopes.find_by(id: scope_id)
end