decidim-challenges 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (231) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-AGPLv3.txt +661 -0
  3. data/README.md +49 -0
  4. data/Rakefile +9 -0
  5. data/app/cells/decidim/challenges/challenge_cell.rb +21 -0
  6. data/app/cells/decidim/challenges/challenge_g/show.erb +47 -0
  7. data/app/cells/decidim/challenges/challenge_g_cell.rb +69 -0
  8. data/app/cells/decidim/problems/problem_cell.rb +21 -0
  9. data/app/cells/decidim/problems/problem_g/show.erb +35 -0
  10. data/app/cells/decidim/problems/problem_g_cell.rb +61 -0
  11. data/app/cells/decidim/solutions/solution_cell.rb +21 -0
  12. data/app/cells/decidim/solutions/solution_g/show.erb +30 -0
  13. data/app/cells/decidim/solutions/solution_g_cell.rb +84 -0
  14. data/app/commands/decidim/challenges/admin/create_challenge.rb +67 -0
  15. data/app/commands/decidim/challenges/admin/destroy_challenge.rb +49 -0
  16. data/app/commands/decidim/challenges/admin/export_challenge_surveys.rb +45 -0
  17. data/app/commands/decidim/challenges/admin/publish_challenge.rb +40 -0
  18. data/app/commands/decidim/challenges/admin/unpublish_challenge.rb +40 -0
  19. data/app/commands/decidim/challenges/admin/update_challenge.rb +72 -0
  20. data/app/commands/decidim/challenges/admin/update_surveys.rb +43 -0
  21. data/app/commands/decidim/challenges/survey_challenge.rb +67 -0
  22. data/app/commands/decidim/command_utils.rb +20 -0
  23. data/app/commands/decidim/problems/admin/create_problem.rb +66 -0
  24. data/app/commands/decidim/problems/admin/destroy_problem.rb +49 -0
  25. data/app/commands/decidim/problems/admin/publish_problem.rb +40 -0
  26. data/app/commands/decidim/problems/admin/unpublish_problem.rb +40 -0
  27. data/app/commands/decidim/problems/admin/update_problem.rb +69 -0
  28. data/app/commands/decidim/solutions/admin/create_solution.rb +65 -0
  29. data/app/commands/decidim/solutions/admin/destroy_solution.rb +43 -0
  30. data/app/commands/decidim/solutions/admin/publish_solution.rb +40 -0
  31. data/app/commands/decidim/solutions/admin/unpublish_solution.rb +40 -0
  32. data/app/commands/decidim/solutions/admin/update_solution.rb +67 -0
  33. data/app/commands/decidim/solutions/create_solution.rb +67 -0
  34. data/app/controllers/concerns/decidim/challenges/admin/filterable.rb +27 -0
  35. data/app/controllers/concerns/decidim/challenges/orderable_challenges.rb +37 -0
  36. data/app/controllers/concerns/decidim/problems/admin/filterable.rb +27 -0
  37. data/app/controllers/concerns/decidim/problems/orderable_problems.rb +37 -0
  38. data/app/controllers/concerns/decidim/solutions/admin/filterable.rb +27 -0
  39. data/app/controllers/concerns/decidim/solutions/orderable_solutions.rb +37 -0
  40. data/app/controllers/concerns/decidim/with_default_filters.rb +23 -0
  41. data/app/controllers/concerns/decidim/with_sdgs.rb +19 -0
  42. data/app/controllers/decidim/challenges/admin/application_controller.rb +15 -0
  43. data/app/controllers/decidim/challenges/admin/challenge_publications_controller.rb +53 -0
  44. data/app/controllers/decidim/challenges/admin/challenges_controller.rb +108 -0
  45. data/app/controllers/decidim/challenges/admin/survey_form_controller.rb +43 -0
  46. data/app/controllers/decidim/challenges/admin/surveys_controller.rb +104 -0
  47. data/app/controllers/decidim/challenges/application_controller.rb +13 -0
  48. data/app/controllers/decidim/challenges/challenges_controller.rb +70 -0
  49. data/app/controllers/decidim/challenges/surveys_controller.rb +61 -0
  50. data/app/controllers/decidim/problems/admin/application_controller.rb +15 -0
  51. data/app/controllers/decidim/problems/admin/problem_publications_controller.rb +53 -0
  52. data/app/controllers/decidim/problems/admin/problems_controller.rb +102 -0
  53. data/app/controllers/decidim/problems/application_controller.rb +13 -0
  54. data/app/controllers/decidim/problems/problems_controller.rb +62 -0
  55. data/app/controllers/decidim/sdgs/admin/application_controller.rb +15 -0
  56. data/app/controllers/decidim/sdgs/admin/sdgs_controller.rb +18 -0
  57. data/app/controllers/decidim/sdgs/application_controller.rb +13 -0
  58. data/app/controllers/decidim/sdgs/sdgs_controller.rb +24 -0
  59. data/app/controllers/decidim/solutions/admin/application_controller.rb +15 -0
  60. data/app/controllers/decidim/solutions/admin/solution_publications_controller.rb +53 -0
  61. data/app/controllers/decidim/solutions/admin/solutions_controller.rb +106 -0
  62. data/app/controllers/decidim/solutions/application_controller.rb +13 -0
  63. data/app/controllers/decidim/solutions/solutions_controller.rb +115 -0
  64. data/app/forms/decidim/challenges/admin/challenge_surveys_form.rb +35 -0
  65. data/app/forms/decidim/challenges/admin/challenges_form.rb +78 -0
  66. data/app/forms/decidim/problems/admin/problems_form.rb +90 -0
  67. data/app/forms/decidim/solutions/admin/solutions_form.rb +71 -0
  68. data/app/forms/decidim/solutions/solutions_form.rb +50 -0
  69. data/app/helpers/decidim/challenges/application_helper.rb +25 -0
  70. data/app/helpers/decidim/challenges/challenge_cells_helper.rb +57 -0
  71. data/app/helpers/decidim/challenges/challenges_helper.rb +39 -0
  72. data/app/helpers/decidim/problems/application_helper.rb +10 -0
  73. data/app/helpers/decidim/problems/problem_cells_helper.rb +23 -0
  74. data/app/helpers/decidim/problems/problems_helper.rb +24 -0
  75. data/app/helpers/decidim/sdgs/sdgs_helper.rb +28 -0
  76. data/app/helpers/decidim/show_filters_helper.rb +13 -0
  77. data/app/helpers/decidim/solutions/application_helper.rb +27 -0
  78. data/app/helpers/decidim/solutions/solution_cells_helper.rb +56 -0
  79. data/app/helpers/decidim/solutions/solutions_helper.rb +21 -0
  80. data/app/models/decidim/application_record.rb +8 -0
  81. data/app/models/decidim/challenges/challenge.rb +82 -0
  82. data/app/models/decidim/challenges/survey.rb +19 -0
  83. data/app/models/decidim/problems/problem.rb +118 -0
  84. data/app/models/decidim/sdgs/sdg.rb +47 -0
  85. data/app/models/decidim/solutions/application_record.rb +10 -0
  86. data/app/models/decidim/solutions/solution.rb +69 -0
  87. data/app/packs/entrypoints/decidim_challenges.js +4 -0
  88. data/app/packs/entrypoints/decidim_challenges.scss +1 -0
  89. data/app/packs/entrypoints/decidim_problems.js +1 -0
  90. data/app/packs/entrypoints/decidim_problems.scss +1 -0
  91. data/app/packs/entrypoints/decidim_sdgs.js +6 -0
  92. data/app/packs/entrypoints/decidim_sdgs.scss +3 -0
  93. data/app/packs/entrypoints/decidim_shared.js +1 -0
  94. data/app/packs/entrypoints/decidim_shared.scss +1 -0
  95. data/app/packs/entrypoints/decidim_solutions.js +4 -0
  96. data/app/packs/entrypoints/decidim_solutions.scss +1 -0
  97. data/app/packs/fonts/Oswald-Medium.ttf +0 -0
  98. data/app/packs/images/decidim/challenges/decidim_challenges_icon.svg +1 -0
  99. data/app/packs/images/decidim/sdgs/ods-01.svg +11 -0
  100. data/app/packs/images/decidim/sdgs/ods-02.svg +11 -0
  101. data/app/packs/images/decidim/sdgs/ods-03.svg +11 -0
  102. data/app/packs/images/decidim/sdgs/ods-04.svg +12 -0
  103. data/app/packs/images/decidim/sdgs/ods-05.svg +12 -0
  104. data/app/packs/images/decidim/sdgs/ods-06.svg +20 -0
  105. data/app/packs/images/decidim/sdgs/ods-07.svg +18 -0
  106. data/app/packs/images/decidim/sdgs/ods-08.svg +13 -0
  107. data/app/packs/images/decidim/sdgs/ods-09.svg +25 -0
  108. data/app/packs/images/decidim/sdgs/ods-10.svg +13 -0
  109. data/app/packs/images/decidim/sdgs/ods-11.svg +41 -0
  110. data/app/packs/images/decidim/sdgs/ods-12.svg +11 -0
  111. data/app/packs/images/decidim/sdgs/ods-13.svg +57 -0
  112. data/app/packs/images/decidim/sdgs/ods-14.svg +14 -0
  113. data/app/packs/images/decidim/sdgs/ods-15.svg +11 -0
  114. data/app/packs/images/decidim/sdgs/ods-16.svg +14 -0
  115. data/app/packs/images/decidim/sdgs/ods-17.svg +39 -0
  116. data/app/packs/images/decidim/sdgs/sdg-wheel.png +0 -0
  117. data/app/packs/images/decidim/sdgs/un_emblem_square.png +0 -0
  118. data/app/packs/src/decidim/challenges/add_challenge.js +3 -0
  119. data/app/packs/src/decidim/challenges/admin/challenges_form.js +3 -0
  120. data/app/packs/src/decidim/sdgs/filter.js +75 -0
  121. data/app/packs/stylesheets/decidim/challenges/challenges.scss +3 -0
  122. data/app/packs/stylesheets/decidim/problems/problems.scss +3 -0
  123. data/app/packs/stylesheets/decidim/sdgs/ods.scss +185 -0
  124. data/app/packs/stylesheets/decidim/sdgs/sdgs_filter/button.scss +27 -0
  125. data/app/packs/stylesheets/decidim/sdgs/sdgs_filter/modal.scss +60 -0
  126. data/app/packs/stylesheets/decidim/shared/_cards.scss +52 -0
  127. data/app/packs/stylesheets/decidim/shared/base.scss +9 -0
  128. data/app/packs/stylesheets/decidim/solutions/solutions.scss +3 -0
  129. data/app/permissions/decidim/challenges/admin/permissions.rb +88 -0
  130. data/app/permissions/decidim/challenges/permissions.rb +27 -0
  131. data/app/permissions/decidim/problems/admin/permissions.rb +52 -0
  132. data/app/permissions/decidim/problems/permissions.rb +16 -0
  133. data/app/permissions/decidim/solutions/admin/permissions.rb +58 -0
  134. data/app/permissions/decidim/solutions/permissions.rb +17 -0
  135. data/app/presenters/decidim/challenges/challenge_presenter.rb +134 -0
  136. data/app/presenters/decidim/problems/problem_presenter.rb +108 -0
  137. data/app/presenters/decidim/solutions/solution_presenter.rb +198 -0
  138. data/app/serializers/decidim/challenges/data_serializer.rb +46 -0
  139. data/app/serializers/decidim/challenges/survey_serializer.rb +37 -0
  140. data/app/types/decidim/challenges/challenge_type.rb +28 -0
  141. data/app/types/decidim/challenges/challenges_type.rb +32 -0
  142. data/app/types/decidim/problems/problem_type.rb +29 -0
  143. data/app/types/decidim/problems/problems_type.rb +32 -0
  144. data/app/types/decidim/solutions/solution_type.rb +25 -0
  145. data/app/types/decidim/solutions/solutions_type.rb +32 -0
  146. data/app/views/decidim/challenges/admin/challenges/_form.html.erb +78 -0
  147. data/app/views/decidim/challenges/admin/challenges/edit.html.erb +24 -0
  148. data/app/views/decidim/challenges/admin/challenges/index.html.erb +88 -0
  149. data/app/views/decidim/challenges/admin/challenges/new.html.erb +18 -0
  150. data/app/views/decidim/challenges/admin/surveys/_form.html.erb +9 -0
  151. data/app/views/decidim/challenges/admin/surveys/edit.html.erb +39 -0
  152. data/app/views/decidim/challenges/admin/surveys/index.html.erb +49 -0
  153. data/app/views/decidim/challenges/admin/surveys/show.html.erb +43 -0
  154. data/app/views/decidim/challenges/challenges/_challenge.html.erb +1 -0
  155. data/app/views/decidim/challenges/challenges/_challenges.html.erb +11 -0
  156. data/app/views/decidim/challenges/challenges/_related_problems.html.erb +14 -0
  157. data/app/views/decidim/challenges/challenges/_sidebar_data.html.erb +60 -0
  158. data/app/views/decidim/challenges/challenges/index.html.erb +29 -0
  159. data/app/views/decidim/challenges/challenges/index.js.erb +5 -0
  160. data/app/views/decidim/challenges/challenges/show.html.erb +41 -0
  161. data/app/views/decidim/problems/admin/problems/_form.html.erb +79 -0
  162. data/app/views/decidim/problems/admin/problems/edit.html.erb +24 -0
  163. data/app/views/decidim/problems/admin/problems/index.html.erb +93 -0
  164. data/app/views/decidim/problems/admin/problems/new.html.erb +18 -0
  165. data/app/views/decidim/problems/problems/_problem.html.erb +1 -0
  166. data/app/views/decidim/problems/problems/_problems.html.erb +11 -0
  167. data/app/views/decidim/problems/problems/_sidebar_data.html.erb +70 -0
  168. data/app/views/decidim/problems/problems/index.html.erb +28 -0
  169. data/app/views/decidim/problems/problems/index.js.erb +5 -0
  170. data/app/views/decidim/problems/problems/show.html.erb +38 -0
  171. data/app/views/decidim/sdgs/sdgs/_objectives.html.erb +320 -0
  172. data/app/views/decidim/sdgs/sdgs/_ods.html.erb +132 -0
  173. data/app/views/decidim/sdgs/sdgs/index.html.erb +64 -0
  174. data/app/views/decidim/sdgs/sdgs_filter/_filter_selector.html.erb +7 -0
  175. data/app/views/decidim/sdgs/sdgs_filter/_modal.html.erb +35 -0
  176. data/app/views/decidim/shared/_related_solutions.html.erb +14 -0
  177. data/app/views/decidim/solutions/admin/solutions/_documents.html.erb +13 -0
  178. data/app/views/decidim/solutions/admin/solutions/_form.html.erb +70 -0
  179. data/app/views/decidim/solutions/admin/solutions/_photos.html.erb +13 -0
  180. data/app/views/decidim/solutions/admin/solutions/edit.html.erb +24 -0
  181. data/app/views/decidim/solutions/admin/solutions/index.html.erb +97 -0
  182. data/app/views/decidim/solutions/admin/solutions/new.html.erb +18 -0
  183. data/app/views/decidim/solutions/admin/solutions/show.html.erb +114 -0
  184. data/app/views/decidim/solutions/solutions/_form.html.erb +22 -0
  185. data/app/views/decidim/solutions/solutions/_sidebar_data.html.erb +114 -0
  186. data/app/views/decidim/solutions/solutions/_solution.html.erb +1 -0
  187. data/app/views/decidim/solutions/solutions/_solutions.html.erb +13 -0
  188. data/app/views/decidim/solutions/solutions/index.html.erb +37 -0
  189. data/app/views/decidim/solutions/solutions/index.js.erb +5 -0
  190. data/app/views/decidim/solutions/solutions/new.html.erb +20 -0
  191. data/app/views/decidim/solutions/solutions/show.html.erb +72 -0
  192. data/config/assets.rb +27 -0
  193. data/config/i18n-tasks.yml +10 -0
  194. data/config/locales/ca.yml +1244 -0
  195. data/config/locales/cs.yml +668 -0
  196. data/config/locales/en.yml +1245 -0
  197. data/config/locales/es.yml +1250 -0
  198. data/config/locales/oc.yml +1229 -0
  199. data/db/migrate/20201014125000_create_decidim_challenges_challenges.rb +23 -0
  200. data/db/migrate/20201103155100_create_decidim_problems_problems.rb +25 -0
  201. data/db/migrate/20201116111200_create_decidim_solutions_solutions.rb +21 -0
  202. data/db/migrate/20210413083244_create_decidim_challenges_surveys.rb +14 -0
  203. data/db/migrate/20210413083507_add_survey_attributes_to_challenges.rb +7 -0
  204. data/db/migrate/20210413083604_add_questionnaire_to_existing_challenges.rb +15 -0
  205. data/db/migrate/20210413112229_add_challenge_reference_to_solutions.rb +7 -0
  206. data/db/migrate/20210427091033_remove_require_null_in_problems_for_solutions.rb +7 -0
  207. data/db/migrate/20220407110503_add_card_image_to_challenges.rb +7 -0
  208. data/db/migrate/20240919094714_add_public_fields_to_solutions.rb +10 -0
  209. data/lib/decidim/challenges/admin.rb +10 -0
  210. data/lib/decidim/challenges/admin_engine.rb +37 -0
  211. data/lib/decidim/challenges/component.rb +65 -0
  212. data/lib/decidim/challenges/engine.rb +39 -0
  213. data/lib/decidim/challenges/test/factories.rb +59 -0
  214. data/lib/decidim/challenges/version.rb +14 -0
  215. data/lib/decidim/challenges.rb +13 -0
  216. data/lib/decidim/problems/admin.rb +10 -0
  217. data/lib/decidim/problems/admin_engine.rb +25 -0
  218. data/lib/decidim/problems/component.rb +51 -0
  219. data/lib/decidim/problems/engine.rb +31 -0
  220. data/lib/decidim/problems/test/factories.rb +39 -0
  221. data/lib/decidim/sdgs/admin.rb +10 -0
  222. data/lib/decidim/sdgs/admin_engine.rb +28 -0
  223. data/lib/decidim/sdgs/component.rb +44 -0
  224. data/lib/decidim/sdgs/engine.rb +23 -0
  225. data/lib/decidim/sdgs/test/factories.rb +13 -0
  226. data/lib/decidim/solutions/admin.rb +10 -0
  227. data/lib/decidim/solutions/admin_engine.rb +25 -0
  228. data/lib/decidim/solutions/component.rb +52 -0
  229. data/lib/decidim/solutions/engine.rb +31 -0
  230. data/lib/decidim/solutions/test/factories.rb +28 -0
  231. metadata +316 -0
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimChallengesChallenges < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :decidim_challenges_challenges do |t|
6
+ t.jsonb :title
7
+ t.jsonb :local_description
8
+ t.jsonb :global_description
9
+ t.references :decidim_component, index: true, null: false
10
+ t.jsonb :tags
11
+ t.string :sdg_code
12
+ t.references :decidim_scope, index: true
13
+ t.integer :state, null: false, default: 0
14
+ t.date :start_date
15
+ t.date :end_date
16
+ t.timestamp :published_at
17
+ t.string :coordinating_entities
18
+ t.string :collaborating_entities
19
+
20
+ t.timestamps
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimProblemsProblems < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :decidim_problems_problems do |t|
6
+ t.jsonb :title
7
+ t.jsonb :description
8
+ t.references :decidim_component, index: true, null: false
9
+ t.references :decidim_challenges_challenge, index: { name: "decidim_challenges_challenges_problems" }, null: false
10
+ t.bigint "decidim_sectorial_scope_id"
11
+ t.bigint "decidim_technological_scope_id"
12
+ t.jsonb :tags
13
+ t.string :causes
14
+ t.string :groups_affected
15
+ t.integer :state, null: false, default: 0
16
+ t.date :start_date
17
+ t.date :end_date
18
+ t.timestamp :published_at
19
+ t.string :proposing_entities
20
+ t.string :collaborating_entities
21
+
22
+ t.timestamps
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimSolutionsSolutions < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :decidim_solutions_solutions do |t|
6
+ t.jsonb :title
7
+ t.jsonb :description
8
+ t.references :decidim_component, index: true, null: false
9
+ t.references :decidim_problems_problem, index: { name: "decidim_challenges_problems_solutions" }, null: false
10
+ t.jsonb :tags
11
+ t.jsonb :indicators
12
+ t.jsonb :beneficiaries
13
+ t.jsonb :requirements
14
+ t.jsonb :financing_type
15
+ t.jsonb :objectives
16
+ t.timestamp :published_at
17
+
18
+ t.timestamps
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimChallengesSurveys < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :decidim_challenges_surveys do |t|
6
+ t.references :decidim_user, null: false, index: true
7
+ t.references :decidim_challenge, null: false, index: true
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :decidim_challenges_surveys, [:decidim_user_id, :decidim_challenge_id], unique: true, name: "decidim_challenges_surveys_user_challenge_unique"
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddSurveyAttributesToChallenges < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :decidim_challenges_challenges, :survey_enabled, :boolean, null: false, default: false
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddQuestionnaireToExistingChallenges < ActiveRecord::Migration[5.2]
4
+ def change
5
+ Decidim::Challenges::Challenge.transaction do
6
+ Decidim::Challenges::Challenge.find_each do |challenge|
7
+ if challenge.component.present? && challenge.questionnaire.blank?
8
+ challenge.update!(
9
+ questionnaire: Decidim::Forms::Questionnaire.new
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddChallengeReferenceToSolutions < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_reference :decidim_solutions_solutions, :decidim_challenges_challenge, index: { name: "decidim_challenges_solutions" }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RemoveRequireNullInProblemsForSolutions < ActiveRecord::Migration[5.2]
4
+ def change
5
+ change_column_null :decidim_solutions_solutions, :decidim_problems_problem_id, true
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddCardImageToChallenges < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :decidim_challenges_challenges, :card_image, :string
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddPublicFieldsToSolutions < ActiveRecord::Migration[6.1]
4
+ def change
5
+ add_column :decidim_solutions_solutions, :project_status, :string
6
+ add_column :decidim_solutions_solutions, :project_url, :string
7
+ add_column :decidim_solutions_solutions, :coordinating_entity, :string
8
+ add_reference :decidim_solutions_solutions, :author, foreign_key: { to_table: :decidim_users }, index: true
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Challenges
5
+ # This module contains all the domain logic associated to Decidim's Challenges
6
+ # component admin panel.
7
+ module Admin
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Challenges
5
+ # This is the engine that runs on the public interface of `Challenges`.
6
+ class AdminEngine < ::Rails::Engine
7
+ isolate_namespace Decidim::Challenges::Admin
8
+
9
+ paths["db/migrate"] = nil
10
+ paths["lib/tasks"] = nil
11
+
12
+ # Add admin engine routes here
13
+ routes do
14
+ get "/answer_options", to: "challenge_survey#answer_options", as: :answer_options_challenge_survey, defaults: { format: "json" }
15
+
16
+ resources :challenges do
17
+ resource :publish, controller: "challenge_publications", only: [:create, :destroy]
18
+
19
+ resource :surveys, only: [:edit, :update] do
20
+ resource :form, only: [:edit, :update], controller: "survey_form"
21
+ collection do
22
+ get :index_answers, action: :index
23
+ get :show_answers, action: :show
24
+ get :export_response, action: :export_response
25
+ get :export
26
+ end
27
+ end
28
+ end
29
+ root to: "challenges#index"
30
+ end
31
+
32
+ def load_seed
33
+ nil
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "decidim/components/namer"
4
+ require "decidim/challenges/admin"
5
+ require "decidim/challenges/engine"
6
+ require "decidim/challenges/admin_engine"
7
+
8
+ # Sustainable Development Goals
9
+ Decidim.register_component(:challenges) do |component|
10
+ component.engine = Decidim::Challenges::Engine
11
+ component.stylesheet = "decidim/challenges/challenges"
12
+ component.admin_engine = Decidim::Challenges::AdminEngine
13
+ component.icon = "media/images/decidim_challenges_icon.svg"
14
+
15
+ component.data_portable_entities = ["Decidim::Challenges::Survey"]
16
+
17
+ # component.on(:before_destroy) do |instance|
18
+ # # Code executed before removing the component
19
+ # end
20
+
21
+ component.permissions_class_name = "Decidim::Challenges::Permissions"
22
+
23
+ # These actions permissions can be configured in the admin panel
24
+ # component.actions = %w()
25
+
26
+ component.query_type = "Decidim::Challenges::ChallengesType"
27
+
28
+ component.settings(:global) do |settings|
29
+ # Available types: :integer, :boolean
30
+ settings.attribute :announcement, type: :text, translated: true, editor: true
31
+ settings.attribute :hide_filters, type: :boolean, default: false
32
+ settings.attribute :allow_card_image, type: :boolean, default: false
33
+ end
34
+
35
+ component.settings(:step) do |settings|
36
+ settings.attribute :announcement, type: :text, translated: true, editor: true
37
+ end
38
+
39
+ component.register_resource(:challenge) do |resource|
40
+ # Register a optional resource that can be references from other resources.
41
+ resource.model_class_name = "Decidim::Challenges::Challenge"
42
+ resource.card = "decidim/challenges/challenge"
43
+ # resource.template = "decidim/challenges/some_resources/linked_some_resources"
44
+ resource.searchable = true
45
+ end
46
+
47
+ # component.register_stat :some_stat do |context, start_at, end_at|
48
+ # # Register some stat number to the application
49
+ # end
50
+
51
+ component.seeds do |participatory_space|
52
+ # Add some seeds for this component
53
+ end
54
+
55
+ component.exports :answers do |exports|
56
+ exports.collection do |_f, _user, resource_id|
57
+ questionnaire = Decidim::Forms::Questionnaire.find(resource_id)
58
+ Decidim::Forms::QuestionnaireUserAnswers.for(questionnaire)
59
+ end
60
+
61
+ exports.formats %w(CSV JSON Excel FormPDF)
62
+
63
+ exports.serializer Decidim::Forms::UserAnswersSerializer
64
+ end
65
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+ require "decidim/core"
5
+ require "wicked_pdf"
6
+
7
+ module Decidim
8
+ module Challenges
9
+ # This is the engine that runs on the public interface of challenges.
10
+ class Engine < ::Rails::Engine
11
+ isolate_namespace Decidim::Challenges
12
+
13
+ routes do
14
+ # Add engine routes here
15
+ resources :challenges do
16
+ get :data_picker_modal_content, on: :collection
17
+ end
18
+ root to: "challenges#index"
19
+ resources :challenges, only: [:index, :show] do
20
+ resource :survey, only: [:create, :destroy] do
21
+ collection do
22
+ get :answer, action: :show
23
+ post :answer
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ initializer "decidim_challenges.add_cells_view_paths" do
30
+ Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Challenges::Engine.root}/app/cells")
31
+ Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Challenges::Engine.root}/app/views") # for partials
32
+ end
33
+
34
+ initializer "decidim_challenges.webpacker.assets_path" do
35
+ Decidim.register_assets_path File.expand_path("app/packs", root)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/core/test/factories"
4
+
5
+ FactoryBot.define do
6
+ factory :challenges_component, parent: :component do
7
+ name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :challenges).i18n_name }
8
+ manifest_name { :challenges }
9
+ participatory_space { association(:participatory_process, :with_steps) }
10
+
11
+ trait :with_card_image_allowed do
12
+ settings do
13
+ {
14
+ allow_card_image: true,
15
+ }
16
+ end
17
+ end
18
+ end
19
+
20
+ factory :challenge, traits: [:proposal, :execution, :finished], class: "Decidim::Challenges::Challenge" do
21
+ title { generate_localized_title }
22
+ local_description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
23
+ global_description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
24
+ tags { Decidim::Faker::Localized.localized { [1..5].collect { generate(:name) }.join(", ") } }
25
+ state { "execution" }
26
+ start_date { 1.day.from_now }
27
+ end_date { start_date + 2.months }
28
+ component { association(:challenges_component) }
29
+ coordinating_entities { [1..5].collect { generate(:name) }.join(", ") }
30
+ collaborating_entities { [1..5].collect { generate(:name) }.join(", ") }
31
+ published_at { Time.current }
32
+ questionnaire { association(:questionnaire) }
33
+
34
+ trait :proposal do
35
+ state { 0 }
36
+ end
37
+
38
+ trait :execution do
39
+ state { 1 }
40
+ end
41
+
42
+ trait :finished do
43
+ state { 2 }
44
+ end
45
+
46
+ trait :with_survey_enabled do
47
+ survey_enabled { true }
48
+ end
49
+
50
+ trait :with_card_image do
51
+ card_image { Decidim::Dev.test_file("city.jpeg", "image/jpeg") }
52
+ end
53
+ end
54
+
55
+ factory :survey, class: "Decidim::Challenges::Survey" do
56
+ challenge
57
+ user
58
+ end
59
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This holds the decidim-meetings version.
5
+ module Challenges
6
+ def self.version
7
+ "0.5.0"
8
+ end
9
+
10
+ def self.decidim_version
11
+ "~> 0.27"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/challenges/component"
4
+ require "decidim/problems/component"
5
+ require "decidim/sdgs/component"
6
+ require "decidim/solutions/component"
7
+
8
+ module Decidim
9
+ # This namespace holds the logic of the `Challenges` component. This component
10
+ # allows users to create challenges in a participatory space.
11
+ module Challenges
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Problems
5
+ # This module contains all the domain logic associated to Decidim's Problems
6
+ # component admin panel.
7
+ module Admin
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Problems
5
+ # This is the engine that runs on the public interface of `Problems`.
6
+ class AdminEngine < ::Rails::Engine
7
+ isolate_namespace Decidim::Problems::Admin
8
+
9
+ paths["db/migrate"] = nil
10
+ paths["lib/tasks"] = nil
11
+
12
+ # Add admin engine routes here
13
+ routes do
14
+ resources :problems do
15
+ resource :publish, controller: "problem_publications", only: [:create, :destroy]
16
+ end
17
+ root to: "problems#index"
18
+ end
19
+
20
+ def load_seed
21
+ nil
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "decidim/components/namer"
4
+ require "decidim/problems/admin"
5
+ require "decidim/problems/engine"
6
+ require "decidim/problems/admin_engine"
7
+
8
+ # Sustainable Development Goals
9
+ Decidim.register_component(:problems) do |component|
10
+ component.engine = Decidim::Problems::Engine
11
+ component.stylesheet = "decidim/problems/problems"
12
+ component.admin_engine = Decidim::Problems::AdminEngine
13
+ component.icon = "media/images/decidim_challenges_icon.svg"
14
+
15
+ # component.on(:before_destroy) do |instance|
16
+ # # Code executed before removing the component
17
+ # end
18
+
19
+ component.permissions_class_name = "Decidim::Problems::Permissions"
20
+
21
+ # These actions permissions can be configured in the admin panel
22
+ # component.actions = %w()
23
+
24
+ component.query_type = "Decidim::Problems::ProblemsType"
25
+
26
+ component.settings(:global) do |settings|
27
+ # Add your global settings
28
+ # Available types: :integer, :boolean
29
+ settings.attribute :hide_filters, type: :boolean, default: false
30
+ end
31
+
32
+ # component.settings(:step) do |settings|
33
+ # # Add your settings per step
34
+ # end
35
+
36
+ component.register_resource(:problem) do |resource|
37
+ # Register a optional resource that can be references from other resources.
38
+ resource.model_class_name = "Decidim::Problems::Problem"
39
+ resource.card = "decidim/problems/problem"
40
+ # resource.template = "decidim/problems/some_resources/linked_some_resources"
41
+ resource.searchable = true
42
+ end
43
+
44
+ # component.register_stat :some_stat do |context, start_at, end_at|
45
+ # # Register some stat number to the application
46
+ # end
47
+
48
+ # component.seeds do |participatory_space|
49
+ # # Add some seeds for this component
50
+ # end
51
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+ require "decidim/core"
5
+
6
+ module Decidim
7
+ module Problems
8
+ # This is the engine that runs on the public interface of problems.
9
+ class Engine < ::Rails::Engine
10
+ isolate_namespace Decidim::Problems
11
+
12
+ routes do
13
+ # Add engine routes here
14
+ resources :problems do
15
+ get :data_picker_modal_content, on: :collection
16
+ end
17
+ root to: "problems#index"
18
+ resources :problems, only: [:index, :show]
19
+ end
20
+
21
+ initializer "decidim_problems.add_cells_view_paths" do
22
+ Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Problems::Engine.root}/app/cells")
23
+ Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Problems::Engine.root}/app/views") # for partials
24
+ end
25
+
26
+ initializer "decidim_problems.webpacker.assets_path" do
27
+ Decidim.register_assets_path File.expand_path("app/packs", root)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/core/test/factories"
4
+
5
+ FactoryBot.define do
6
+ factory :problems_component, parent: :component do
7
+ name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :problems).i18n_name }
8
+ manifest_name { :problems }
9
+ participatory_space { association(:participatory_process, :with_steps) }
10
+ end
11
+
12
+ factory :problem, traits: [:proposal, :execution, :finished], class: "Decidim::Problems::Problem" do
13
+ title { generate_localized_title }
14
+ description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
15
+ tags { Decidim::Faker::Localized.localized { [1..5].collect { generate(:name) }.join(", ") } }
16
+ state { "execution" }
17
+ causes { "causes" }
18
+ groups_affected { "groups affected" }
19
+ start_date { 1.day.from_now }
20
+ end_date { start_date + 2.months }
21
+ component { association(:component, manifest_name: "problems") }
22
+ challenge { association(:challenge) }
23
+ proposing_entities { [1..5].collect { generate(:name) }.join(", ") }
24
+ collaborating_entities { [1..5].collect { generate(:name) }.join(", ") }
25
+ published_at { Time.current }
26
+
27
+ trait :proposal do
28
+ state { 0 }
29
+ end
30
+
31
+ trait :execution do
32
+ state { 1 }
33
+ end
34
+
35
+ trait :finished do
36
+ state { 2 }
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Sdgs
5
+ # This module contains all the domain logic associated to Decidim's Challenges
6
+ # component admin panel.
7
+ module Admin
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Sdgs
5
+ # This is the engine that runs on the public interface of `Challenges`.
6
+ class AdminEngine < ::Rails::Engine
7
+ isolate_namespace Decidim::Sdgs::Admin
8
+
9
+ paths["db/migrate"] = nil
10
+ paths["lib/tasks"] = nil
11
+
12
+ routes do
13
+ # Add admin engine routes here
14
+ resources :sdgs, only: :index
15
+ # resources :sdgs do
16
+ # collection do
17
+ # resources :exports, only: [:create]
18
+ # end
19
+ # end
20
+ root to: "sdgs#index"
21
+ end
22
+
23
+ def load_seed
24
+ nil
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "decidim/components/namer"
4
+
5
+ require "decidim/sdgs/admin"
6
+ require "decidim/sdgs/engine"
7
+ require "decidim/sdgs/admin_engine"
8
+
9
+ Decidim.register_component(:sdgs) do |component|
10
+ component.engine = Decidim::Sdgs::Engine
11
+ component.admin_engine = Decidim::Sdgs::AdminEngine
12
+ component.icon = "media/images/decidim_challenges_icon.svg"
13
+
14
+ # component.on(:before_destroy) do |instance|
15
+ # # Code executed before removing the component
16
+ # end
17
+
18
+ # These actions permissions can be configured in the admin panel
19
+ # component.actions = %w()
20
+
21
+ # component.settings(:global) do |settings|
22
+ # # Add your global settings
23
+ # # Available types: :integer, :boolean
24
+ # # settings.attribute :vote_limit, type: :integer, default: 0
25
+ # end
26
+
27
+ # component.settings(:step) do |settings|
28
+ # # Add your settings per step
29
+ # end
30
+
31
+ # component.register_resource(:some_resource) do |resource|
32
+ # # Register a optional resource that can be references from other resources.
33
+ # resource.model_class_name = "Decidim::Sdgs::SomeResource"
34
+ # resource.template = "decidim/sdgs/some_resources/linked_some_resources"
35
+ # end
36
+
37
+ # component.register_stat :some_stat do |context, start_at, end_at|
38
+ # # Register some stat number to the application
39
+ # end
40
+
41
+ # component.seeds do |participatory_space|
42
+ # # Add some seeds for this component
43
+ # end
44
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+ require "decidim/core"
5
+
6
+ module Decidim
7
+ module Sdgs
8
+ # This is the engine that runs on the public interface of challenges.
9
+ class Engine < ::Rails::Engine
10
+ isolate_namespace Decidim::Sdgs
11
+
12
+ routes do
13
+ # Add engine routes here
14
+ resources :sdgs, only: [:index, :show]
15
+ root to: "sdgs#index"
16
+ end
17
+
18
+ initializer "decidim_sdgs.webpacker.assets_path" do
19
+ Decidim.register_assets_path File.expand_path("app/packs", root)
20
+ end
21
+ end
22
+ end
23
+ end