Class: Decidim::Debates::Admin::DebateForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Debates::Admin::DebateForm
- Includes:
- TranslatableAttributes
- Defined in:
- app/forms/decidim/debates/admin/debate_form.rb
Overview
This class holds a Form to create/update debates from Decidim’s admin panel.
Instance Method Summary collapse
- #category ⇒ Object
- #map_model(model) ⇒ Object
-
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses the component scope if missing.
-
#scope_id ⇒ Object
Scope identifier.
Instance Method Details
#category ⇒ Object
40 41 42 43 44 |
# File 'app/forms/decidim/debates/admin/debate_form.rb', line 40 def category return unless current_component @category ||= current_component.categories.find_by(id: decidim_category_id) end |
#map_model(model) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/forms/decidim/debates/admin/debate_form.rb', line 31 def map_model(model) self.finite = model.start_time.present? && model.end_time.present? self.decidim_category_id = model.categorization.decidim_category_id if model.categorization presenter = DebatePresenter.new(model) self.title = presenter.title(all_locales: title.is_a?(Hash)) self.description = presenter.description(all_locales: description.is_a?(Hash)) end |
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses the component scope if missing.
Returns a Decidim::Scope
49 50 51 |
# File 'app/forms/decidim/debates/admin/debate_form.rb', line 49 def scope @scope ||= @attributes["scope_id"].value ? current_component.scopes.find_by(id: @attributes["scope_id"].value) : current_component.scope end |
#scope_id ⇒ Object
Scope identifier
Returns the scope identifier related to the meeting
56 57 58 |
# File 'app/forms/decidim/debates/admin/debate_form.rb', line 56 def scope_id super || scope&.id end |