Class: Decidim::ParticipatoryProcess

Inherits:
ApplicationRecord
  • Object
show all
Includes:
FilterableResource, Followable, HasArea, HasAttachmentCollections, HasAttachments, HasPrivateUsers, HasReference, HasUploadValidations, Loggable, Participable, ParticipatorySpaceResourceable, Publicable, ScopableParticipatorySpace, Searchable, Traceable, TranslatableResource
Defined in:
app/models/decidim/participatory_process.rb

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

Class Method Details

.active_spacesObject



132
133
134
# File 'app/models/decidim/participatory_process.rb', line 132

def self.active_spaces
  active
end

.future_spacesObject



136
137
138
# File 'app/models/decidim/participatory_process.rb', line 136

def self.future_spaces
  upcoming
end

.group_idsObject

Pluck all ParticipatoryProcessGroup ID’s



167
168
169
# File 'app/models/decidim/participatory_process.rb', line 167

def self.group_ids
  pluck(:decidim_participatory_process_group_id)
end

.groupedObject

Return processes that belong to a process group.



128
129
130
# File 'app/models/decidim/participatory_process.rb', line 128

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

.grouplessObject

Return processes that DO NOT belong to a process group.



123
124
125
# File 'app/models/decidim/participatory_process.rb', line 123

def self.groupless
  where(decidim_participatory_process_group_id: nil)
end

.log_presenter_class_for(_log) ⇒ Object



144
145
146
# File 'app/models/decidim/participatory_process.rb', line 144

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

.moderators(organization) ⇒ Object



188
189
190
# File 'app/models/decidim/participatory_process.rb', line 188

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

.past_spacesObject



140
141
142
# File 'app/models/decidim/participatory_process.rb', line 140

def self.past_spaces
  past
end

Scope to return only the promoted processes.

Returns an ActiveRecord::Relation.



118
119
120
# File 'app/models/decidim/participatory_process.rb', line 118

def self.promoted
  where(promoted: true)
end

.ransackable_scopes(_auth_object = nil) ⇒ Object



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

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

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


148
149
150
151
152
# File 'app/models/decidim/participatory_process.rb', line 148

def active?
  return false if start_date.blank?

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

#attachment_contextObject



199
200
201
# File 'app/models/decidim/participatory_process.rb', line 199

def attachment_context
  :admin
end

#closed?Boolean

Returns:

  • (Boolean)


171
172
173
# File 'app/models/decidim/participatory_process.rb', line 171

def closed?
  past?
end

#hashtagObject



175
176
177
# File 'app/models/decidim/participatory_process.rb', line 175

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

#moderatorsObject

Overrides the moderators methods from ‘Participable`.



184
185
186
# File 'app/models/decidim/participatory_process.rb', line 184

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

#past?Boolean

Returns:

  • (Boolean)


154
155
156
157
158
# File 'app/models/decidim/participatory_process.rb', line 154

def past?
  return false if end_date.blank?

  end_date < Date.current
end

#to_paramObject



179
180
181
# File 'app/models/decidim/participatory_process.rb', line 179

def to_param
  slug
end

#upcoming?Boolean

Returns:

  • (Boolean)


160
161
162
163
164
# File 'app/models/decidim/participatory_process.rb', line 160

def upcoming?
  return false if start_date.blank?

  start_date > Date.current
end

#user_roles(role_name = nil) ⇒ Object



192
193
194
195
196
197
# File 'app/models/decidim/participatory_process.rb', line 192

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