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
data/app/controllers/decidim/participatory_processes/participatory_process_widgets_controller.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
class ParticipatoryProcessWidgetsController < Decidim::WidgetsController
|
6
|
+
private
|
7
|
+
|
8
|
+
def model
|
9
|
+
@model ||= ParticipatoryProcess.find(params[:participatory_process_id])
|
10
|
+
end
|
11
|
+
|
12
|
+
def current_participatory_space
|
13
|
+
model
|
14
|
+
end
|
15
|
+
|
16
|
+
def iframe_url
|
17
|
+
@iframe_url ||= participatory_process_participatory_process_widget_url(model)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# A controller that holds the logic to show ParticipatoryProcesses in a
|
6
|
+
# public layout.
|
7
|
+
class ParticipatoryProcessesController < Decidim::ApplicationController
|
8
|
+
layout "layouts/decidim/participatory_process", only: [:show]
|
9
|
+
|
10
|
+
before_action -> { extend NeedsParticipatoryProcess }, only: [:show]
|
11
|
+
|
12
|
+
helper Decidim::AttachmentsHelper
|
13
|
+
helper Decidim::IconHelper
|
14
|
+
helper Decidim::WidgetUrlsHelper
|
15
|
+
|
16
|
+
helper ParticipatoryProcessHelper
|
17
|
+
|
18
|
+
helper_method :collection, :promoted_participatory_processes, :participatory_processes, :stats, :filter
|
19
|
+
|
20
|
+
def index
|
21
|
+
authorize! :read, ParticipatoryProcess
|
22
|
+
authorize! :read, ParticipatoryProcessGroup
|
23
|
+
end
|
24
|
+
|
25
|
+
def show
|
26
|
+
authorize! :read, current_participatory_process
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def collection
|
32
|
+
@collection ||= (participatory_processes.to_a + participatory_process_groups).flatten
|
33
|
+
end
|
34
|
+
|
35
|
+
def filtered_participatory_processes(filter = default_filter)
|
36
|
+
OrganizationPrioritizedParticipatoryProcesses.new(current_organization, filter)
|
37
|
+
end
|
38
|
+
|
39
|
+
def participatory_processes
|
40
|
+
@participatory_processes ||= filtered_participatory_processes(filter)
|
41
|
+
end
|
42
|
+
|
43
|
+
def promoted_participatory_processes
|
44
|
+
@promoted_processes ||= filtered_participatory_processes | PromotedParticipatoryProcesses.new
|
45
|
+
end
|
46
|
+
|
47
|
+
def participatory_process_groups
|
48
|
+
@process_groups ||= OrganizationPrioritizedParticipatoryProcessGroups.new(current_organization, filter)
|
49
|
+
end
|
50
|
+
|
51
|
+
def stats
|
52
|
+
@stats ||= ParticipatoryProcessStatsPresenter.new(participatory_process: current_participatory_process)
|
53
|
+
end
|
54
|
+
|
55
|
+
def filter
|
56
|
+
@filter = params[:filter] || default_filter
|
57
|
+
end
|
58
|
+
|
59
|
+
def default_filter
|
60
|
+
"active"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Admin
|
6
|
+
# A form object used to copy a participatory processes from the admin
|
7
|
+
# dashboard.
|
8
|
+
#
|
9
|
+
class ParticipatoryProcessCopyForm < Form
|
10
|
+
include TranslatableAttributes
|
11
|
+
|
12
|
+
translatable_attribute :title, String
|
13
|
+
|
14
|
+
mimic :participatory_process
|
15
|
+
|
16
|
+
attribute :slug, String
|
17
|
+
attribute :copy_steps, Boolean
|
18
|
+
attribute :copy_categories, Boolean
|
19
|
+
attribute :copy_features, Boolean
|
20
|
+
|
21
|
+
validates :slug, presence: true
|
22
|
+
validates :title, translatable_presence: true
|
23
|
+
validate :slug, :slug_uniqueness
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def slug_uniqueness
|
28
|
+
return unless OrganizationParticipatoryProcesses.new(current_organization).query.where(slug: slug).where.not(id: id).any?
|
29
|
+
|
30
|
+
errors.add(:slug, :taken)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Admin
|
6
|
+
# A form object used to create participatory processes from the admin
|
7
|
+
# dashboard.
|
8
|
+
#
|
9
|
+
class ParticipatoryProcessForm < Form
|
10
|
+
include TranslatableAttributes
|
11
|
+
|
12
|
+
translatable_attribute :title, String
|
13
|
+
translatable_attribute :subtitle, String
|
14
|
+
translatable_attribute :description, String
|
15
|
+
translatable_attribute :short_description, String
|
16
|
+
translatable_attribute :meta_scope, String
|
17
|
+
translatable_attribute :developer_group, String
|
18
|
+
translatable_attribute :local_area, String
|
19
|
+
translatable_attribute :target, String
|
20
|
+
translatable_attribute :participatory_scope, String
|
21
|
+
translatable_attribute :participatory_structure, String
|
22
|
+
translatable_attribute :announcement, String
|
23
|
+
|
24
|
+
mimic :participatory_process
|
25
|
+
|
26
|
+
attribute :start_date, Date
|
27
|
+
attribute :end_date, Date
|
28
|
+
attribute :slug, String
|
29
|
+
attribute :hashtag, String
|
30
|
+
attribute :promoted, Boolean
|
31
|
+
attribute :scopes_enabled, Boolean
|
32
|
+
attribute :scope_id, Integer
|
33
|
+
attribute :hero_image
|
34
|
+
attribute :remove_hero_image
|
35
|
+
attribute :banner_image
|
36
|
+
attribute :remove_banner_image
|
37
|
+
attribute :participatory_process_group_id, Integer
|
38
|
+
attribute :show_statistics, Boolean
|
39
|
+
|
40
|
+
validates :slug, presence: true
|
41
|
+
validates :title, :subtitle, :description, :short_description, translatable_presence: true
|
42
|
+
validates :scope, presence: true, if: proc { |object| object.scope_id.present? }
|
43
|
+
|
44
|
+
validate :slug, :slug_uniqueness
|
45
|
+
|
46
|
+
validates :hero_image, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } }, file_content_type: { allow: ["image/jpeg", "image/png"] }
|
47
|
+
validates :banner_image, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } }, file_content_type: { allow: ["image/jpeg", "image/png"] }
|
48
|
+
|
49
|
+
def map_model(model)
|
50
|
+
self.scope_id = model.decidim_scope_id
|
51
|
+
self.participatory_process_group_id = model.decidim_participatory_process_group_id
|
52
|
+
end
|
53
|
+
|
54
|
+
def scope
|
55
|
+
@scope ||= current_organization.scopes.where(id: scope_id).first
|
56
|
+
end
|
57
|
+
|
58
|
+
def participatory_process_group
|
59
|
+
Decidim::ParticipatoryProcessGroup.where(id: participatory_process_group_id).first
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def slug_uniqueness
|
65
|
+
return unless OrganizationParticipatoryProcesses.new(current_organization).query.where(slug: slug).where.not(id: id).any?
|
66
|
+
|
67
|
+
errors.add(:slug, :taken)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Admin
|
6
|
+
# A form object used to create participatory process groups from the admin
|
7
|
+
# dashboard.
|
8
|
+
#
|
9
|
+
class ParticipatoryProcessGroupForm < Form
|
10
|
+
include TranslatableAttributes
|
11
|
+
|
12
|
+
translatable_attribute :name, String
|
13
|
+
translatable_attribute :description, String
|
14
|
+
attribute :participatory_process_ids, Array[Integer]
|
15
|
+
|
16
|
+
mimic :participatory_process_group
|
17
|
+
|
18
|
+
attribute :hero_image
|
19
|
+
|
20
|
+
validates :name, :description, translatable_presence: true
|
21
|
+
|
22
|
+
validates :hero_image, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } }, file_content_type: { allow: ["image/jpeg", "image/png"] }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Admin
|
6
|
+
# A form object used to create participatory processes steps from the admin
|
7
|
+
# dashboard.
|
8
|
+
#
|
9
|
+
class ParticipatoryProcessStepForm < Form
|
10
|
+
include TranslatableAttributes
|
11
|
+
|
12
|
+
translatable_attribute :title, String
|
13
|
+
translatable_attribute :description, String
|
14
|
+
|
15
|
+
mimic :participatory_process_step
|
16
|
+
|
17
|
+
attribute :start_date, DateTime
|
18
|
+
attribute :end_date, DateTime
|
19
|
+
|
20
|
+
validates :title, translatable_presence: true
|
21
|
+
|
22
|
+
validates :start_date, date: { before: :end_date, allow_blank: true, if: proc { |obj| obj.end_date.present? } }
|
23
|
+
validates :end_date, date: { after: :start_date, allow_blank: true, if: proc { |obj| obj.start_date.present? } }
|
24
|
+
|
25
|
+
def start_date
|
26
|
+
return nil unless super.respond_to?(:at_midnight)
|
27
|
+
super.at_midnight
|
28
|
+
end
|
29
|
+
|
30
|
+
def end_date
|
31
|
+
return nil unless super.respond_to?(:at_midnight)
|
32
|
+
super.at_midnight
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Admin
|
6
|
+
# A form object used to create participatory process user roles from the
|
7
|
+
# admin dashboard.
|
8
|
+
#
|
9
|
+
class ParticipatoryProcessUserRoleForm < Form
|
10
|
+
mimic :participatory_process_user_role
|
11
|
+
|
12
|
+
attribute :name, String
|
13
|
+
attribute :email, String
|
14
|
+
attribute :role, String
|
15
|
+
|
16
|
+
validates :email, :role, presence: true
|
17
|
+
validates :name, presence: true
|
18
|
+
validates :role, inclusion: { in: Decidim::ParticipatoryProcessUserRole::ROLES }
|
19
|
+
|
20
|
+
def roles
|
21
|
+
Decidim::ParticipatoryProcessUserRole::ROLES.map do |role|
|
22
|
+
[
|
23
|
+
I18n.t(role, scope: "decidim.admin.models.participatory_process_user_role.roles"),
|
24
|
+
role
|
25
|
+
]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Admin
|
6
|
+
# This class contains helpers needed to format ParticipatoryProcessGroups
|
7
|
+
# in order to use them in select forms.
|
8
|
+
#
|
9
|
+
module ProcessGroupsForSelectHelper
|
10
|
+
# Public: A formatted collection of ParticipatoryProcessGroups to be used
|
11
|
+
# in forms.
|
12
|
+
#
|
13
|
+
# Returns an Array.
|
14
|
+
def process_groups_for_select
|
15
|
+
@process_groups_for_select ||=
|
16
|
+
OrganizationParticipatoryProcessGroups.new(current_organization).map do |group|
|
17
|
+
[translated_attribute(group.name), group.id]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Admin
|
6
|
+
# This class contains helpers needed to format ParticipatoryProcesses
|
7
|
+
# in order to use them in select forms.
|
8
|
+
#
|
9
|
+
module ProcessesForSelectHelper
|
10
|
+
# Public: A formatted collection of ParticipatoryProcesses to be used
|
11
|
+
# in forms.
|
12
|
+
#
|
13
|
+
# Returns an Array.
|
14
|
+
def processes_for_select
|
15
|
+
@processes_for_select ||= OrganizationParticipatoryProcesses.new(current_organization).map do |process|
|
16
|
+
[
|
17
|
+
translated_attribute(process.title),
|
18
|
+
process.id
|
19
|
+
]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# Helpers related to the Participatory Process layout.
|
6
|
+
module ParticipatoryProcessHelper
|
7
|
+
# Public: Returns the dates for a step in a readable format like
|
8
|
+
# "2016-01-01 - 2016-02-05".
|
9
|
+
#
|
10
|
+
# participatory_process_step - The step to format to
|
11
|
+
#
|
12
|
+
# Returns a String with the formatted dates.
|
13
|
+
def participatory_process_step_dates(participatory_process_step)
|
14
|
+
dates = [participatory_process_step.start_date, participatory_process_step.end_date]
|
15
|
+
dates.map { |date| date ? localize(date.to_date, format: :default) : "?" }.join(" - ")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# Helper that provides a single method to give a class to a
|
6
|
+
# ParticipatoryProcessStep depending on their date.
|
7
|
+
module ParticipatoryProcessStepsHelper
|
8
|
+
# Returns the class for the given step depending on their end_date.
|
9
|
+
#
|
10
|
+
# step - the given ParticipatoryProcessStep
|
11
|
+
# past - a Boolean indicating if the step is past or not
|
12
|
+
#
|
13
|
+
# Returns a String.
|
14
|
+
def step_class(step, past)
|
15
|
+
status = past ? "" : "timeline__item--inactive"
|
16
|
+
step.active? ? "timeline__item--current" : status
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# Interaction between a user and an organization is done via a
|
5
|
+
# ParticipatoryProcess. It's a unit of action from the Organization point of
|
6
|
+
# view that groups several features (proposals, debates...) distributed in
|
7
|
+
# steps that get enabled or disabled depending on which step is currently
|
8
|
+
# active.
|
9
|
+
class ParticipatoryProcess < ApplicationRecord
|
10
|
+
include Decidim::HasAttachments
|
11
|
+
include Decidim::Participable
|
12
|
+
include Decidim::Publicable
|
13
|
+
include Decidim::Scopable
|
14
|
+
|
15
|
+
belongs_to :organization,
|
16
|
+
foreign_key: "decidim_organization_id",
|
17
|
+
class_name: "Decidim::Organization"
|
18
|
+
belongs_to :participatory_process_group,
|
19
|
+
foreign_key: "decidim_participatory_process_group_id",
|
20
|
+
class_name: "Decidim::ParticipatoryProcessGroup",
|
21
|
+
inverse_of: :participatory_processes,
|
22
|
+
optional: true
|
23
|
+
has_many :steps,
|
24
|
+
-> { order(position: :asc) },
|
25
|
+
foreign_key: "decidim_participatory_process_id",
|
26
|
+
class_name: "Decidim::ParticipatoryProcessStep",
|
27
|
+
dependent: :destroy,
|
28
|
+
inverse_of: :participatory_process
|
29
|
+
has_one :active_step,
|
30
|
+
-> { where(active: true) },
|
31
|
+
foreign_key: "decidim_participatory_process_id",
|
32
|
+
class_name: "Decidim::ParticipatoryProcessStep",
|
33
|
+
dependent: :destroy,
|
34
|
+
inverse_of: :participatory_process
|
35
|
+
has_many :categories,
|
36
|
+
foreign_key: "decidim_participatory_space_id",
|
37
|
+
foreign_type: "decidim_participatory_space_type",
|
38
|
+
dependent: :destroy,
|
39
|
+
as: :participatory_space
|
40
|
+
|
41
|
+
has_many :features, as: :participatory_space
|
42
|
+
|
43
|
+
attr_readonly :active_step
|
44
|
+
|
45
|
+
validates :slug, presence: true
|
46
|
+
validates :slug, uniqueness: { scope: :organization }
|
47
|
+
|
48
|
+
mount_uploader :hero_image, Decidim::HeroImageUploader
|
49
|
+
mount_uploader :banner_image, Decidim::BannerImageUploader
|
50
|
+
|
51
|
+
# Scope to return only the promoted processes.
|
52
|
+
#
|
53
|
+
# Returns an ActiveRecord::Relation.
|
54
|
+
def self.promoted
|
55
|
+
where(promoted: true)
|
56
|
+
end
|
57
|
+
|
58
|
+
def hashtag
|
59
|
+
attributes["hashtag"].to_s.delete("#")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|