Class: Decidim::ParticipatoryProcess

Inherits:
ApplicationRecord
  • Object
show all
Includes:
Followable, HasAttachmentCollections, HasAttachments, HasPrivateUsers, HasReference, Loggable, Participable, ParticipatorySpaceResourceable, Publicable, Scopable, Searchable, Traceable
Defined in:
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

Class Method Details

.active_spacesObject



96
97
98
# File 'app/models/decidim/participatory_process.rb', line 96

def self.active_spaces
  active
end

.future_spacesObject



100
101
102
# File 'app/models/decidim/participatory_process.rb', line 100

def self.future_spaces
  upcoming
end

.group_idsObject

Pluck all ParticipatoryProcessGroup ID’s



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

def self.group_ids
  pluck(:decidim_participatory_process_group_id)
end

.groupedObject

Return processes that belong to a process group.



92
93
94
# File 'app/models/decidim/participatory_process.rb', line 92

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

.grouplessObject

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



87
88
89
# File 'app/models/decidim/participatory_process.rb', line 87

def self.groupless
  where(decidim_participatory_process_group_id: nil)
end

.log_presenter_class_for(_log) ⇒ Object



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

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

.past_spacesObject



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

def self.past_spaces
  past
end

Scope to return only the promoted processes.

Returns an ActiveRecord::Relation.



82
83
84
# File 'app/models/decidim/participatory_process.rb', line 82

def self.promoted
  where(promoted: true)
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


112
113
114
115
116
# File 'app/models/decidim/participatory_process.rb', line 112

def active?
  return false if start_date.blank?

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

#closed?Boolean

Returns:

  • (Boolean)


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

def closed?
  past?
end

#hashtagObject



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

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

#moderatorsObject

Overrides the method from ‘Participable`.



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

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

#past?Boolean

Returns:

  • (Boolean)


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

def past?
  return false if end_date.blank?

  end_date < Date.current
end

#to_paramObject



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

def to_param
  slug
end

#upcoming?Boolean

Returns:

  • (Boolean)


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

def upcoming?
  return false if start_date.blank?

  start_date > Date.current
end