Class: Decidim::ParticipatoryProcess

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

Overview

Interaction between a user and an organization is done via a ParticipatoryProcess. It's 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

#maximum_avatar_size, #maximum_upload_size

Methods included from Searchable

searchable_resources, 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

#publish!, #published?, #unpublish!

Class Method Details

.active_spacesObject


108
109
110
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 108

def self.active_spaces
  active
end

.future_spacesObject


112
113
114
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 112

def self.future_spaces
  upcoming
end

.group_idsObject

Pluck all ParticipatoryProcessGroup ID's


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

def self.group_ids
  pluck(:decidim_participatory_process_group_id)
end

.groupedObject

Return processes that belong to a process group.


104
105
106
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 104

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

.grouplessObject

Return processes that DON'T belong to a process group.


99
100
101
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 99

def self.groupless
  where(decidim_participatory_process_group_id: nil)
end

.log_presenter_class_for(_log) ⇒ Object


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

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

.past_spacesObject


116
117
118
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 116

def self.past_spaces
  past
end

Scope to return only the promoted processes.

Returns an ActiveRecord::Relation.


94
95
96
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 94

def self.promoted
  where(promoted: true)
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)

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

def active?
  return false if start_date.blank?

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

#attachment_contextObject


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

def attachment_context
  :admin
end

#closed?Boolean

Returns:

  • (Boolean)

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

def closed?
  past?
end

#hashtagObject


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

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

#moderatorsObject

Overrides the method from `Participable`.


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

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

#past?Boolean

Returns:

  • (Boolean)

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

def past?
  return false if end_date.blank?

  end_date < Date.current
end

#to_paramObject


155
156
157
# File 'decidim-participatory_processes/app/models/decidim/participatory_process.rb', line 155

def to_param
  slug
end

#upcoming?Boolean

Returns:

  • (Boolean)

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

def upcoming?
  return false if start_date.blank?

  start_date > Date.current
end

#user_roles(role_name = nil) ⇒ Object


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

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