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

Inherits:
Form
  • Object
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.

Instance Method Summary collapse

Methods included from TranslatableAttributes

#default_locale?

Instance Method Details

#map_model(model) ⇒ Object


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

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

#options_for_voting_type_selectObject


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

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


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

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