Class: Decidim::ParticipatoryProcess

Overview

Interaction between a user and an organization is done via a ParticipatoryProcess. It is a unit of action from the Organization point of view that groups several components (proposals, debates…) distributed in steps that get enabled or disabled depending on which step is currently active.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasUploadValidations

#attached_uploader, #maximum_avatar_size, #maximum_upload_size

Methods included from Searchable

searchable_resources, searchable_resources_by_type, searchable_resources_of_type_comment, searchable_resources_of_type_component, searchable_resources_of_type_participant, searchable_resources_of_type_participatory_space

Methods included from Followable

#followers

Methods included from Publicable

#previously_published?, #publish!, #published?, #unpublish!

Class Method Details

.active_spacesObject



135
136
137
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 135

def self.active_spaces
  active
end

.future_spacesObject



139
140
141
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 139

def self.future_spaces
  upcoming
end

.group_idsObject

Pluck all ParticipatoryProcessGroup ID’s



170
171
172
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 170

def self.group_ids
  pluck(:decidim_participatory_process_group_id)
end

.groupedObject

Return processes that belong to a process group.



131
132
133
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 131

def self.grouped
  where.not(decidim_participatory_process_group_id: nil)
end

.grouplessObject

Return processes that DO NOT belong to a process group.



126
127
128
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 126

def self.groupless
  where(decidim_participatory_process_group_id: nil)
end

.log_presenter_class_for(_log) ⇒ Object



147
148
149
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 147

def self.log_presenter_class_for(_log)
  Decidim::ParticipatoryProcesses::AdminLog::ParticipatoryProcessPresenter
end

.moderators(organization) ⇒ Object



191
192
193
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 191

def self.moderators(organization)
  "#{admin_module_name}::Moderators".constantize.for_organization(organization)
end

.past_spacesObject



143
144
145
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 143

def self.past_spaces
  past
end

Scope to return only the promoted processes.

Returns an ActiveRecord::Relation.



121
122
123
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 121

def self.promoted
  where(promoted: true)
end

.ransackable_associations(_auth_object = nil) ⇒ Object



224
225
226
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 224

def self.ransackable_associations(_auth_object = nil)
  %w(area scope participatory_process_type participatory_process_group)
end

.ransackable_attributes(auth_object = nil) ⇒ Object



217
218
219
220
221
222
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 217

def self.ransackable_attributes(auth_object = nil)
  base = %w(title short_description description id)
  return base unless auth_object&.admin?

  base + %w(private_space published_at decidim_participatory_process_group_id)
end

.ransackable_scopes(_auth_object = nil) ⇒ Object



213
214
215
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 213

def self.ransackable_scopes(_auth_object = nil)
  [:with_date, :with_any_taxonomies, :with_any_type]
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


151
152
153
154
155
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 151

def active?
  return false if start_date.blank?

  start_date <= Date.current && (end_date.blank? || end_date >= Date.current)
end

#attachment_contextObject



202
203
204
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 202

def attachment_context
  :admin
end

#closed?Boolean

Returns:

  • (Boolean)


174
175
176
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 174

def closed?
  past?
end

#hashtagObject



178
179
180
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 178

def hashtag
  attributes["hashtag"].to_s.delete("#")
end

#moderatorsObject

Overrides the moderators methods from ‘Participable`.



187
188
189
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 187

def moderators
  "#{admin_module_name}::Moderators".constantize.for(self)
end

#past?Boolean

Returns:

  • (Boolean)


157
158
159
160
161
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 157

def past?
  return false if end_date.blank?

  end_date < Date.current
end

#shareable_url(share_token) ⇒ Object



206
207
208
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 206

def shareable_url(share_token)
  EngineRouter.main_proxy(self).participatory_process_url(self, share_token: share_token.token)
end

#to_paramObject



182
183
184
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 182

def to_param
  slug
end

#upcoming?Boolean

Returns:

  • (Boolean)


163
164
165
166
167
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 163

def upcoming?
  return false if start_date.blank?

  start_date > Date.current
end

#user_roles(role_name = nil) ⇒ Object



195
196
197
198
199
200
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 195

def user_roles(role_name = nil)
  roles = Decidim::ParticipatoryProcessUserRole.where(participatory_process: self)
  return roles if role_name.blank?

  roles.where(role: role_name)
end