decidim-participatory_processes 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +36 -0
- data/Rakefile +3 -0
- data/app/assets/config/admin/decidim_participatory_processes_manifest.js +1 -0
- data/app/assets/config/decidim_participatory_processes_manifest.js +2 -0
- data/app/assets/images/decidim/participatory_processes/process.svg +10 -0
- data/app/assets/javascripts/decidim/participatory_processes/admin/participatory_processes.js.es6 +12 -0
- data/app/assets/javascripts/decidim/participatory_processes/filters.js.es6 +25 -0
- data/app/commands/decidim/participatory_processes/admin/activate_participatory_process_step.rb +46 -0
- data/app/commands/decidim/participatory_processes/admin/copy_participatory_process.rb +116 -0
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +82 -0
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb +95 -0
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process_group.rb +57 -0
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process_step.rb +49 -0
- data/app/commands/decidim/participatory_processes/admin/deactivate_participatory_process_step.rb +38 -0
- data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_step.rb +46 -0
- data/app/commands/decidim/participatory_processes/admin/publish_participatory_process.rb +34 -0
- data/app/commands/decidim/participatory_processes/admin/reorder_participatory_process_steps.rb +54 -0
- data/app/commands/decidim/participatory_processes/admin/unpublish_participatory_process.rb +34 -0
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +77 -0
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process_admin.rb +43 -0
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process_group.rb +60 -0
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb +51 -0
- data/app/constraints/decidim/participatory_processes/current_feature.rb +28 -0
- data/app/constraints/decidim/participatory_processes/current_participatory_process.rb +37 -0
- data/app/controllers/concerns/decidim/participatory_processes/admin/participatory_process_context.rb +21 -0
- data/app/controllers/concerns/decidim/participatory_processes/needs_participatory_process.rb +50 -0
- data/app/controllers/concerns/decidim/participatory_processes/participatory_process_context.rb +27 -0
- data/app/controllers/decidim/participatory_processes/admin/application_controller.rb +11 -0
- data/app/controllers/decidim/participatory_processes/admin/categories_controller.rb +13 -0
- data/app/controllers/decidim/participatory_processes/admin/concerns/participatory_process_admin.rb +26 -0
- data/app/controllers/decidim/participatory_processes/admin/exports_controller.rb +14 -0
- data/app/controllers/decidim/participatory_processes/admin/feature_permissions_controller.rb +14 -0
- data/app/controllers/decidim/participatory_processes/admin/features_controller.rb +14 -0
- data/app/controllers/decidim/participatory_processes/admin/moderations_controller.rb +12 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_attachments_controller.rb +27 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_copies_controller.rb +35 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_groups_controller.rb +90 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_publications_controller.rb +45 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_step_activations_controller.rb +39 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_step_ordering_controller.rb +29 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_steps_controller.rb +91 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_user_roles_controller.rb +99 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb +102 -0
- data/app/controllers/decidim/participatory_processes/participatory_process_groups_controller.rb +28 -0
- data/app/controllers/decidim/participatory_processes/participatory_process_steps_controller.rb +20 -0
- data/app/controllers/decidim/participatory_processes/participatory_process_widgets_controller.rb +21 -0
- data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +64 -0
- data/app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb +35 -0
- data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +72 -0
- data/app/forms/decidim/participatory_processes/admin/participatory_process_group_form.rb +26 -0
- data/app/forms/decidim/participatory_processes/admin/participatory_process_step_form.rb +37 -0
- data/app/forms/decidim/participatory_processes/admin/participatory_process_user_role_form.rb +31 -0
- data/app/helpers/decidim/participatory_processes/admin/process_groups_for_select_helper.rb +23 -0
- data/app/helpers/decidim/participatory_processes/admin/processes_for_select_helper.rb +25 -0
- data/app/helpers/decidim/participatory_processes/participatory_process_helper.rb +19 -0
- data/app/helpers/decidim/participatory_processes/participatory_process_steps_helper.rb +20 -0
- data/app/models/decidim/participatory_process.rb +62 -0
- data/app/models/decidim/participatory_process_group.rb +15 -0
- data/app/models/decidim/participatory_process_step.rb +39 -0
- data/app/models/decidim/participatory_processes/abilities/admin/admin_ability.rb +21 -0
- data/app/models/decidim/participatory_processes/abilities/admin_ability.rb +16 -0
- data/app/models/decidim/participatory_processes/abilities/everyone_ability.rb +19 -0
- data/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb +52 -0
- data/app/queries/decidim/participatory_processes/admin/admin_users.rb +46 -0
- data/app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb +29 -0
- data/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb +26 -0
- data/app/queries/decidim/participatory_processes/highlighted_participatory_processes.rb +12 -0
- data/app/queries/decidim/participatory_processes/organization_participatory_process_groups.rb +16 -0
- data/app/queries/decidim/participatory_processes/organization_participatory_processes.rb +16 -0
- data/app/queries/decidim/participatory_processes/organization_prioritized_participatory_process_groups.rb +20 -0
- data/app/queries/decidim/participatory_processes/organization_prioritized_participatory_processes.rb +22 -0
- data/app/queries/decidim/participatory_processes/organization_published_participatory_processes.rb +19 -0
- data/app/queries/decidim/participatory_processes/prioritized_participatory_processes.rb +13 -0
- data/app/queries/decidim/participatory_processes/promoted_participatory_processes.rb +12 -0
- data/app/queries/decidim/participatory_processes/published_participatory_processes.rb +12 -0
- data/app/views/decidim/participatory_process_groups/_participatory_process_group.html.erb +22 -0
- data/app/views/decidim/participatory_process_steps/_participatory_process_step.html.erb +16 -0
- data/app/views/decidim/participatory_processes/_order_by_processes.html.erb +12 -0
- data/app/views/decidim/participatory_processes/_participatory_process.html.erb +28 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_copies/_form.html.erb +38 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_copies/new.html.erb +7 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_groups/_form.html.erb +17 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_groups/edit.html.erb +19 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_groups/index.html.erb +44 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_groups/new.html.erb +13 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_groups/show.html.erb +23 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_steps/_form.html.erb +25 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_steps/edit.html.erb +8 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_steps/index.html.erb +63 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_steps/new.html.erb +7 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_steps/show.html.erb +18 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/_form.html.erb +22 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/edit.html.erb +7 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/index.html.erb +65 -0
- data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/new.html.erb +7 -0
- data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +107 -0
- data/app/views/decidim/participatory_processes/admin/participatory_processes/edit.html.erb +19 -0
- data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +66 -0
- data/app/views/decidim/participatory_processes/admin/participatory_processes/new.html.erb +11 -0
- data/app/views/decidim/participatory_processes/participatory_process_groups/show.html.erb +11 -0
- data/app/views/decidim/participatory_processes/participatory_process_steps/_timeline.html.erb +7 -0
- data/app/views/decidim/participatory_processes/participatory_process_steps/index.html.erb +14 -0
- data/app/views/decidim/participatory_processes/participatory_process_widgets/show.html.erb +17 -0
- data/app/views/decidim/participatory_processes/participatory_processes/_no_processes_yet.html.erb +3 -0
- data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process.html.erb +32 -0
- data/app/views/decidim/participatory_processes/participatory_processes/_statistics.html.erb +10 -0
- data/app/views/decidim/participatory_processes/participatory_processes/index.html.erb +22 -0
- data/app/views/decidim/participatory_processes/participatory_processes/index.js.erb +6 -0
- data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +92 -0
- data/app/views/layouts/decidim/_process_header.html.erb +65 -0
- data/app/views/layouts/decidim/_process_header_steps.html.erb +27 -0
- data/app/views/layouts/decidim/admin/participatory_process.html.erb +64 -0
- data/app/views/layouts/decidim/admin/participatory_process_groups.html.erb +14 -0
- data/app/views/layouts/decidim/admin/participatory_processes.html.erb +14 -0
- data/app/views/layouts/decidim/participatory_process.html.erb +30 -0
- data/config/locales/ca.yml +281 -0
- data/config/locales/en.yml +281 -0
- data/config/locales/es.yml +281 -0
- data/config/locales/eu.yml +280 -0
- data/config/locales/fi.yml +280 -0
- data/config/locales/fr.yml +280 -0
- data/config/locales/it.yml +280 -0
- data/config/locales/nl.yml +280 -0
- data/config/locales/pl.yml +281 -0
- data/config/locales/uk.yml +282 -0
- data/db/migrate/20161005130108_add_participatory_processes.rb +19 -0
- data/db/migrate/20161010102356_translate_processes.rb +17 -0
- data/db/migrate/20161011125616_add_hero_image_to_processes.rb +7 -0
- data/db/migrate/20161011141033_add_banner_image_to_processes.rb +7 -0
- data/db/migrate/20161013134732_add_promoted_flag_to_processes.rb +7 -0
- data/db/migrate/20161017085822_add_participatory_process_steps.rb +18 -0
- data/db/migrate/20161019072016_add_active_flag_to_step.rb +13 -0
- data/db/migrate/20161020080756_add_position_to_steps.rb +9 -0
- data/db/migrate/20161025125300_add_published_at_to_processes.rb +7 -0
- data/db/migrate/20161107152228_remove_not_null_on_step_position.rb +7 -0
- data/db/migrate/20161110092735_add_index_for_process_slug_organization.rb +10 -0
- data/db/migrate/20161116115156_create_attachments.rb +18 -0
- data/db/migrate/20170116135237_loosen_step_requirements.rb +8 -0
- data/db/migrate/20170123134023_make_attachments_polymorphic.rb +20 -0
- data/db/migrate/20170125135937_rename_attachable_to_attached_to.rb +13 -0
- data/db/migrate/20170126151123_add_extra_info_to_processes.rb +10 -0
- data/db/migrate/20170206083118_rename_extra_info_on_processes.rb +14 -0
- data/db/migrate/20170220110740_remove_steps_short_description.rb +23 -0
- data/db/migrate/20170221094835_add_scopes_to_processes.rb +8 -0
- data/db/migrate/20170228142440_add_participatory_process_groups.rb +17 -0
- data/db/migrate/20170404132616_change_steps_end_and_start_date_to_date.rb +8 -0
- data/db/migrate/20170720120135_make_features_polymorphic.rb +27 -0
- data/db/migrate/20170725085104_add_show_statistics_to_participatory_processes.rb +7 -0
- data/db/migrate/20170804125402_attachment_description_nullable.rb +7 -0
- data/db/migrate/20170808080905_add_announcement_to_participatory_processes.rb +7 -0
- data/db/migrate/20170809084005_add_scopes_enabled_to_participatory_processes.rb +7 -0
- data/db/migrate/20170830081725_add_start_date_to_processes.rb +8 -0
- data/db/seeds/Exampledocument.pdf +0 -0
- data/db/seeds/city.jpeg +0 -0
- data/db/seeds/city2.jpeg +0 -0
- data/db/seeds/homepage_image.jpg +0 -0
- data/lib/decidim/participatory_processes.rb +12 -0
- data/lib/decidim/participatory_processes/admin.rb +10 -0
- data/lib/decidim/participatory_processes/admin_engine.rb +98 -0
- data/lib/decidim/participatory_processes/engine.rb +55 -0
- data/lib/decidim/participatory_processes/participatory_space.rb +118 -0
- data/lib/decidim/participatory_processes/test/factories.rb +97 -0
- metadata +266 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class ParticipatoryProcessGroup < ApplicationRecord
|
5
|
+
has_many :participatory_processes,
|
6
|
+
foreign_key: "decidim_participatory_process_group_id",
|
7
|
+
class_name: "Decidim::ParticipatoryProcess",
|
8
|
+
inverse_of: :participatory_process_group
|
9
|
+
belongs_to :organization,
|
10
|
+
foreign_key: "decidim_organization_id",
|
11
|
+
class_name: "Decidim::Organization"
|
12
|
+
|
13
|
+
mount_uploader :hero_image, Decidim::HeroImageUploader
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A ParticipatoryProcess is composed of many steps that hold different
|
5
|
+
# features that will show up in the depending on what step is currently
|
6
|
+
# active.
|
7
|
+
class ParticipatoryProcessStep < ApplicationRecord
|
8
|
+
belongs_to :participatory_process, foreign_key: "decidim_participatory_process_id", class_name: "Decidim::ParticipatoryProcess"
|
9
|
+
has_one :organization, through: :participatory_process
|
10
|
+
|
11
|
+
validates :start_date, date: { before: :end_date, allow_blank: true, if: proc { |obj| obj.end_date.present? } }
|
12
|
+
validates :end_date, date: { after: :start_date, allow_blank: true, if: proc { |obj| obj.start_date.present? } }
|
13
|
+
|
14
|
+
validates :active, uniqueness: { scope: :decidim_participatory_process_id }, if: proc { |step| step.active? }
|
15
|
+
|
16
|
+
validates :position, numericality: { greater_than_or_equal_to: 0, only_integer: true }, allow_blank: true
|
17
|
+
validates :position, uniqueness: { scope: :decidim_participatory_process_id }
|
18
|
+
|
19
|
+
before_create :set_position
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# Internal: Sets the position of the step if it is `nil`. That means that
|
24
|
+
# when the step is the first of the process, and no position is set
|
25
|
+
# manually, it will be set to 0, and when it is not the only one it will be
|
26
|
+
# set to the last step's position + 1.
|
27
|
+
#
|
28
|
+
# Note: This allows manual positioning, but there is a validation that
|
29
|
+
# forbids two steps from the same proccess to have the same position. Take
|
30
|
+
# that into account. It would be best if you did not use manual
|
31
|
+
# positioning.
|
32
|
+
def set_position
|
33
|
+
return if position.present?
|
34
|
+
return self.position = 0 if participatory_process.steps.select(&:persisted?).empty?
|
35
|
+
|
36
|
+
self.position = participatory_process.steps.pluck(:position).last + 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Abilities
|
6
|
+
module Admin
|
7
|
+
# Defines the abilities for a user in the admin section. Intended to be
|
8
|
+
# used with `cancancan`.
|
9
|
+
class AdminAbility < Decidim::Abilities::AdminAbility
|
10
|
+
def define_abilities
|
11
|
+
super
|
12
|
+
|
13
|
+
can :manage, ParticipatoryProcess
|
14
|
+
can :manage, ParticipatoryProcessGroup
|
15
|
+
can :manage, ParticipatoryProcessStep
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Abilities
|
6
|
+
# Defines the abilities for an admin user. Intended to be used with `cancancan`.
|
7
|
+
class AdminAbility < Decidim::Abilities::AdminAbility
|
8
|
+
def define_abilities
|
9
|
+
super
|
10
|
+
|
11
|
+
can :read, ParticipatoryProcess
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Abilities
|
6
|
+
# Defines the base abilities related to participatory processes for any
|
7
|
+
# user. Guest users will use these too. Intended to be used with
|
8
|
+
# `cancancan`.
|
9
|
+
class EveryoneAbility < Decidim::Abilities::EveryoneAbility
|
10
|
+
def initialize(user, context)
|
11
|
+
super(user, context)
|
12
|
+
|
13
|
+
can :read, ParticipatoryProcessGroup
|
14
|
+
can :read, ParticipatoryProcess, &:published?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# A presenter to render statistics in the homepage.
|
6
|
+
class ParticipatoryProcessStatsPresenter < Rectify::Presenter
|
7
|
+
attribute :participatory_process, Decidim::ParticipatoryProcess
|
8
|
+
include Decidim::IconHelper
|
9
|
+
|
10
|
+
# Public: Render a collection of primary stats.
|
11
|
+
def highlighted
|
12
|
+
highlighted_stats = feature_stats(priority: StatsRegistry::HIGH_PRIORITY)
|
13
|
+
highlighted_stats = highlighted_stats.concat(feature_stats(priority: StatsRegistry::MEDIUM_PRIORITY))
|
14
|
+
highlighted_stats = highlighted_stats.reject(&:empty?)
|
15
|
+
highlighted_stats = highlighted_stats.reject { |_manifest, _name, data| data.zero? }
|
16
|
+
grouped_highlighted_stats = highlighted_stats.group_by { |stats| stats.first.name }
|
17
|
+
|
18
|
+
safe_join(
|
19
|
+
grouped_highlighted_stats.map do |_manifest_name, stats|
|
20
|
+
content_tag :div, class: "process_stats-item" do
|
21
|
+
safe_join(
|
22
|
+
stats.each_with_index.map do |stat, index|
|
23
|
+
render_stats_data(stat[0], stat[1], stat[2], index)
|
24
|
+
end
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def feature_stats(conditions)
|
34
|
+
Decidim.feature_manifests.map do |feature_manifest|
|
35
|
+
feature_manifest.stats.filter(conditions).with_context(published_features).map { |name, data| [feature_manifest, name, data] }.flatten
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def render_stats_data(feature_manifest, name, data, index)
|
40
|
+
safe_join([
|
41
|
+
index.zero? ? manifest_icon(feature_manifest) : " / ".html_safe,
|
42
|
+
content_tag(:span, "#{number_with_delimiter(data)} " + I18n.t(name, scope: "decidim.participatory_processes.statistics"),
|
43
|
+
class: "#{name} process_stats-text")
|
44
|
+
])
|
45
|
+
end
|
46
|
+
|
47
|
+
def published_features
|
48
|
+
@published_features ||= Feature.where(participatory_space: participatory_process).published
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Admin
|
6
|
+
# A class used to find the admins for a participatory process including
|
7
|
+
# organization admins.
|
8
|
+
class AdminUsers < Rectify::Query
|
9
|
+
# Syntactic sugar to initialize the class and return the queried objects.
|
10
|
+
#
|
11
|
+
# process - a process that needs to find its process admins
|
12
|
+
def self.for(process)
|
13
|
+
new(process).query
|
14
|
+
end
|
15
|
+
|
16
|
+
# Initializes the class.
|
17
|
+
#
|
18
|
+
# process - a process that needs to find its process admins
|
19
|
+
def initialize(process)
|
20
|
+
@process = process
|
21
|
+
end
|
22
|
+
|
23
|
+
# Finds organization admins and the users with role admin for the given process.
|
24
|
+
#
|
25
|
+
# Returns an ActiveRecord::Relation.
|
26
|
+
def query
|
27
|
+
Decidim::User.where(id: organization_admins).or(Decidim::User.where(id: process_admins))
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :process
|
33
|
+
|
34
|
+
def organization_admins
|
35
|
+
process.organization.admins
|
36
|
+
end
|
37
|
+
|
38
|
+
def process_admins
|
39
|
+
Decidim::ParticipatoryProcessUserRole
|
40
|
+
.where(participatory_process: process, role: :admin)
|
41
|
+
.pluck(:decidim_user_id)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This query class filters participatory processes groups given a filter name.
|
6
|
+
# The filter is applied checking the start and end dates of the processes in
|
7
|
+
# the group.
|
8
|
+
class FilteredParticipatoryProcessGroups < Rectify::Query
|
9
|
+
def initialize(filter = "active")
|
10
|
+
@filter = filter
|
11
|
+
end
|
12
|
+
|
13
|
+
def query
|
14
|
+
processes = Decidim::ParticipatoryProcess.all
|
15
|
+
|
16
|
+
processes = case @filter
|
17
|
+
when "past"
|
18
|
+
processes.where("decidim_participatory_processes.end_date <= ?", Time.current)
|
19
|
+
when "upcoming"
|
20
|
+
processes.where("decidim_participatory_processes.start_date > ?", Time.current)
|
21
|
+
else
|
22
|
+
processes
|
23
|
+
end
|
24
|
+
|
25
|
+
Decidim::ParticipatoryProcessGroup.where(id: processes.pluck(:decidim_participatory_process_group_id))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This query class filters participatory processes given a filter name.
|
6
|
+
# It uses the start and end dates to select the correct processes.
|
7
|
+
class FilteredParticipatoryProcesses < Rectify::Query
|
8
|
+
def initialize(filter = "active")
|
9
|
+
@filter = filter
|
10
|
+
end
|
11
|
+
|
12
|
+
def query
|
13
|
+
processes = Decidim::ParticipatoryProcess.all
|
14
|
+
|
15
|
+
case @filter
|
16
|
+
when "past"
|
17
|
+
processes.where("decidim_participatory_processes.end_date <= ?", Time.current)
|
18
|
+
when "upcoming"
|
19
|
+
processes.where("decidim_participatory_processes.start_date > ?", Time.current)
|
20
|
+
else
|
21
|
+
processes
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This query selects some prioritized processes.
|
6
|
+
class HighlightedParticipatoryProcesses < Rectify::Query
|
7
|
+
def query
|
8
|
+
PrioritizedParticipatoryProcesses.new.query.limit(8)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This query class filters participatory process groups given an organization.
|
6
|
+
class OrganizationParticipatoryProcessGroups < Rectify::Query
|
7
|
+
def initialize(organization)
|
8
|
+
@organization = organization
|
9
|
+
end
|
10
|
+
|
11
|
+
def query
|
12
|
+
Decidim::ParticipatoryProcessGroup.where(organization: @organization)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This query class filters all processes given an organization.
|
6
|
+
class OrganizationParticipatoryProcesses < Rectify::Query
|
7
|
+
def initialize(organization)
|
8
|
+
@organization = organization
|
9
|
+
end
|
10
|
+
|
11
|
+
def query
|
12
|
+
Decidim::ParticipatoryProcess.where(organization: @organization)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This query class filters participatory process groups given an organization and a filter.
|
6
|
+
class OrganizationPrioritizedParticipatoryProcessGroups < Rectify::Query
|
7
|
+
def initialize(organization, filter = "active")
|
8
|
+
@organization = organization
|
9
|
+
@filter = filter
|
10
|
+
end
|
11
|
+
|
12
|
+
def query
|
13
|
+
Rectify::Query.merge(
|
14
|
+
OrganizationParticipatoryProcessGroups.new(@organization),
|
15
|
+
FilteredParticipatoryProcessGroups.new(@filter)
|
16
|
+
).query
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/app/queries/decidim/participatory_processes/organization_prioritized_participatory_processes.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This query class filters public processes given an organization and a
|
6
|
+
# filter in a meaningful prioritized order.
|
7
|
+
class OrganizationPrioritizedParticipatoryProcesses < Rectify::Query
|
8
|
+
def initialize(organization, filter = "active")
|
9
|
+
@organization = organization
|
10
|
+
@filter = filter
|
11
|
+
end
|
12
|
+
|
13
|
+
def query
|
14
|
+
Rectify::Query.merge(
|
15
|
+
OrganizationPublishedParticipatoryProcesses.new(@organization),
|
16
|
+
PrioritizedParticipatoryProcesses.new,
|
17
|
+
FilteredParticipatoryProcesses.new(@filter)
|
18
|
+
).query
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/app/queries/decidim/participatory_processes/organization_published_participatory_processes.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This query class filters published processes given an organization.
|
6
|
+
class OrganizationPublishedParticipatoryProcesses < Rectify::Query
|
7
|
+
def initialize(organization)
|
8
|
+
@organization = organization
|
9
|
+
end
|
10
|
+
|
11
|
+
def query
|
12
|
+
Rectify::Query.merge(
|
13
|
+
OrganizationParticipatoryProcesses.new(@organization),
|
14
|
+
PublishedParticipatoryProcesses.new
|
15
|
+
).query
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This query orders processes by importance, prioritizing promoted processes
|
6
|
+
# first, and closest to finalization date second.
|
7
|
+
class PrioritizedParticipatoryProcesses < Rectify::Query
|
8
|
+
def query
|
9
|
+
Decidim::ParticipatoryProcess.order(promoted: :desc).includes(:active_step).order("decidim_participatory_process_steps.end_date ASC")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This query filters processes so only promoted ones are returned.
|
6
|
+
class PromotedParticipatoryProcesses < Rectify::Query
|
7
|
+
def query
|
8
|
+
Decidim::ParticipatoryProcess.promoted
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This query filters published processes only.
|
6
|
+
class PublishedParticipatoryProcesses < Rectify::Query
|
7
|
+
def query
|
8
|
+
Decidim::ParticipatoryProcess.published
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<div class="column">
|
2
|
+
<article class="card card--process">
|
3
|
+
<%= link_to participatory_process_group_path(participatory_process_group), class: "card__link" do %>
|
4
|
+
<div class="card__image-top"
|
5
|
+
style="background-image:url(<%= participatory_process_group.hero_image.url %>)"></div>
|
6
|
+
<% end %>
|
7
|
+
<div class="card__content">
|
8
|
+
<%= link_to participatory_process_group_path(participatory_process_group), class: "card__link" do %>
|
9
|
+
<h4 class="card__title"><%= translated_attribute participatory_process_group.name %></h4>
|
10
|
+
<% end %>
|
11
|
+
<p class="card__desc"><%== html_truncate(translated_attribute(participatory_process_group.description), length: 630, separator: '...') %></p>
|
12
|
+
</div>
|
13
|
+
<div class="card__footer">
|
14
|
+
<div class="card__support">
|
15
|
+
<span class="card--process__small"></span>
|
16
|
+
<%= link_to participatory_process_group_path(participatory_process_group), class: "card__button button small" do %>
|
17
|
+
<%= t(".browse", scope: "layouts") %>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</article>
|
22
|
+
</div>
|