module Decidim::Participable

Utilities for models that can act as participatory spaces

Public Instance Methods

active_spaces() click to toggle source

Public: Adds a sane default way to retrieve active spaces. Please, overwrite this from your model class in case this is not correct for your model.

Returns an `ActiveRecord::Association`.

# File lib/decidim/participable.rb, line 117
def active_spaces
  public_spaces
end
admin_extension_module() click to toggle source
# File lib/decidim/participable.rb, line 44
def admin_extension_module
  "#{admin_module_name}::#{demodulized_name}Context".constantize
end
admin_module_name() click to toggle source
# File lib/decidim/participable.rb, line 21
def admin_module_name
  "#{module_name}::Admin"
end
admins() click to toggle source
# File lib/decidim/participable.rb, line 52
def admins
  admins_query.for(self)
end
admins_query() click to toggle source
# File lib/decidim/participable.rb, line 48
def admins_query
  "#{admin_module_name}::AdminUsers".constantize
end
allows_steps?() click to toggle source
# File lib/decidim/participable.rb, line 63
def allows_steps?
  respond_to?(:steps)
end
can_participate?(_user) click to toggle source
# File lib/decidim/participable.rb, line 75
def can_participate?(_user)
  true
end
cta_button_text_key() click to toggle source
# File lib/decidim/participable.rb, line 83
def cta_button_text_key
  return :more_info if empty_published_component?

  :take_part
end
cta_button_text_key_accessible() click to toggle source
# File lib/decidim/participable.rb, line 89
def cta_button_text_key_accessible
  return :more_info_about if empty_published_component?

  :take_part_in
end
demodulized_name() click to toggle source
# File lib/decidim/participable.rb, line 11
def demodulized_name
  @demodulized_name ||= self.class.name.demodulize
end
empty_published_component?() click to toggle source
# File lib/decidim/participable.rb, line 79
def empty_published_component?
  components.published.empty?
end
future_spaces() click to toggle source

Public: Adds a sane default way to retrieve future spaces. Please, overwrite this from your model class in case this is not correct for your model.

Returns an `ActiveRecord::Association`.

# File lib/decidim/participable.rb, line 125
def future_spaces
  none
end
has_steps?() click to toggle source
# File lib/decidim/participable.rb, line 67
def has_steps?
  allows_steps? && steps.any?
end
manifest() click to toggle source
# File lib/decidim/participable.rb, line 71
def manifest
  self.class.participatory_space_manifest
end
moderators() click to toggle source

Public: Returns an ActiveRecord::Relation of all the users that can moderate the space. This is used when notifying of flagged/hidden content.

# File lib/decidim/participable.rb, line 59
def moderators
  admins
end
module_name() click to toggle source
# File lib/decidim/participable.rb, line 17
def module_name
  "Decidim::#{demodulized_name.pluralize}"
end
mounted_admin_engine() click to toggle source
# File lib/decidim/participable.rb, line 33
def mounted_admin_engine
  "decidim_admin_#{underscored_name.pluralize}"
end
mounted_engine() click to toggle source
# File lib/decidim/participable.rb, line 29
def mounted_engine
  "decidim_#{underscored_name.pluralize}"
end
mounted_params() click to toggle source
# File lib/decidim/participable.rb, line 37
def mounted_params
  {
    host: organization.host,
    "#{underscored_name}_slug".to_sym => slug
  }
end
participatory_space_manifest() click to toggle source
# File lib/decidim/participable.rb, line 101
def participatory_space_manifest
  Decidim.find_participatory_space_manifest(name.demodulize.underscore.pluralize)
end
past_spaces() click to toggle source

Public: Adds a sane default way to retrieve past spaces. Please, overwrite this from your model class in case this is not correct for your model.

Returns an `ActiveRecord::Association`.

# File lib/decidim/participable.rb, line 133
def past_spaces
  none
end
public_spaces() click to toggle source

Public: Adds a sane default way to retrieve public spaces. Please, overwrite this from your model class in case this is not correct for your model.

Returns an `ActiveRecord::Association`.

# File lib/decidim/participable.rb, line 109
def public_spaces
  published
end
slug_format() click to toggle source
# File lib/decidim/participable.rb, line 97
def slug_format
  /\A[a-zA-Z]+[a-zA-Z0-9\-]+\z/
end
underscored_name() click to toggle source
# File lib/decidim/participable.rb, line 25
def underscored_name
  demodulized_name.underscore
end