decidim-participatory_processes 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +36 -0
  3. data/Rakefile +3 -0
  4. data/app/assets/config/admin/decidim_participatory_processes_manifest.js +1 -0
  5. data/app/assets/config/decidim_participatory_processes_manifest.js +2 -0
  6. data/app/assets/images/decidim/participatory_processes/process.svg +10 -0
  7. data/app/assets/javascripts/decidim/participatory_processes/admin/participatory_processes.js.es6 +12 -0
  8. data/app/assets/javascripts/decidim/participatory_processes/filters.js.es6 +25 -0
  9. data/app/commands/decidim/participatory_processes/admin/activate_participatory_process_step.rb +46 -0
  10. data/app/commands/decidim/participatory_processes/admin/copy_participatory_process.rb +116 -0
  11. data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +82 -0
  12. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb +95 -0
  13. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_group.rb +57 -0
  14. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_step.rb +49 -0
  15. data/app/commands/decidim/participatory_processes/admin/deactivate_participatory_process_step.rb +38 -0
  16. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_step.rb +46 -0
  17. data/app/commands/decidim/participatory_processes/admin/publish_participatory_process.rb +34 -0
  18. data/app/commands/decidim/participatory_processes/admin/reorder_participatory_process_steps.rb +54 -0
  19. data/app/commands/decidim/participatory_processes/admin/unpublish_participatory_process.rb +34 -0
  20. data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +77 -0
  21. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_admin.rb +43 -0
  22. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_group.rb +60 -0
  23. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb +51 -0
  24. data/app/constraints/decidim/participatory_processes/current_feature.rb +28 -0
  25. data/app/constraints/decidim/participatory_processes/current_participatory_process.rb +37 -0
  26. data/app/controllers/concerns/decidim/participatory_processes/admin/participatory_process_context.rb +21 -0
  27. data/app/controllers/concerns/decidim/participatory_processes/needs_participatory_process.rb +50 -0
  28. data/app/controllers/concerns/decidim/participatory_processes/participatory_process_context.rb +27 -0
  29. data/app/controllers/decidim/participatory_processes/admin/application_controller.rb +11 -0
  30. data/app/controllers/decidim/participatory_processes/admin/categories_controller.rb +13 -0
  31. data/app/controllers/decidim/participatory_processes/admin/concerns/participatory_process_admin.rb +26 -0
  32. data/app/controllers/decidim/participatory_processes/admin/exports_controller.rb +14 -0
  33. data/app/controllers/decidim/participatory_processes/admin/feature_permissions_controller.rb +14 -0
  34. data/app/controllers/decidim/participatory_processes/admin/features_controller.rb +14 -0
  35. data/app/controllers/decidim/participatory_processes/admin/moderations_controller.rb +12 -0
  36. data/app/controllers/decidim/participatory_processes/admin/participatory_process_attachments_controller.rb +27 -0
  37. data/app/controllers/decidim/participatory_processes/admin/participatory_process_copies_controller.rb +35 -0
  38. data/app/controllers/decidim/participatory_processes/admin/participatory_process_groups_controller.rb +90 -0
  39. data/app/controllers/decidim/participatory_processes/admin/participatory_process_publications_controller.rb +45 -0
  40. data/app/controllers/decidim/participatory_processes/admin/participatory_process_step_activations_controller.rb +39 -0
  41. data/app/controllers/decidim/participatory_processes/admin/participatory_process_step_ordering_controller.rb +29 -0
  42. data/app/controllers/decidim/participatory_processes/admin/participatory_process_steps_controller.rb +91 -0
  43. data/app/controllers/decidim/participatory_processes/admin/participatory_process_user_roles_controller.rb +99 -0
  44. data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb +102 -0
  45. data/app/controllers/decidim/participatory_processes/participatory_process_groups_controller.rb +28 -0
  46. data/app/controllers/decidim/participatory_processes/participatory_process_steps_controller.rb +20 -0
  47. data/app/controllers/decidim/participatory_processes/participatory_process_widgets_controller.rb +21 -0
  48. data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +64 -0
  49. data/app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb +35 -0
  50. data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +72 -0
  51. data/app/forms/decidim/participatory_processes/admin/participatory_process_group_form.rb +26 -0
  52. data/app/forms/decidim/participatory_processes/admin/participatory_process_step_form.rb +37 -0
  53. data/app/forms/decidim/participatory_processes/admin/participatory_process_user_role_form.rb +31 -0
  54. data/app/helpers/decidim/participatory_processes/admin/process_groups_for_select_helper.rb +23 -0
  55. data/app/helpers/decidim/participatory_processes/admin/processes_for_select_helper.rb +25 -0
  56. data/app/helpers/decidim/participatory_processes/participatory_process_helper.rb +19 -0
  57. data/app/helpers/decidim/participatory_processes/participatory_process_steps_helper.rb +20 -0
  58. data/app/models/decidim/participatory_process.rb +62 -0
  59. data/app/models/decidim/participatory_process_group.rb +15 -0
  60. data/app/models/decidim/participatory_process_step.rb +39 -0
  61. data/app/models/decidim/participatory_processes/abilities/admin/admin_ability.rb +21 -0
  62. data/app/models/decidim/participatory_processes/abilities/admin_ability.rb +16 -0
  63. data/app/models/decidim/participatory_processes/abilities/everyone_ability.rb +19 -0
  64. data/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb +52 -0
  65. data/app/queries/decidim/participatory_processes/admin/admin_users.rb +46 -0
  66. data/app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb +29 -0
  67. data/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb +26 -0
  68. data/app/queries/decidim/participatory_processes/highlighted_participatory_processes.rb +12 -0
  69. data/app/queries/decidim/participatory_processes/organization_participatory_process_groups.rb +16 -0
  70. data/app/queries/decidim/participatory_processes/organization_participatory_processes.rb +16 -0
  71. data/app/queries/decidim/participatory_processes/organization_prioritized_participatory_process_groups.rb +20 -0
  72. data/app/queries/decidim/participatory_processes/organization_prioritized_participatory_processes.rb +22 -0
  73. data/app/queries/decidim/participatory_processes/organization_published_participatory_processes.rb +19 -0
  74. data/app/queries/decidim/participatory_processes/prioritized_participatory_processes.rb +13 -0
  75. data/app/queries/decidim/participatory_processes/promoted_participatory_processes.rb +12 -0
  76. data/app/queries/decidim/participatory_processes/published_participatory_processes.rb +12 -0
  77. data/app/views/decidim/participatory_process_groups/_participatory_process_group.html.erb +22 -0
  78. data/app/views/decidim/participatory_process_steps/_participatory_process_step.html.erb +16 -0
  79. data/app/views/decidim/participatory_processes/_order_by_processes.html.erb +12 -0
  80. data/app/views/decidim/participatory_processes/_participatory_process.html.erb +28 -0
  81. data/app/views/decidim/participatory_processes/admin/participatory_process_copies/_form.html.erb +38 -0
  82. data/app/views/decidim/participatory_processes/admin/participatory_process_copies/new.html.erb +7 -0
  83. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/_form.html.erb +17 -0
  84. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/edit.html.erb +19 -0
  85. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/index.html.erb +44 -0
  86. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/new.html.erb +13 -0
  87. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/show.html.erb +23 -0
  88. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/_form.html.erb +25 -0
  89. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/edit.html.erb +8 -0
  90. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/index.html.erb +63 -0
  91. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/new.html.erb +7 -0
  92. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/show.html.erb +18 -0
  93. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/_form.html.erb +22 -0
  94. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/edit.html.erb +7 -0
  95. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/index.html.erb +65 -0
  96. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/new.html.erb +7 -0
  97. data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +107 -0
  98. data/app/views/decidim/participatory_processes/admin/participatory_processes/edit.html.erb +19 -0
  99. data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +66 -0
  100. data/app/views/decidim/participatory_processes/admin/participatory_processes/new.html.erb +11 -0
  101. data/app/views/decidim/participatory_processes/participatory_process_groups/show.html.erb +11 -0
  102. data/app/views/decidim/participatory_processes/participatory_process_steps/_timeline.html.erb +7 -0
  103. data/app/views/decidim/participatory_processes/participatory_process_steps/index.html.erb +14 -0
  104. data/app/views/decidim/participatory_processes/participatory_process_widgets/show.html.erb +17 -0
  105. data/app/views/decidim/participatory_processes/participatory_processes/_no_processes_yet.html.erb +3 -0
  106. data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process.html.erb +32 -0
  107. data/app/views/decidim/participatory_processes/participatory_processes/_statistics.html.erb +10 -0
  108. data/app/views/decidim/participatory_processes/participatory_processes/index.html.erb +22 -0
  109. data/app/views/decidim/participatory_processes/participatory_processes/index.js.erb +6 -0
  110. data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +92 -0
  111. data/app/views/layouts/decidim/_process_header.html.erb +65 -0
  112. data/app/views/layouts/decidim/_process_header_steps.html.erb +27 -0
  113. data/app/views/layouts/decidim/admin/participatory_process.html.erb +64 -0
  114. data/app/views/layouts/decidim/admin/participatory_process_groups.html.erb +14 -0
  115. data/app/views/layouts/decidim/admin/participatory_processes.html.erb +14 -0
  116. data/app/views/layouts/decidim/participatory_process.html.erb +30 -0
  117. data/config/locales/ca.yml +281 -0
  118. data/config/locales/en.yml +281 -0
  119. data/config/locales/es.yml +281 -0
  120. data/config/locales/eu.yml +280 -0
  121. data/config/locales/fi.yml +280 -0
  122. data/config/locales/fr.yml +280 -0
  123. data/config/locales/it.yml +280 -0
  124. data/config/locales/nl.yml +280 -0
  125. data/config/locales/pl.yml +281 -0
  126. data/config/locales/uk.yml +282 -0
  127. data/db/migrate/20161005130108_add_participatory_processes.rb +19 -0
  128. data/db/migrate/20161010102356_translate_processes.rb +17 -0
  129. data/db/migrate/20161011125616_add_hero_image_to_processes.rb +7 -0
  130. data/db/migrate/20161011141033_add_banner_image_to_processes.rb +7 -0
  131. data/db/migrate/20161013134732_add_promoted_flag_to_processes.rb +7 -0
  132. data/db/migrate/20161017085822_add_participatory_process_steps.rb +18 -0
  133. data/db/migrate/20161019072016_add_active_flag_to_step.rb +13 -0
  134. data/db/migrate/20161020080756_add_position_to_steps.rb +9 -0
  135. data/db/migrate/20161025125300_add_published_at_to_processes.rb +7 -0
  136. data/db/migrate/20161107152228_remove_not_null_on_step_position.rb +7 -0
  137. data/db/migrate/20161110092735_add_index_for_process_slug_organization.rb +10 -0
  138. data/db/migrate/20161116115156_create_attachments.rb +18 -0
  139. data/db/migrate/20170116135237_loosen_step_requirements.rb +8 -0
  140. data/db/migrate/20170123134023_make_attachments_polymorphic.rb +20 -0
  141. data/db/migrate/20170125135937_rename_attachable_to_attached_to.rb +13 -0
  142. data/db/migrate/20170126151123_add_extra_info_to_processes.rb +10 -0
  143. data/db/migrate/20170206083118_rename_extra_info_on_processes.rb +14 -0
  144. data/db/migrate/20170220110740_remove_steps_short_description.rb +23 -0
  145. data/db/migrate/20170221094835_add_scopes_to_processes.rb +8 -0
  146. data/db/migrate/20170228142440_add_participatory_process_groups.rb +17 -0
  147. data/db/migrate/20170404132616_change_steps_end_and_start_date_to_date.rb +8 -0
  148. data/db/migrate/20170720120135_make_features_polymorphic.rb +27 -0
  149. data/db/migrate/20170725085104_add_show_statistics_to_participatory_processes.rb +7 -0
  150. data/db/migrate/20170804125402_attachment_description_nullable.rb +7 -0
  151. data/db/migrate/20170808080905_add_announcement_to_participatory_processes.rb +7 -0
  152. data/db/migrate/20170809084005_add_scopes_enabled_to_participatory_processes.rb +7 -0
  153. data/db/migrate/20170830081725_add_start_date_to_processes.rb +8 -0
  154. data/db/seeds/Exampledocument.pdf +0 -0
  155. data/db/seeds/city.jpeg +0 -0
  156. data/db/seeds/city2.jpeg +0 -0
  157. data/db/seeds/homepage_image.jpg +0 -0
  158. data/lib/decidim/participatory_processes.rb +12 -0
  159. data/lib/decidim/participatory_processes/admin.rb +10 -0
  160. data/lib/decidim/participatory_processes/admin_engine.rb +98 -0
  161. data/lib/decidim/participatory_processes/engine.rb +55 -0
  162. data/lib/decidim/participatory_processes/participatory_space.rb +118 -0
  163. data/lib/decidim/participatory_processes/test/factories.rb +97 -0
  164. metadata +266 -0
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ class MakeAttachmentsPolymorphic < ActiveRecord::Migration[5.0]
4
+ def change
5
+ transaction do
6
+ remove_index :decidim_participatory_process_attachments, name: "index_decidim_processes_attachments_on_decidim_process_id"
7
+ rename_table :decidim_participatory_process_attachments, :decidim_attachments
8
+
9
+ add_column :decidim_attachments, :attachable_type, :string
10
+ ActiveRecord::Base.connection
11
+ .execute("UPDATE decidim_attachments SET attachable_type = 'Decidim::ParticipatoryProcess'")
12
+
13
+ rename_column :decidim_attachments, :decidim_participatory_process_id, :attachable_id
14
+ add_index :decidim_attachments, [:attachable_id, :attachable_type]
15
+
16
+ change_column_null(:decidim_attachments, :attachable_id, false)
17
+ change_column_null(:decidim_attachments, :attachable_type, false)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RenameAttachableToAttachedTo < ActiveRecord::Migration[5.0]
4
+ def change
5
+ remove_index :decidim_attachments, name: "index_decidim_attachments_on_attachable_id_and_attachable_type"
6
+ remove_foreign_key :decidim_attachments, column: :attachable_id
7
+
8
+ rename_column :decidim_attachments, :attachable_id, :attached_to_id
9
+ rename_column :decidim_attachments, :attachable_type, :attached_to_type
10
+
11
+ add_index :decidim_attachments, [:attached_to_id, :attached_to_type], name: "index_decidim_attachments_on_attached_to"
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddExtraInfoToProcesses < ActiveRecord::Migration[5.0]
4
+ def change
5
+ add_column :decidim_participatory_processes, :domain, :jsonb
6
+ add_column :decidim_participatory_processes, :end_date, :date
7
+ add_column :decidim_participatory_processes, :developer_group, :string
8
+ add_column :decidim_participatory_processes, :scope, :jsonb
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RenameExtraInfoOnProcesses < ActiveRecord::Migration[5.0]
4
+ def change
5
+ remove_column :decidim_participatory_processes, :developer_group
6
+
7
+ rename_column :decidim_participatory_processes, :domain, :developer_group
8
+
9
+ add_column :decidim_participatory_processes, :local_area, :jsonb
10
+ add_column :decidim_participatory_processes, :target, :jsonb
11
+ add_column :decidim_participatory_processes, :participatory_scope, :jsonb
12
+ add_column :decidim_participatory_processes, :participatory_structure, :jsonb
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RemoveStepsShortDescription < ActiveRecord::Migration[5.0]
4
+ def change
5
+ Decidim::ParticipatoryProcessStep.transaction do
6
+ Decidim::ParticipatoryProcessStep.find_each do |step|
7
+ step.update_attributes!(
8
+ description: new_description_for(step)
9
+ )
10
+ end
11
+
12
+ remove_column :decidim_participatory_process_steps, :short_description
13
+ end
14
+ end
15
+
16
+ def new_description_for(step)
17
+ desc = {}
18
+ step.description.keys.each do |locale|
19
+ desc[locale] = step.short_description[locale] + step.description[locale]
20
+ end
21
+ desc
22
+ end
23
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddScopesToProcesses < ActiveRecord::Migration[5.0]
4
+ def change
5
+ rename_column :decidim_participatory_processes, :scope, :meta_scope
6
+ add_column :decidim_participatory_processes, :decidim_scope_id, :integer
7
+ end
8
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddParticipatoryProcessGroups < ActiveRecord::Migration[5.0]
4
+ def change
5
+ create_table :decidim_participatory_process_groups do |t|
6
+ t.jsonb :name, null: false
7
+ t.jsonb :description, null: false
8
+ t.string :hero_image
9
+
10
+ t.references :decidim_organization, index: { name: "decidim_participatory_process_group_organization" }
11
+
12
+ t.timestamps
13
+ end
14
+
15
+ add_column :decidim_participatory_processes, :decidim_participatory_process_group_id, :integer
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ChangeStepsEndAndStartDateToDate < ActiveRecord::Migration[5.0]
4
+ def change
5
+ change_column :decidim_participatory_process_steps, :start_date, :date
6
+ change_column :decidim_participatory_process_steps, :end_date, :date
7
+ end
8
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ class MakeFeaturesPolymorphic < ActiveRecord::Migration[5.1]
4
+ def change
5
+ remove_index :decidim_features, name: "index_decidim_features_on_decidim_participatory_process_id"
6
+
7
+ add_column :decidim_features, :participatory_space_type, :string
8
+
9
+ reversible do |direction|
10
+ direction.up do
11
+ execute <<~SQL.squish
12
+ UPDATE decidim_features
13
+ SET participatory_space_type = 'Decidim::ParticipatoryProcess'
14
+ SQL
15
+ end
16
+ end
17
+
18
+ rename_column :decidim_features, :decidim_participatory_process_id, :participatory_space_id
19
+
20
+ add_index :decidim_features,
21
+ [:participatory_space_id, :participatory_space_type],
22
+ name: "index_decidim_features_on_decidim_participatory_space"
23
+
24
+ change_column_null :decidim_features, :participatory_space_id, false
25
+ change_column_null :decidim_features, :participatory_space_type, false
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddShowStatisticsToParticipatoryProcesses < ActiveRecord::Migration[5.1]
4
+ def change
5
+ add_column :decidim_participatory_processes, :show_statistics, :boolean, default: true
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AttachmentDescriptionNullable < ActiveRecord::Migration[5.1]
4
+ def change
5
+ change_column :decidim_attachments, :description, :jsonb, null: true
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddAnnouncementToParticipatoryProcesses < ActiveRecord::Migration[5.1]
4
+ def change
5
+ add_column :decidim_participatory_processes, :announcement, :jsonb
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddScopesEnabledToParticipatoryProcesses < ActiveRecord::Migration[5.1]
4
+ def change
5
+ add_column :decidim_participatory_processes, :scopes_enabled, :boolean, null: false, default: true
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddStartDateToProcesses < ActiveRecord::Migration[5.1]
4
+ def change
5
+ add_column :decidim_participatory_processes, :start_date, :date
6
+ ActiveRecord::Base.connection.execute("UPDATE decidim_participatory_processes SET start_date = created_at")
7
+ end
8
+ end
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/participatory_processes/admin"
4
+ require "decidim/participatory_processes/engine"
5
+ require "decidim/participatory_processes/admin_engine"
6
+ require "decidim/participatory_processes/participatory_space"
7
+
8
+ module Decidim
9
+ # Base module for the participatory processes engine.
10
+ module ParticipatoryProcesses
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # This module contains all the domain logic associated to Decidim's
6
+ # Participatory processes component admin panel.
7
+ module Admin
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+ require "active_support/all"
5
+
6
+ require "decidim/core"
7
+
8
+ module Decidim
9
+ module ParticipatoryProcesses
10
+ # Decidim's Processes Rails Admin Engine.
11
+ class AdminEngine < ::Rails::Engine
12
+ isolate_namespace Decidim::ParticipatoryProcesses::Admin
13
+
14
+ paths["db/migrate"] = nil
15
+
16
+ routes do
17
+ resources :participatory_process_groups
18
+ resources :participatory_processes, except: :show do
19
+ resource :publish, controller: "participatory_process_publications", only: [:create, :destroy]
20
+ resources :copies, controller: "participatory_process_copies", only: [:new, :create]
21
+
22
+ resources :steps, controller: "participatory_process_steps" do
23
+ resource :activate, controller: "participatory_process_step_activations", only: [:create, :destroy]
24
+ collection do
25
+ post :ordering, to: "participatory_process_step_ordering#create"
26
+ end
27
+ end
28
+ resources :user_roles, controller: "participatory_process_user_roles" do
29
+ member do
30
+ post :resend_invitation, to: "participatory_process_user_roles#resend_invitation"
31
+ end
32
+ end
33
+ resources :attachments, controller: "participatory_process_attachments"
34
+ end
35
+
36
+ scope "/participatory_processes/:participatory_process_id" do
37
+ resources :categories
38
+
39
+ resources :features do
40
+ resource :permissions, controller: "feature_permissions"
41
+ member do
42
+ put :publish
43
+ put :unpublish
44
+ end
45
+ resources :exports, only: :create
46
+ end
47
+
48
+ resources :moderations do
49
+ member do
50
+ put :unreport
51
+ put :hide
52
+ end
53
+ end
54
+ end
55
+
56
+ scope "/participatory_processes/:participatory_process_id/features/:feature_id/manage" do
57
+ Decidim.feature_manifests.each do |manifest|
58
+ next unless manifest.admin_engine
59
+
60
+ constraints CurrentFeature.new(manifest) do
61
+ mount manifest.admin_engine, at: "/", as: "decidim_admin_participatory_process_#{manifest.name}"
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ initializer "decidim_participatory_processes.admin_assets" do |app|
68
+ app.config.assets.precompile += %w(admin/decidim_participatory_processes_manifest.js)
69
+ end
70
+
71
+ initializer "decidim_participatory_processes.inject_abilities_to_user" do |_app|
72
+ Decidim.configure do |config|
73
+ config.admin_abilities += [
74
+ "Decidim::ParticipatoryProcesses::Abilities::Admin::AdminAbility"
75
+ ]
76
+ end
77
+ end
78
+
79
+ initializer "decidim_participatory_processes.admin_menu" do
80
+ Decidim.menu :admin_menu do |menu|
81
+ menu.item I18n.t("menu.participatory_processes", scope: "decidim.admin"),
82
+ decidim_admin_participatory_processes.participatory_processes_path,
83
+ icon_name: "target",
84
+ position: 2,
85
+ active: :inclusive,
86
+ if: can?(:manage, Decidim::ParticipatoryProcess)
87
+
88
+ menu.item I18n.t("menu.participatory_process_groups", scope: "decidim.admin"),
89
+ decidim_admin_participatory_processes.participatory_process_groups_path,
90
+ icon_name: "layers",
91
+ position: 3,
92
+ active: :inclusive,
93
+ if: can?(:read, Decidim::ParticipatoryProcessGroup)
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+ require "active_support/all"
5
+
6
+ require "decidim/core"
7
+
8
+ module Decidim
9
+ module ParticipatoryProcesses
10
+ # Decidim's Participatory Processes Rails Engine.
11
+ class Engine < ::Rails::Engine
12
+ isolate_namespace Decidim::ParticipatoryProcesses
13
+
14
+ routes do
15
+ resources :participatory_process_groups, only: :show, path: "processes_groups"
16
+ resources :participatory_processes, only: [:index, :show], path: "processes" do
17
+ resources :participatory_process_steps, only: [:index], path: "steps"
18
+ resource :participatory_process_widget, only: :show, path: "embed"
19
+ end
20
+
21
+ scope "/processes/:participatory_process_id/f/:feature_id" do
22
+ Decidim.feature_manifests.each do |manifest|
23
+ next unless manifest.engine
24
+
25
+ constraints CurrentFeature.new(manifest) do
26
+ mount manifest.engine, at: "/", as: "decidim_participatory_process_#{manifest.name}"
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ initializer "decidim_participatory_processes.assets" do |app|
33
+ app.config.assets.precompile += %w(decidim_participatory_processes_manifest.js)
34
+ end
35
+
36
+ initializer "decidim_participatory_processes.inject_abilities_to_user" do |_app|
37
+ Decidim.configure do |config|
38
+ config.abilities += [
39
+ "Decidim::ParticipatoryProcesses::Abilities::EveryoneAbility",
40
+ "Decidim::ParticipatoryProcesses::Abilities::AdminAbility"
41
+ ]
42
+ end
43
+ end
44
+
45
+ initializer "decidim_participatory_processes.menu" do
46
+ Decidim.menu :menu do |menu|
47
+ menu.item I18n.t("menu.processes", scope: "decidim"),
48
+ decidim_participatory_processes.participatory_processes_path,
49
+ position: 2,
50
+ active: :inclusive
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ Decidim.register_participatory_space(:participatory_processes) do |participatory_space|
4
+ participatory_space.engine = Decidim::ParticipatoryProcesses::Engine
5
+ participatory_space.admin_engine = Decidim::ParticipatoryProcesses::AdminEngine
6
+ participatory_space.icon = "decidim/participatory_processes/icon.svg"
7
+
8
+ participatory_space.seeds do
9
+ organization = Decidim::Organization.first
10
+ seeds_root = File.join(__dir__, "..", "..", "..", "db", "seeds")
11
+
12
+ process_groups = []
13
+ 3.times do
14
+ process_groups << Decidim::ParticipatoryProcessGroup.create!(
15
+ name: Decidim::Faker::Localized.sentence(3),
16
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
17
+ Decidim::Faker::Localized.paragraph(3)
18
+ end,
19
+ hero_image: File.new(File.join(seeds_root, "city.jpeg")),
20
+ organization: organization
21
+ )
22
+ end
23
+
24
+ 3.times do
25
+ Decidim::ParticipatoryProcess.create!(
26
+ title: Decidim::Faker::Localized.sentence(5),
27
+ slug: Faker::Internet.unique.slug(nil, "-"),
28
+ subtitle: Decidim::Faker::Localized.sentence(2),
29
+ hashtag: "##{Faker::Lorem.word}",
30
+ short_description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
31
+ Decidim::Faker::Localized.sentence(3)
32
+ end,
33
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
34
+ Decidim::Faker::Localized.paragraph(3)
35
+ end,
36
+ hero_image: File.new(File.join(seeds_root, "city.jpeg")),
37
+ banner_image: File.new(File.join(seeds_root, "city2.jpeg")),
38
+ promoted: true,
39
+ published_at: 2.weeks.ago,
40
+ organization: organization,
41
+ meta_scope: Decidim::Faker::Localized.word,
42
+ developer_group: Decidim::Faker::Localized.sentence(1),
43
+ local_area: Decidim::Faker::Localized.sentence(2),
44
+ target: Decidim::Faker::Localized.sentence(3),
45
+ participatory_scope: Decidim::Faker::Localized.sentence(1),
46
+ participatory_structure: Decidim::Faker::Localized.sentence(2),
47
+ start_date: Time.current,
48
+ end_date: 2.month.from_now.at_midnight,
49
+ participatory_process_group: process_groups.sample,
50
+ scope: Faker::Boolean.boolean(0.5) ? nil : Decidim::Scope.reorder("RANDOM()").first
51
+ )
52
+ end
53
+
54
+ Decidim::ParticipatoryProcess.find_each do |process|
55
+ Decidim::ParticipatoryProcessStep.find_or_initialize_by(
56
+ participatory_process: process,
57
+ active: true
58
+ ).update!(
59
+ title: Decidim::Faker::Localized.sentence(1, false, 2),
60
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
61
+ Decidim::Faker::Localized.paragraph(3)
62
+ end,
63
+ start_date: 1.month.ago.at_midnight,
64
+ end_date: 2.months.from_now.at_midnight
65
+ )
66
+
67
+ # Create users with specific roles
68
+ Decidim::ParticipatoryProcessUserRole::ROLES.each do |role|
69
+ email = "participatory_process_#{process.id}_#{role}@example.org"
70
+
71
+ user = Decidim::User.find_or_initialize_by(email: email)
72
+ user.update!(
73
+ name: Faker::Name.name,
74
+ password: "decidim123456",
75
+ password_confirmation: "decidim123456",
76
+ organization: organization,
77
+ confirmed_at: Time.current,
78
+ locale: I18n.default_locale,
79
+ tos_agreement: true
80
+ )
81
+
82
+ Decidim::ParticipatoryProcessUserRole.find_or_create_by!(
83
+ user: user,
84
+ participatory_process: process,
85
+ role: role
86
+ )
87
+ end
88
+
89
+ Decidim::Attachment.create!(
90
+ title: Decidim::Faker::Localized.sentence(2),
91
+ description: Decidim::Faker::Localized.sentence(5),
92
+ file: File.new(File.join(seeds_root, "city.jpeg")),
93
+ attached_to: process
94
+ )
95
+
96
+ Decidim::Attachment.create!(
97
+ title: Decidim::Faker::Localized.sentence(2),
98
+ description: Decidim::Faker::Localized.sentence(5),
99
+ file: File.new(File.join(seeds_root, "Exampledocument.pdf")),
100
+ attached_to: process
101
+ )
102
+
103
+ 2.times do
104
+ Decidim::Category.create!(
105
+ name: Decidim::Faker::Localized.sentence(5),
106
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
107
+ Decidim::Faker::Localized.paragraph(3)
108
+ end,
109
+ participatory_space: process
110
+ )
111
+ end
112
+
113
+ Decidim.feature_manifests.each do |manifest|
114
+ manifest.seed!(process.reload)
115
+ end
116
+ end
117
+ end
118
+ end