Class: Decidim::Initiatives::Admin::InitiativeForm

Inherits:
Form
  • Object
show all
Includes:
TranslatableAttributes
Defined in:
app/forms/decidim/initiatives/admin/initiative_form.rb

Overview

A form object used to show the initiative data in the administration panel.

Instance Method Summary collapse

Instance Method Details

#areaObject



68
69
70
# File 'app/forms/decidim/initiatives/admin/initiative_form.rb', line 68

def area
  @area ||= current_organization.areas.find_by(id: area_id)
end

#area_updatable?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'app/forms/decidim/initiatives/admin/initiative_form.rb', line 58

def area_updatable?
  @area_updatable ||= current_user.admin? || context.initiative.created?
end

#map_model(model) ⇒ Object



41
42
43
44
45
# File 'app/forms/decidim/initiatives/admin/initiative_form.rb', line 41

def map_model(model)
  self.type_id = model.type.id
  self.decidim_scope_id = model.scope&.id
  self.offline_votes = offline_votes.empty? ? zero_offline_votes_with_scopes_names(model) : offline_votes_with_scopes_names(model)
end

#scoped_type_idObject



62
63
64
65
66
# File 'app/forms/decidim/initiatives/admin/initiative_form.rb', line 62

def scoped_type_id
  return unless type && decidim_scope_id

  type.scopes.find_by(decidim_scopes_id: decidim_scope_id.presence).id
end

#signature_type_updatable?Boolean

Returns:

  • (Boolean)


47
48
49
50
51
52
# File 'app/forms/decidim/initiatives/admin/initiative_form.rb', line 47

def signature_type_updatable?
  @signature_type_updatable ||= begin
    state ||= context.initiative.state
    (state == "validating" && context.current_user.admin?) || state == "created"
  end
end

#state_updatable?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/forms/decidim/initiatives/admin/initiative_form.rb', line 54

def state_updatable?
  false
end