Class: Decidim::ParticipatoryProcess
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Decidim::ParticipatoryProcess
- Includes:
- FilterableResource, Followable, HasArea, HasAttachmentCollections, HasAttachments, HasPrivateUsers, HasReference, HasUploadValidations, Loggable, Participable, ParticipatorySpaceResourceable, Publicable, ScopableParticipatorySpace, Searchable, ShareableWithToken, SoftDeletable, Taxonomizable, 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
- .active_spaces ⇒ Object
- .future_spaces ⇒ Object
-
.group_ids ⇒ Object
Pluck all ParticipatoryProcessGroup ID’s.
-
.grouped ⇒ Object
Return processes that belong to a process group.
-
.groupless ⇒ Object
Return processes that DO NOT belong to a process group.
- .log_presenter_class_for(_log) ⇒ Object
- .moderators(organization) ⇒ Object
- .past_spaces ⇒ Object
-
.promoted ⇒ Object
Scope to return only the promoted processes.
- .ransackable_associations(_auth_object = nil) ⇒ Object
- .ransackable_attributes(auth_object = nil) ⇒ Object
- .ransackable_scopes(_auth_object = nil) ⇒ Object
Instance Method Summary collapse
- #active? ⇒ Boolean
- #attachment_context ⇒ Object
- #closed? ⇒ Boolean
-
#moderators ⇒ Object
Overrides the moderators methods from ‘Participable`.
- #past? ⇒ Boolean
- #presenter ⇒ Object
- #shareable_url(share_token) ⇒ Object
- #to_param ⇒ Object
- #upcoming? ⇒ Boolean
- #user_roles(role_name = nil) ⇒ Object
Class Method Details
.active_spaces ⇒ Object
133 134 135 |
# File 'app/models/decidim/participatory_process.rb', line 133 def self.active_spaces active end |
.future_spaces ⇒ Object
137 138 139 |
# File 'app/models/decidim/participatory_process.rb', line 137 def self.future_spaces upcoming end |
.group_ids ⇒ Object
Pluck all ParticipatoryProcessGroup ID’s
172 173 174 |
# File 'app/models/decidim/participatory_process.rb', line 172 def self.group_ids pluck(:decidim_participatory_process_group_id) end |
.grouped ⇒ Object
Return processes that belong to a process group.
129 130 131 |
# File 'app/models/decidim/participatory_process.rb', line 129 def self.grouped where.not(decidim_participatory_process_group_id: nil) end |
.groupless ⇒ Object
Return processes that DO NOT belong to a process group.
124 125 126 |
# File 'app/models/decidim/participatory_process.rb', line 124 def self.groupless where(decidim_participatory_process_group_id: nil) end |
.log_presenter_class_for(_log) ⇒ Object
145 146 147 |
# File 'app/models/decidim/participatory_process.rb', line 145 def self.log_presenter_class_for(_log) Decidim::ParticipatoryProcesses::AdminLog::ParticipatoryProcessPresenter end |
.moderators(organization) ⇒ Object
189 190 191 |
# File 'app/models/decidim/participatory_process.rb', line 189 def self.moderators(organization) "#{admin_module_name}::Moderators".constantize.for_organization(organization) end |
.past_spaces ⇒ Object
141 142 143 |
# File 'app/models/decidim/participatory_process.rb', line 141 def self.past_spaces past end |
.promoted ⇒ Object
Scope to return only the promoted processes.
Returns an ActiveRecord::Relation.
119 120 121 |
# File 'app/models/decidim/participatory_process.rb', line 119 def self.promoted where(promoted: true) end |
.ransackable_associations(_auth_object = nil) ⇒ Object
222 223 224 |
# File 'app/models/decidim/participatory_process.rb', line 222 def self.ransackable_associations(_auth_object = nil) %w(participatory_process_type participatory_process_group taxonomies) end |
.ransackable_attributes(auth_object = nil) ⇒ Object
215 216 217 218 219 220 |
# File 'app/models/decidim/participatory_process.rb', line 215 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 created_at decidim_participatory_process_group_id) end |
.ransackable_scopes(_auth_object = nil) ⇒ Object
211 212 213 |
# File 'app/models/decidim/participatory_process.rb', line 211 def self.ransackable_scopes(_auth_object = nil) [:with_date, :with_any_taxonomies] end |
Instance Method Details
#active? ⇒ Boolean
153 154 155 156 157 |
# File 'app/models/decidim/participatory_process.rb', line 153 def active? return false if start_date.blank? start_date <= Date.current && (end_date.blank? || end_date >= Date.current) end |
#attachment_context ⇒ Object
200 201 202 |
# File 'app/models/decidim/participatory_process.rb', line 200 def :admin end |
#closed? ⇒ Boolean
176 177 178 |
# File 'app/models/decidim/participatory_process.rb', line 176 def closed? past? end |
#moderators ⇒ Object
Overrides the moderators methods from ‘Participable`.
185 186 187 |
# File 'app/models/decidim/participatory_process.rb', line 185 def moderators "#{admin_module_name}::Moderators".constantize.for(self) end |
#past? ⇒ Boolean
159 160 161 162 163 |
# File 'app/models/decidim/participatory_process.rb', line 159 def past? return false if end_date.blank? end_date < Date.current end |
#presenter ⇒ Object
149 150 151 |
# File 'app/models/decidim/participatory_process.rb', line 149 def presenter @presenter ||= Decidim::ParticipatoryProcesses::ParticipatoryProcessPresenter.new(self) end |
#shareable_url(share_token) ⇒ Object
204 205 206 |
# File 'app/models/decidim/participatory_process.rb', line 204 def shareable_url(share_token) EngineRouter.main_proxy(self).participatory_process_url(self, share_token: share_token.token) end |
#to_param ⇒ Object
180 181 182 |
# File 'app/models/decidim/participatory_process.rb', line 180 def to_param slug end |
#upcoming? ⇒ Boolean
165 166 167 168 169 |
# File 'app/models/decidim/participatory_process.rb', line 165 def upcoming? return false if start_date.blank? start_date > Date.current end |
#user_roles(role_name = nil) ⇒ Object
193 194 195 196 197 198 |
# File 'app/models/decidim/participatory_process.rb', line 193 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 |