module Decidim::Participable
Utilities for models that can act as participatory spaces
Public Instance Methods
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
# File lib/decidim/participable.rb, line 44 def admin_extension_module "#{admin_module_name}::#{demodulized_name}Context".constantize end
# File lib/decidim/participable.rb, line 21 def admin_module_name "#{module_name}::Admin" end
# File lib/decidim/participable.rb, line 52 def admins admins_query.for(self) end
# File lib/decidim/participable.rb, line 48 def admins_query "#{admin_module_name}::AdminUsers".constantize end
# File lib/decidim/participable.rb, line 63 def allows_steps? respond_to?(:steps) end
# File lib/decidim/participable.rb, line 75 def can_participate?(_user) true end
# File lib/decidim/participable.rb, line 11 def demodulized_name @demodulized_name ||= self.class.name.demodulize end
# File lib/decidim/participable.rb, line 79 def empty_published_component? components.published.empty? end
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
# File lib/decidim/participable.rb, line 67 def has_steps? allows_steps? && steps.any? end
# File lib/decidim/participable.rb, line 71 def manifest self.class.participatory_space_manifest end
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
# File lib/decidim/participable.rb, line 17 def module_name "Decidim::#{demodulized_name.pluralize}" end
# File lib/decidim/participable.rb, line 33 def mounted_admin_engine "decidim_admin_#{underscored_name.pluralize}" end
# File lib/decidim/participable.rb, line 29 def mounted_engine "decidim_#{underscored_name.pluralize}" end
# File lib/decidim/participable.rb, line 37 def mounted_params { host: organization.host, "#{underscored_name}_slug".to_sym => slug } end
# File lib/decidim/participable.rb, line 101 def participatory_space_manifest Decidim.find_participatory_space_manifest(name.demodulize.underscore.pluralize) end
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: 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
# File lib/decidim/participable.rb, line 97 def slug_format /\A[a-zA-Z]+[a-zA-Z0-9\-]+\z/ end
# File lib/decidim/participable.rb, line 25 def underscored_name demodulized_name.underscore end