decidim-participatory_processes 0.23.3 → 0.24.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/participatory_process_groups/content_block_cell.rb +17 -0
  3. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/filters.erb +22 -0
  4. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/filters_small_view.erb +18 -0
  5. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/participatory_space_filters.erb +6 -0
  6. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/show.erb +7 -0
  7. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/title_filter_order.erb +8 -0
  8. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes_cell.rb +65 -0
  9. data/app/cells/decidim/participatory_process_groups/content_blocks/html/show.erb +3 -0
  10. data/app/cells/decidim/participatory_process_groups/content_blocks/html_cell.rb +13 -0
  11. data/app/cells/decidim/participatory_process_groups/content_blocks/metadata/show.erb +28 -0
  12. data/app/cells/decidim/participatory_process_groups/content_blocks/metadata_cell.rb +15 -0
  13. data/app/cells/decidim/participatory_process_groups/content_blocks/stats/show.erb +13 -0
  14. data/app/cells/decidim/participatory_process_groups/content_blocks/stats_cell.rb +17 -0
  15. data/app/cells/decidim/participatory_process_groups/content_blocks/title/show.erb +43 -0
  16. data/app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb +56 -0
  17. data/app/cells/decidim/participatory_process_groups/process_filters_cell.rb +78 -0
  18. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/show.erb +2 -16
  19. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/single_process.erb +32 -28
  20. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb +33 -10
  21. data/app/cells/decidim/participatory_processes/filtered_participatory_processes/show.erb +3 -0
  22. data/app/cells/decidim/participatory_processes/filtered_participatory_processes_cell.rb +56 -0
  23. data/app/cells/decidim/participatory_processes/process_cell.rb +6 -1
  24. data/app/cells/decidim/participatory_processes/process_filters_cell.rb +1 -1
  25. data/app/cells/decidim/participatory_processes/process_group_cell.rb +6 -1
  26. data/app/cells/decidim/participatory_processes/process_group_m_cell.rb +3 -1
  27. data/app/cells/decidim/participatory_processes/process_group_s/image.erb +1 -0
  28. data/app/cells/decidim/participatory_processes/process_group_s/show.erb +8 -0
  29. data/app/cells/decidim/participatory_processes/process_group_s_cell.rb +23 -0
  30. data/app/cells/decidim/participatory_processes/process_s/image.erb +1 -0
  31. data/app/cells/decidim/participatory_processes/process_s/show.erb +14 -0
  32. data/app/cells/decidim/participatory_processes/process_s_cell.rb +35 -0
  33. data/app/cells/decidim/participatory_processes/statistic/show.erb +3 -3
  34. data/app/cells/decidim/participatory_processes/statistics/show.erb +1 -1
  35. data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +1 -0
  36. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb +7 -75
  37. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_group.rb +11 -2
  38. data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +1 -0
  39. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_group.rb +11 -2
  40. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb +1 -0
  41. data/app/controllers/decidim/participatory_processes/admin/imports_controller.rb +14 -0
  42. data/app/controllers/decidim/participatory_processes/admin/moderations/reports_controller.rb +18 -0
  43. data/app/controllers/decidim/participatory_processes/admin/participatory_process_group_landing_page_content_blocks_controller.rb +48 -0
  44. data/app/controllers/decidim/participatory_processes/admin/participatory_process_group_landing_page_controller.rb +53 -0
  45. data/app/controllers/decidim/participatory_processes/admin/participatory_process_groups_controller.rb +3 -1
  46. data/app/controllers/decidim/participatory_processes/participatory_process_groups_controller.rb +1 -2
  47. data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +14 -1
  48. data/app/events/decidim/participatory_process_role_assigned_event.rb +1 -1
  49. data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +3 -0
  50. data/app/forms/decidim/participatory_processes/admin/participatory_process_group_form.rb +34 -2
  51. data/app/forms/decidim/participatory_processes/admin/participatory_process_step_form.rb +1 -1
  52. data/app/helpers/decidim/participatory_processes/admin/participatory_processes_menu_helper.rb +23 -0
  53. data/app/helpers/decidim/participatory_processes/admin/process_groups_for_select_helper.rb +1 -1
  54. data/app/helpers/decidim/participatory_processes/application_helper.rb +0 -12
  55. data/app/helpers/decidim/participatory_processes/participatory_process_helper.rb +35 -0
  56. data/app/models/decidim/participatory_process.rb +2 -2
  57. data/app/models/decidim/participatory_process_group.rb +9 -1
  58. data/app/presenters/decidim/participatory_processes/admin_log/participatory_process_group_presenter.rb +10 -2
  59. data/app/presenters/decidim/participatory_processes/participatory_process_group_stats_presenter.rb +67 -0
  60. data/app/presenters/decidim/participatory_processes/participatory_process_presenter.rb +4 -3
  61. data/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb +3 -3
  62. data/app/queries/decidim/participatory_processes/group_participatory_processes.rb +16 -0
  63. data/app/queries/decidim/participatory_processes/group_published_participatory_processes.rb +21 -0
  64. data/app/queries/decidim/participatory_processes/organization_participatory_processes.rb +1 -1
  65. data/app/queries/decidim/participatory_processes/organization_published_participatory_processes.rb +1 -1
  66. data/app/queries/decidim/participatory_processes/promoted_participatory_process_groups.rb +12 -0
  67. data/app/queries/decidim/participatory_processes/stats_followers_count.rb +18 -4
  68. data/app/queries/decidim/participatory_processes/stats_participants_count.rb +18 -4
  69. data/app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb +6 -2
  70. data/app/serializers/decidim/participatory_processes/participatory_process_importer.rb +1 -1
  71. data/app/serializers/decidim/participatory_processes/participatory_process_serializer.rb +1 -1
  72. data/app/services/decidim/participatory_processes/participatory_process_search.rb +2 -1
  73. data/app/views/decidim/participatory_processes/admin/participatory_process_copies/new.html.erb +2 -0
  74. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/_form.html.erb +68 -13
  75. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/edit.html.erb +7 -14
  76. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/index.html.erb +12 -3
  77. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/new.html.erb +2 -8
  78. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/show.html.erb +10 -2
  79. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/edit.html.erb +1 -0
  80. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/index.html.erb +6 -0
  81. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/edit.html.erb +2 -0
  82. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/index.html.erb +8 -0
  83. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/new.html.erb +2 -0
  84. data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +4 -0
  85. data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +14 -3
  86. data/app/views/decidim/participatory_processes/admin/participatory_processes/new.html.erb +2 -0
  87. data/app/views/decidim/participatory_processes/admin/shared/_secondary_nav.html.erb +2 -16
  88. data/app/views/decidim/participatory_processes/participatory_process_groups/show.html.erb +18 -8
  89. data/app/views/decidim/participatory_processes/participatory_process_groups/show.js.erb +12 -0
  90. data/app/views/decidim/participatory_processes/participatory_processes/_participatory_process_group.html.erb +4 -0
  91. data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process_group.html.erb +31 -0
  92. data/app/views/decidim/participatory_processes/participatory_processes/index.html.erb +4 -2
  93. data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +4 -4
  94. data/app/views/layouts/decidim/admin/participatory_process.html.erb +8 -1
  95. data/app/views/layouts/decidim/admin/participatory_process_group.html.erb +17 -0
  96. data/config/locales/ar.yml +3 -10
  97. data/config/locales/ca.yml +52 -5
  98. data/config/locales/cs.yml +56 -9
  99. data/config/locales/de.yml +52 -5
  100. data/config/locales/el.yml +3 -6
  101. data/config/locales/en.yml +52 -5
  102. data/config/locales/es-MX.yml +52 -5
  103. data/config/locales/es-PY.yml +52 -5
  104. data/config/locales/es.yml +52 -5
  105. data/config/locales/eu.yml +3 -6
  106. data/config/locales/fi-plain.yml +53 -6
  107. data/config/locales/fi.yml +53 -6
  108. data/config/locales/fr-CA.yml +52 -5
  109. data/config/locales/fr.yml +52 -5
  110. data/config/locales/gl.yml +84 -5
  111. data/config/locales/hu.yml +3 -6
  112. data/config/locales/id-ID.yml +3 -5
  113. data/config/locales/is-IS.yml +3 -3
  114. data/config/locales/it.yml +8 -6
  115. data/config/locales/ja.yml +3 -5
  116. data/config/locales/lv.yml +3 -7
  117. data/config/locales/nl.yml +50 -6
  118. data/config/locales/no.yml +3 -6
  119. data/config/locales/pl.yml +63 -13
  120. data/config/locales/pt-BR.yml +3 -6
  121. data/config/locales/pt.yml +3 -6
  122. data/config/locales/ro-RO.yml +74 -25
  123. data/config/locales/ru.yml +4 -9
  124. data/config/locales/sk.yml +3 -8
  125. data/config/locales/sr-CS.yml +4 -0
  126. data/config/locales/sv.yml +33 -5
  127. data/config/locales/tr-TR.yml +51 -5
  128. data/config/locales/uk.yml +4 -9
  129. data/config/locales/zh-CN.yml +3 -5
  130. data/db/migrate/20170220110740_remove_steps_short_description.rb +1 -1
  131. data/db/migrate/20201007215105_add_hashtag_to_participatory_process_groups.rb +7 -0
  132. data/db/migrate/20201008154315_add_metadata_columns_to_participatory_process_groups.rb +13 -0
  133. data/db/migrate/20201013105520_rename_name_column_to_title_in_decidim_participatory_process_groups.rb +39 -0
  134. data/db/migrate/20201030133444_add_promoted_flag_to_decidim_participatory_process_groups.rb +7 -0
  135. data/db/migrate/20210204154593_add_weight_field_to_participatory_processes.rb +7 -0
  136. data/db/migrate/20210310120750_add_followable_counter_cache_to_participatory_processes.rb +16 -0
  137. data/lib/decidim/api/participatory_process_group_type.rb +17 -0
  138. data/{app/types/decidim/participatory_processes → lib/decidim/api}/participatory_process_input_filter.rb +0 -0
  139. data/{app/types/decidim/participatory_processes → lib/decidim/api}/participatory_process_input_sort.rb +2 -2
  140. data/lib/decidim/api/participatory_process_step_type.rb +23 -0
  141. data/lib/decidim/api/participatory_process_type.rb +50 -0
  142. data/lib/decidim/participatory_processes.rb +2 -6
  143. data/lib/decidim/participatory_processes/admin_engine.rb +49 -1
  144. data/lib/decidim/participatory_processes/api.rb +11 -0
  145. data/lib/decidim/participatory_processes/engine.rb +90 -8
  146. data/lib/decidim/participatory_processes/participatory_space.rb +47 -24
  147. data/lib/decidim/participatory_processes/query_extensions.rb +18 -20
  148. data/lib/decidim/participatory_processes/test/factories.rb +15 -2
  149. data/lib/decidim/participatory_processes/version.rb +1 -1
  150. metadata +59 -17
  151. data/app/functions/decidim/participatory_processes/participatory_process_finder.rb +0 -10
  152. data/app/functions/decidim/participatory_processes/participatory_process_list.rb +0 -11
  153. data/app/types/decidim/participatory_processes/participatory_process_group_type.rb +0 -20
  154. data/app/types/decidim/participatory_processes/participatory_process_step_type.rb +0 -28
  155. data/app/types/decidim/participatory_processes/participatory_process_type.rb +0 -54
