Class: Decidim::Challenges::Admin::ChallengesForm

Inherits:
Form
  • Object
show all
Includes:
HasUploadValidations, Sdgs::SdgsHelper, TranslatableAttributes
Defined in:
app/forms/decidim/challenges/admin/challenges_form.rb

Overview

A form object used to create challenges from the admin dashboard.

Instance Method Summary collapse

Methods included from Sdgs::SdgsHelper

#filter_sdgs_values, #sdgs_filter_selector, #t_sdg

Instance Method Details

#map_model(model) ⇒ Object



66
# File 'app/forms/decidim/challenges/admin/challenges_form.rb', line 66

def map_model(model); end

#scopeObject

Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.

Returns a Decidim::Scope



62
63
64
# File 'app/forms/decidim/challenges/admin/challenges_form.rb', line 62

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

#select_sdg_collectionObject



53
54
55
56
57
# File 'app/forms/decidim/challenges/admin/challenges_form.rb', line 53

def select_sdg_collection
  Decidim::Sdgs::Sdg::SDGS.map do |sdg_code|
    [I18n.t("#{sdg_code}.objectives.subtitle", scope: "decidim.components.sdgs"), sdg_code]
  end
end

#select_states_collectionObject



47
48
49
50
51
# File 'app/forms/decidim/challenges/admin/challenges_form.rb', line 47

def select_states_collection
  Decidim::Challenges::Challenge::VALID_STATES.map.with_index do |state, idx|
    [I18n.t(state, scope: "decidim.challenges.states"), idx]
  end
end