class Decidim::Debates::DebateForm
This class holds a Form to create/update debates from Decidim’s public views.
def category
def category @category ||= current_component.categories.find_by(id: category_id) end
def editable_by_user
def editable_by_user return unless debate.respond_to?(:editable_by?) errors.add(:debate, :invalid) unless debate.editable_by?(current_user) end
def map_model(debate)
def map_model(debate) super self.debate = debate # Debates can be translated in different languages from the admin but # the public form doesn't allow it. When a user creates a debate the # user locale is taken as the text locale. self.title = debate.title.values.first self.description = debate.description.values.first self.user_group_id = debate.decidim_user_group_id if debate.category.present? self.category_id = debate.category.id @category = debate.category end end
def scope
Finds the Scope from the given scope_id, uses component scope if missing.
def scope @scope ||= @scope_id ? current_component.scopes.find_by(id: @scope_id) : current_component.scope end
def scope_id
Scope identifier
def scope_id @scope_id || scope&.id end