@@ -46,10 +46,19 @@ module Decidim
46
46
  ) do
47
47
  ParticipatoryProcessGroup.create(
48
48
  organization: form.current_organization,
49
- name: form.name,
49
+ title: form.title,
50
50
  description: form.description,
51
+ hashtag: form.hashtag,
52
+ group_url: form.group_url,
51
53
  hero_image: form.hero_image, # Keep after organization
52
- participatory_processes: participatory_processes
54
+ participatory_processes: participatory_processes,
55
+ developer_group: form.developer_group,
56
+ local_area: form.local_area,
57
+ meta_scope: form.meta_scope,
58
+ participatory_scope: form.participatory_scope,
59
+ participatory_structure: form.participatory_structure,
60
+ target: form.target,
61
+ promoted: form.promoted
53
62
  )
54
63
  end
55
64
  end
@@ -55,6 +55,7 @@ module Decidim
55
55
  {
56
56
  title: form.title,
57
57
  subtitle: form.subtitle,
58
+ weight: form.weight,
58
59
  slug: form.slug,
59
60
  hashtag: form.hashtag,
60
61
  promoted: form.promoted,
@@ -51,11 +51,20 @@ module Decidim
51
51
 
52
52
  def attributes
53
53
  {
54
- name: form.name,
54
+ title: form.title,
55
55
  hero_image: form.hero_image,
56
56
  remove_hero_image: form.remove_hero_image,
57
57
  description: form.description,
58
- participatory_processes: participatory_processes
58
+ hashtag: form.hashtag,
59
+ group_url: form.group_url,
60
+ participatory_processes: participatory_processes,
61
+ developer_group: form.developer_group,
62
+ local_area: form.local_area,
63
+ meta_scope: form.meta_scope,
64
+ participatory_scope: form.participatory_scope,
65
+ participatory_structure: form.participatory_structure,
66
+ target: form.target,
67
+ promoted: form.promoted
59
68
  }
60
69
  end
61
70
 
@@ -7,6 +7,7 @@ module Decidim
7
7
  # process in the system.
8
8
  class UpdateParticipatoryProcessStep < Rectify::Command
9
9
  attr_reader :step
10
+
10
11
  # Public: Initializes the command.
11
12
  #
12
13
  # step - the ParticipatoryProcessStep to update
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ module Admin
6
+ # This controller allows importing things.
7
+ # It is targeted for customizations for importing things that lives under
8
+ # a participatory process.
9
+ class ImportsController < Decidim::Admin::ImportsController
10
+ include Concerns::ParticipatoryProcessAdmin
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ module Admin
6
+ module Moderations
7
+ # This controller allows admins to manage moderation reports in a participatory process.
8
+ class ReportsController < Decidim::Admin::Moderations::ReportsController
9
+ include Concerns::ParticipatoryProcessAdmin
10
+
11
+ def permissions_context
12
+ super.merge(current_participatory_space: current_participatory_space)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ module Admin
6
+ # Controller that allows to manage the content from the participatory process landing page content blocks
7
+ class ParticipatoryProcessGroupLandingPageContentBlocksController < Decidim::ParticipatoryProcesses::Admin::ApplicationController
8
+ include Decidim::Admin::LandingPageContentBlocks
9
+
10
+ layout "decidim/admin/participatory_process_group"
11
+
12
+ helper_method :participatory_process_group
13
+
14
+ private
15
+
16
+ def content_block_scope
17
+ :participatory_process_group_homepage
18
+ end
19
+
20
+ def scoped_resource
21
+ @scoped_resource ||= collection.find(params[:participatory_process_group_id])
22
+ end
23
+
24
+ def enforce_permission_to_update_resource
25
+ enforce_permission_to :update, :process_group, process_group: scoped_resource
26
+ end
27
+
28
+ def edit_resource_landing_page_path
29
+ edit_participatory_process_group_landing_page_path(scoped_resource)
30
+ end
31
+
32
+ def resource_landing_page_content_block_path
33
+ participatory_process_group_landing_page_content_block_path(scoped_resource, params[:id])
34
+ end
35
+
36
+ def submit_button_text
37
+ t("participatory_process_group_landing_page_content_blocks.edit.update", scope: "decidim.admin")
38
+ end
39
+
40
+ alias participatory_process_group scoped_resource
41
+
42
+ def collection
43
+ @collection ||= OrganizationParticipatoryProcessGroups.new(current_user.organization).query
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ module Admin
6
+ # Controller that allows managing the participatory process group landing
7
+ # page
8
+ class ParticipatoryProcessGroupLandingPageController < Decidim::ParticipatoryProcesses::Admin::ApplicationController
9
+ include Decidim::Admin::LandingPage
10
+
11
+ layout "decidim/admin/participatory_process_group"
12
+
13
+ helper_method :participatory_process_group
14
+
15
+ def content_block_scope
16
+ :participatory_process_group_homepage
17
+ end
18
+
19
+ def scoped_resource
20
+ @scoped_resource ||= collection.find(params[:participatory_process_group_id])
21
+ end
22
+
23
+ def enforce_permission_to_update_resource
24
+ enforce_permission_to :update, :process_group, process_group: scoped_resource
25
+ end
26
+
27
+ def resource_sort_url
28
+ participatory_process_group_landing_page_path(scoped_resource)
29
+ end
30
+
31
+ def active_content_blocks_title
32
+ t("participatory_process_group_landing_page.edit.active_content_blocks", scope: "decidim.admin")
33
+ end
34
+
35
+ def inactive_content_blocks_title
36
+ t("participatory_process_group_landing_page.edit.inactive_content_blocks", scope: "decidim.admin")
37
+ end
38
+
39
+ def resource_content_block_cell
40
+ "decidim/participatory_process_groups/content_block"
41
+ end
42
+
43
+ alias participatory_process_group scoped_resource
44
+
45
+ private
46
+
47
+ def collection
48
+ @collection ||= OrganizationParticipatoryProcessGroups.new(current_user.organization).query
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -16,6 +16,7 @@ module Decidim
16
16
 
17
17
  def show
18
18
  enforce_permission_to :read, :process_group, process_group: participatory_process_group
19
+ render layout: "decidim/admin/participatory_process_group"
19
20
  end
20
21
 
21
22
  def new
@@ -44,6 +45,7 @@ module Decidim
44
45
  @participatory_process_group = collection.find(params[:id])
45
46
  enforce_permission_to :update, :process_group, process_group: @participatory_process_group
46
47
  @form = form(ParticipatoryProcessGroupForm).from_model(@participatory_process_group)
48
+ render layout: "decidim/admin/participatory_process_group"
47
49
  end
48
50
 
49
51
  def update
@@ -59,7 +61,7 @@ module Decidim
59
61
 
60
62
  on(:invalid) do
61
63
  flash.now[:alert] = I18n.t("participatory_process_groups.update.error", scope: "decidim.admin")
62
- render :edit
64
+ render :edit, layout: "decidim/admin/participatory_process_group"
63
65
  end
64
66
  end
65
67
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  module ParticipatoryProcesses
5
5
  class ParticipatoryProcessGroupsController < Decidim::ParticipatoryProcesses::ApplicationController
6
6
  helper Decidim::SanitizeHelper
7
- helper_method :participatory_processes, :group, :collection
7
+ helper_method :participatory_processes, :group
8
8
 
9
9
  before_action :set_group
10
10
 
@@ -27,7 +27,6 @@ module Decidim
27
27
  group.participatory_processes.published.public_spaces
28
28
  end
29
29
  end
30
- alias collection participatory_processes
31
30
 
32
31
  def set_group
33
32
  @group = Decidim::ParticipatoryProcessGroup.find(params[:id])
@@ -10,10 +10,11 @@ module Decidim
10
10
  include FilterResource
11
11
 
12
12
  helper_method :collection,
13
- :promoted_participatory_processes,
13
+ :promoted_collection,
14
14
  :participatory_processes,
15
15
  :stats,
16
16
  :metrics,
17
+ :participatory_process_group,
17
18
  :default_date_filter,
18
19
  :related_processes,
19
20
  :linked_assemblies
@@ -71,6 +72,14 @@ module Decidim
71
72
  @promoted_participatory_processes ||= published_processes | PromotedParticipatoryProcesses.new
72
73
  end
73
74
 
75
+ def promoted_participatory_process_groups
76
+ @promoted_participatory_process_groups ||= PromotedParticipatoryProcessGroups.new
77
+ end
78
+
79
+ def promoted_collection
80
+ @promoted_collection ||= promoted_participatory_processes.query + promoted_participatory_process_groups.query
81
+ end
82
+
74
83
  def collection
75
84
  @collection ||= participatory_processes + participatory_process_groups
76
85
  end
@@ -96,6 +105,10 @@ module Decidim
96
105
  @metrics ||= ParticipatoryProcessMetricChartsPresenter.new(participatory_process: current_participatory_space)
97
106
  end
98
107
 
108
+ def participatory_process_group
109
+ @participatory_process_group ||= current_participatory_space.participatory_process_group
110
+ end
111
+
99
112
  def default_date_filter
100
113
  return "active" if published_processes.any?(&:active?)
101
114
  return "upcoming" if published_processes.any?(&:upcoming?)
@@ -10,7 +10,7 @@ module Decidim
10
10
  end
11
11
 
12
12
  def i18n_role
13
- I18n.t(extra["role"], "decidim.admin.models.participatory_process_user_role.roles", default: extra["role"])
13
+ I18n.t(extra["role"], scope: "decidim.admin.models.participatory_process_user_role.roles", default: extra["role"])
14
14
  end
15
15
 
16
16
  def i18n_options
@@ -32,6 +32,7 @@ module Decidim
32
32
  attribute :scope_id, Integer
33
33
  attribute :related_process_ids, Array[Integer]
34
34
  attribute :scope_type_max_depth_id, Integer
35
+ attribute :weight, Integer, default: 0
35
36
 
36
37
  attribute :private_space, Boolean
37
38
  attribute :promoted, Boolean
@@ -58,6 +59,8 @@ module Decidim
58
59
  validates :banner_image, passthru: { to: Decidim::ParticipatoryProcess }
59
60
  validates :hero_image, passthru: { to: Decidim::ParticipatoryProcess }
60
61
 
62
+ validates :weight, presence: true
63
+
61
64
  alias organization current_organization
62
65
 
63
66
  def map_model(model)
@@ -10,20 +10,52 @@ module Decidim
10
10
  include TranslatableAttributes
11
11
  include Decidim::HasUploadValidations
12
12
 
13
- translatable_attribute :name, String
14
13
  translatable_attribute :description, String
14
+ translatable_attribute :developer_group, String
15
+ translatable_attribute :local_area, String
16
+ translatable_attribute :meta_scope, String
17
+ translatable_attribute :title, String
18
+ translatable_attribute :participatory_scope, String
19
+ translatable_attribute :participatory_structure, String
20
+ translatable_attribute :target, String
21
+
22
+ attribute :group_url, String
23
+ attribute :hashtag, String
15
24
  attribute :participatory_process_ids, Array[Integer]
16
25
 
26
+ attribute :promoted, Boolean
27
+
17
28
  mimic :participatory_process_group
18
29
 
19
30
  attribute :hero_image
20
31
  attribute :remove_hero_image
21
32
 
22
- validates :name, :description, translatable_presence: true
33
+ validates :title, :description, translatable_presence: true
23
34
 
24
35
  validates :hero_image, passthru: { to: Decidim::ParticipatoryProcessGroup }
25
36
 
37
+ validate :group_url_format
38
+
26
39
  alias organization current_organization
40
+
41
+ def group_url
42
+ return if super.blank?
43
+
44
+ return "http://#{super.strip}" unless super.match?(%r{\A(http|https)://}i)
45
+
46
+ super.strip
47
+ end
48
+
49
+ private
50
+
51
+ def group_url_format
52
+ return if group_url.blank?
53
+
54
+ uri = URI.parse(group_url)
55
+ errors.add :group_url, :invalid if !uri.is_a?(URI::HTTP) || uri.host.nil?
56
+ rescue URI::InvalidURIError
57
+ errors.add :group_url, :invalid
58
+ end
27
59
  end
28
60
  end
29
61
  end
@@ -20,7 +20,7 @@ module Decidim
20
20
  attribute :cta_path, String
21
21
 
22
22
  validates :title, translatable_presence: true
23
- validates :cta_path, format: { with: %r{\A[a-zA-Z]+[a-zA-Z0-9\-\_/]+\z} }, allow_blank: true
23
+ validates :cta_path, format: { with: %r{\A[a-zA-Z]+[a-zA-Z0-9\-_/]+\z} }, allow_blank: true
24
24
 
25
25
  validates :start_date, date: { before: :end_date, allow_blank: true, if: proc { |obj| obj.end_date.present? } }
26
26
  validates :end_date, date: { after: :start_date, allow_blank: true, if: proc { |obj| obj.start_date.present? } }
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ module Admin
6
+ module ParticipatoryProcessesMenuHelper
7
+ include Decidim::Admin::SidebarMenuHelper
8
+
9
+ def participatory_process_menu
10
+ @participatory_process_menu ||= sidebar_menu(:admin_participatory_process_menu)
11
+ end
12
+
13
+ def participatory_process_group_menu
14
+ @participatory_process_group_menu ||= sidebar_menu(:admin_participatory_process_group_menu)
15
+ end
16
+
17
+ def participatory_processes_menu
18
+ @participatory_processes_menu ||= sidebar_menu(:admin_participatory_processes_menu)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -14,7 +14,7 @@ module Decidim
14
14
  def process_groups_for_select
15
15
  @process_groups_for_select ||=
16
16
  OrganizationParticipatoryProcessGroups.new(current_organization).map do |group|
17
- [translated_attribute(group.name), group.id]
17
+ [translated_attribute(group.title), group.id]
18
18
  end
19
19
  end
20
20
  end
@@ -6,18 +6,6 @@ module Decidim
6
6
  #
7
7
  module ApplicationHelper
8
8
  include Decidim::ResourceHelper
9
-
10
- # Public: Renders all hooks registered as `hook_name`.
11
- #
12
- # Note: We're passing a deep copy of the view context to allow
13
- # us to extend it without polluting the original view context
14
- #
15
- # @param hook_name [Symbol] representing the name of the hook.
16
- #
17
- # @return [String] an HTML safe String
18
- def render_participatory_processes_hook(hook_name)
19
- Decidim::ParticipatoryProcesses.view_hooks.render(hook_name, deep_dup)
20
- end
21
9
  end
22
10
  end
23
11
  end
@@ -32,6 +32,41 @@ module Decidim
32
32
 
33
33
  "#{path}/#{process.active_step.cta_path}" + (params.present? ? "?#{params}" : "")
34
34
  end
35
+
36
+ # Public: Returns the settings of a cta content block associated if
37
+ # exists
38
+ #
39
+ # Returns a Hash with content block settings or nil
40
+ def participatory_process_group_cta_settings(process_group)
41
+ block = Decidim::ContentBlock.for_scope(
42
+ :participatory_process_group_homepage,
43
+ organization: current_organization
44
+ ).find_by(
45
+ manifest_name: "cta",
46
+ scoped_resource_id: process_group.id
47
+ )
48
+
49
+ cta_settings = block&.settings
50
+
51
+ return if cta_settings.blank? || cta_settings.button_url.blank?
52
+
53
+ OpenStruct.new(
54
+ text: translated_attribute(cta_settings.button_text),
55
+ path: cta_settings.button_url,
56
+ image_url: block.images_container.background_image.big.url
57
+ )
58
+ end
59
+
60
+ # Public: Invokes the appropriate partial for a promoted
61
+ # participatory process or group based on the type name
62
+ #
63
+ # promoted_item - Can be a Decidim::ParticipatoryProcess or
64
+ # Decidim::ParticipatoryProcessGroup
65
+ def render_highlighted_partial_for(promoted_item)
66
+ name = promoted_item.class.name.demodulize.underscore.gsub("participatory_", "promoted_")
67
+
68
+ render partial: name, locals: { name => promoted_item }.symbolize_keys
69
+ end
35
70
  end
36
71
  end
37
72
  end