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
@@ -74,7 +74,7 @@ module Decidim
74
74
 
75
75
  scope :past, -> { where(arel_table[:end_date].lt(Date.current)) }
76
76
  scope :upcoming, -> { where(arel_table[:start_date].gt(Date.current)) }
77
- scope :active, -> { where(arel_table[:start_date].lteq(Date.current).and(arel_table[:end_date].gt(Date.current).or(arel_table[:end_date].eq(nil)))) }
77
+ scope :active, -> { where(arel_table[:start_date].lteq(Date.current).and(arel_table[:end_date].gteq(Date.current).or(arel_table[:end_date].eq(nil)))) }
78
78
 
79
79
  searchable_fields({
80
80
  scope_id: :decidim_scope_id,
@@ -124,7 +124,7 @@ module Decidim
124
124
  def active?
125
125
  return false if start_date.blank?
126
126
 
127
- start_date < Date.current && (end_date.blank? || end_date > Date.current)
127
+ start_date <= Date.current && (end_date.blank? || end_date >= Date.current)
128
128
  end
129
129
 
130
130
  def past?
@@ -7,7 +7,8 @@ module Decidim
7
7
  include Decidim::HasUploadValidations
8
8
  include Decidim::TranslatableResource
9
9
 
10
- translatable_fields :name, :description
10
+ translatable_fields :title, :description, :developer_group, :local_area, :meta_scope, :participatory_scope,
11
+ :participatory_structure, :target
11
12
 
12
13
  has_many :participatory_processes,
13
14
  foreign_key: "decidim_participatory_process_group_id",
@@ -22,6 +23,13 @@ module Decidim
22
23
  validates_upload :hero_image
23
24
  mount_uploader :hero_image, Decidim::HeroImageUploader
24
25
 
26
+ # Scope to return only the promoted groups.
27
+ #
28
+ # Returns an ActiveRecord::Relation.
29
+ def self.promoted
30
+ where(promoted: true)
31
+ end
32
+
25
33
  def self.log_presenter_class_for(_log)
26
34
  Decidim::ParticipatoryProcesses::AdminLog::ParticipatoryProcessGroupPresenter
27
35
  end
@@ -17,8 +17,16 @@ module Decidim
17
17
 
18
18
  def diff_fields_mapping
19
19
  {
20
- name: :i18n,
21
- description: :i18n
20
+ description: :i18n,
21
+ developer_group: :i18n,
22
+ hashtag: :string,
23
+ group_url: :string,
24
+ local_area: :i18n,
25
+ meta_scope: :i18n,
26
+ title: :i18n,
27
+ participatory_scope: :i18n,
28
+ participatory_structure: :i18n,
29
+ target: :i18n
22
30
  }
23
31
  end
24
32
 
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # A presenter to render statistics in the homepage.
6
+ class ParticipatoryProcessGroupStatsPresenter < Rectify::Presenter
7
+ attribute :participatory_process_group, Decidim::ParticipatoryProcessGroup
8
+ include Decidim::IconHelper
9
+
10
+ # Public: returns a collection of stats (Hash) for the participatory
11
+ # process group landing page.
12
+ def collection
13
+ highlighted_stats = process_participants_stats
14
+ highlighted_stats.concat(process_followers_stats(priority: StatsRegistry::HIGH_PRIORITY))
15
+ highlighted_stats.concat(component_stats(priority: StatsRegistry::HIGH_PRIORITY))
16
+ highlighted_stats.concat(component_stats(priority: StatsRegistry::MEDIUM_PRIORITY))
17
+ highlighted_stats = highlighted_stats.reject(&:empty?)
18
+ highlighted_stats = highlighted_stats.reject { |_stat_manifest, _stat_title, stat_number| stat_number.zero? }
19
+ grouped_highlighted_stats = highlighted_stats.group_by(&:first)
20
+
21
+ statistics = []
22
+ grouped_highlighted_stats.each do |_manifest_name, stats|
23
+ stats.each_with_index.each do |stat, _index|
24
+ stat.each_with_index.map do |_item, subindex|
25
+ next unless (subindex % 3).zero?
26
+ next if stat[subindex + 2].zero?
27
+
28
+ statistics << { stat_title: stat[subindex + 1], stat_number: stat[subindex + 2] }
29
+ end
30
+ end
31
+ end
32
+ statistics
33
+ end
34
+
35
+ private
36
+
37
+ def process_participants_stats
38
+ Decidim.stats.only([:participants_count]).with_context(participatory_process_group)
39
+ .map { |stat_title, stat_number| [:participatory_process_group, stat_title, stat_number] }
40
+ end
41
+
42
+ def component_stats(conditions)
43
+ Decidim.component_manifests.map do |component_manifest|
44
+ component_manifest.stats.except([:proposals_accepted])
45
+ .filter(conditions)
46
+ .with_context(published_components)
47
+ .map { |stat_title, stat_number| [component_manifest.name, stat_title, stat_number] }.flatten
48
+ end
49
+ end
50
+
51
+ def process_followers_stats(conditions)
52
+ Decidim.stats.only([:followers_count])
53
+ .filter(conditions)
54
+ .with_context(participatory_process_group)
55
+ .map { |stat_title, stat_number| [:participatory_process_group, stat_title, stat_number] }
56
+ end
57
+
58
+ def participatory_processes
59
+ @participatory_processes ||= participatory_process_group.participatory_processes
60
+ end
61
+
62
+ def published_components
63
+ @published_components ||= Component.where(participatory_space: participatory_processes).published
64
+ end
65
+ end
66
+ end
67
+ end
@@ -6,14 +6,15 @@ module Decidim
6
6
  include Rails.application.routes.mounted_helpers
7
7
  include ActionView::Helpers::UrlHelper
8
8
 
9
- delegate :url, to: :hero_image, prefix: true
10
- delegate :url, to: :banner_image, prefix: true
11
-
12
9
  def hero_image_url
10
+ return unless process.hero_image_url
11
+
13
12
  URI.join(decidim.root_url(host: process.organization.host), process.hero_image_url).to_s
14
13
  end
15
14
 
16
15
  def banner_image_url
16
+ return unless process.banner_image_url
17
+
17
18
  URI.join(decidim.root_url(host: process.organization.host), process.banner_image_url).to_s
18
19
  end
19
20
 
@@ -10,9 +10,9 @@ module Decidim
10
10
  # Public: returns a collection of stats (Hash) for the Process Home.
11
11
  def collection
12
12
  highlighted_stats = process_participants_stats
13
- highlighted_stats = highlighted_stats.concat(process_followers_stats(priority: StatsRegistry::HIGH_PRIORITY))
14
- highlighted_stats = highlighted_stats.concat(component_stats(priority: StatsRegistry::HIGH_PRIORITY))
15
- highlighted_stats = highlighted_stats.concat(component_stats(priority: StatsRegistry::MEDIUM_PRIORITY))
13
+ highlighted_stats.concat(process_followers_stats(priority: StatsRegistry::HIGH_PRIORITY))
14
+ highlighted_stats.concat(component_stats(priority: StatsRegistry::HIGH_PRIORITY))
15
+ highlighted_stats.concat(component_stats(priority: StatsRegistry::MEDIUM_PRIORITY))
16
16
  highlighted_stats = highlighted_stats.reject(&:empty?)
17
17
  highlighted_stats = highlighted_stats.reject { |_stat_manifest, _stat_title, stat_number| stat_number.zero? }
18
18
  grouped_highlighted_stats = highlighted_stats.group_by(&:first)
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # This query class filters all processes of a participatory process group
6
+ class GroupParticipatoryProcesses < Rectify::Query
7
+ def initialize(group)
8
+ @group = group
9
+ end
10
+
11
+ def query
12
+ Decidim::ParticipatoryProcess.where(participatory_process_group: @group)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # This query class filters published processes of a participatory process group
6
+ class GroupPublishedParticipatoryProcesses < Rectify::Query
7
+ def initialize(group, user = nil)
8
+ @group = group
9
+ @user = user
10
+ end
11
+
12
+ def query
13
+ Rectify::Query.merge(
14
+ GroupParticipatoryProcesses.new(@group),
15
+ VisibleParticipatoryProcesses.new(@user),
16
+ PublishedParticipatoryProcesses.new
17
+ ).query
18
+ end
19
+ end
20
+ end
21
+ end
@@ -9,7 +9,7 @@ module Decidim
9
9
  end
10
10
 
11
11
  def query
12
- Decidim::ParticipatoryProcess.where(organization: @organization)
12
+ Decidim::ParticipatoryProcess.where(organization: @organization).order(weight: :asc)
13
13
  end
14
14
  end
15
15
  end
@@ -14,7 +14,7 @@ module Decidim
14
14
  OrganizationParticipatoryProcesses.new(@organization),
15
15
  VisibleParticipatoryProcesses.new(@user),
16
16
  PublishedParticipatoryProcesses.new
17
- ).query
17
+ ).query.order(weight: :asc)
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # This query filters participatory process groups so only promoted ones are returned.
6
+ class PromotedParticipatoryProcessGroups < Rectify::Query
7
+ def query
8
+ Decidim::ParticipatoryProcessGroup.promoted
9
+ end
10
+ end
11
+ end
12
+ end
@@ -2,10 +2,12 @@
2
2
 
3
3
  module Decidim
4
4
  module ParticipatoryProcesses
5
- # This class counts all Followers of a participatory processes
5
+ # This class counts all Followers of a participatory process or
6
+ # participatory processes belonging to a participatory process group
6
7
  class StatsFollowersCount < Rectify::Query
7
8
  def self.for(participatory_space)
8
- return 0 unless participatory_space.is_a? Decidim::ParticipatoryProcess
9
+ return 0 unless participatory_space.is_a?(Decidim::ParticipatoryProcess) ||
10
+ participatory_space.is_a?(Decidim::ParticipatoryProcessGroup) && participatory_space.participatory_processes.exists?
9
11
 
10
12
  new(participatory_space).query
11
13
  end
@@ -26,7 +28,7 @@ module Decidim
26
28
  Decidim.component_manifests.sum do |component|
27
29
  component.stats
28
30
  .filter(tag: :followers)
29
- .with_context(participatory_space.components.published)
31
+ .with_context(space_components)
30
32
  .map { |_name, value| value }
31
33
  .sum
32
34
  end
@@ -36,11 +38,23 @@ module Decidim
36
38
  Decidim.participatory_space_manifests.sum do |space|
37
39
  space.stats
38
40
  .filter(tag: :followers)
39
- .with_context(participatory_space)
41
+ .with_context(participatory_space_items)
40
42
  .map { |_name, value| value }
41
43
  .sum
42
44
  end
43
45
  end
46
+
47
+ def participatory_space_items
48
+ @participatory_space_items ||= if participatory_space.is_a?(Decidim::ParticipatoryProcess)
49
+ participatory_space
50
+ else
51
+ participatory_space.participatory_processes
52
+ end
53
+ end
54
+
55
+ def space_components
56
+ @space_components ||= Decidim::Component.where(participatory_space: participatory_space_items).published
57
+ end
44
58
  end
45
59
  end
46
60
  end
@@ -2,10 +2,12 @@
2
2
 
3
3
  module Decidim
4
4
  module ParticipatoryProcesses
5
- # This class counts unique Participants on a participatory processes
5
+ # This class counts unique Participants on a participatory process or
6
+ # participatory processes belonging to a participatory process group
6
7
  class StatsParticipantsCount < Rectify::Query
7
8
  def self.for(participatory_space)
8
- return 0 unless participatory_space.is_a? Decidim::ParticipatoryProcess
9
+ return 0 unless participatory_space.is_a?(Decidim::ParticipatoryProcess) ||
10
+ participatory_space.is_a?(Decidim::ParticipatoryProcessGroup) && participatory_space.participatory_processes.exists?
9
11
 
10
12
  new(participatory_space).query
11
13
  end
@@ -30,9 +32,17 @@ module Decidim
30
32
 
31
33
  attr_reader :participatory_space
32
34
 
35
+ def participatory_space_ids
36
+ @participatory_space_ids ||= if participatory_space.is_a?(Decidim::ParticipatoryProcess)
37
+ participatory_space.id
38
+ else
39
+ participatory_space.participatory_processes.pluck(:id)
40
+ end
41
+ end
42
+
33
43
  def comments_query
34
44
  Decidim::Comments::Comment
35
- .where(decidim_root_commentable_id: participatory_space.id)
45
+ .where(decidim_root_commentable_id: participatory_space_ids)
36
46
  .pluck(:decidim_author_id)
37
47
  .uniq
38
48
  end
@@ -89,7 +99,11 @@ module Decidim
89
99
  end
90
100
 
91
101
  def space_components
92
- @space_components ||= participatory_space.components
102
+ @space_components ||= if participatory_space.is_a?(Decidim::ParticipatoryProcess)
103
+ participatory_space.components
104
+ else
105
+ Decidim::Component.where(participatory_space: participatory_space.participatory_processes)
106
+ end
93
107
  end
94
108
 
95
109
  def proposals_components
@@ -12,14 +12,18 @@ module Decidim
12
12
  processes = Decidim::ParticipatoryProcess.all
13
13
 
14
14
  if @current_user
15
- return processes if @current_user.admin
15
+ return groups if @current_user.admin?
16
16
 
17
17
  processes = processes.visible_for(@current_user.id)
18
18
  else
19
19
  processes = processes.public_spaces
20
20
  end
21
21
 
22
- Decidim::ParticipatoryProcessGroup.where(id: processes.pluck(:decidim_participatory_process_group_id))
22
+ groups.where(id: processes.pluck(:decidim_participatory_process_group_id))
23
+ end
24
+
25
+ def groups
26
+ @groups ||= Decidim::ParticipatoryProcessGroup.all
23
27
  end
24
28
  end
25
29
  end
@@ -54,7 +54,7 @@ module Decidim
54
54
  def import_process_group(attributes)
55
55
  Decidim.traceability.perform_action!("create", ParticipatoryProcessGroup, @user) do
56
56
  group = ParticipatoryProcessGroup.find_or_initialize_by(
57
- name: attributes["name"],
57
+ title: attributes["title"],
58
58
  description: attributes["description"],
59
59
  organization: @organization
60
60
  )
@@ -41,7 +41,7 @@ module Decidim
41
41
  },
42
42
  participatory_process_group: {
43
43
  id: participatory_process.participatory_process_group.try(:id),
44
- name: participatory_process.participatory_process_group.try(:name) || empty_translatable,
44
+ title: participatory_process.participatory_process_group.try(:title) || empty_translatable,
45
45
  description: participatory_process.participatory_process_group.try(:description) || empty_translatable,
46
46
  remote_hero_image_url: Decidim::ParticipatoryProcesses::ParticipatoryProcessGroupPresenter.new(participatory_process.participatory_process_group).hero_image_url
47
47
  },
@@ -5,7 +5,8 @@ module Decidim
5
5
  # Service that encapsulates all logic related to filtering participatory processes.
6
6
  class ParticipatoryProcessSearch < ParticipatorySpaceSearch
7
7
  def initialize(options = {})
8
- super(ParticipatoryProcess.all, options)
8
+ base_relation = options.has_key?(:base_relation) ? options.delete(:base_relation) : ParticipatoryProcess.all
9
+ super(base_relation, options)
9
10
  end
10
11
 
11
12
  def search_date
@@ -1,3 +1,5 @@
1
+ <% add_decidim_page_title(t("participatory_process_copies.new.select", scope: "decidim.admin")) %>
2
+
1
3
  <%= decidim_form_for(@form, url: participatory_process_copies_path(current_participatory_process), method: :post, html: { class: "form copy_participatory_process" }) do |f| %>
2
4
  <%= render partial: "form", object: f, locals: { title: t("participatory_process_copies.new.title", scope: "decidim.admin"), select: t("participatory_process_copies.new.select", scope: "decidim.admin") } %>
3
5
 
@@ -1,17 +1,72 @@
1
- <div class="row column">
2
- <%= form.translated :text_field, :name, autofocus: true %>
3
- </div>
1
+ <div class="card">
2
+ <div class="card-divider">
3
+ <h2 class="card-title"><%= t(".title") %></h2>
4
+ </div>
5
+ <div class="card-section">
6
+ <div class="row column">
7
+ <%= form.translated :text_field, :title, autofocus: true %>
8
+ </div>
4
9
 
5
- <div class="row column">
6
- <%= form.translated :editor, :description, toolbar: :full, lines: 25 %>
7
- </div>
10
+ <div class="row column">
11
+ <%= form.translated :editor, :description, toolbar: :full, lines: 25 %>
12
+ </div>
8
13
 
9
- <div class="row column">
10
- <% if processes_for_select %>
11
- <%= form.select :participatory_process_ids, processes_for_select, {}, { multiple: true, class: "chosen-select" } %>
12
- <% end %>
13
- </div>
14
+ <div class="row column">
15
+ <% if processes_for_select %>
16
+ <%= form.select :participatory_process_ids, processes_for_select, {}, { multiple: true, class: "chosen-select" } %>
17
+ <% end %>
18
+ </div>
19
+
20
+ <div class="row column">
21
+ <%= form.upload :hero_image %>
22
+ </div>
23
+ </div>
24
+
25
+ <div class="card-divider">
26
+ <h2 class="card-title"><%= t(".metadata") %></h2>
27
+ </div>
28
+
29
+ <div class="card-section">
30
+ <div class="row column">
31
+ <%= form.text_field :hashtag %>
32
+ </div>
33
+
34
+ <div class="row column">
35
+ <%= form.text_field :group_url %>
36
+ </div>
37
+
38
+ <div class="row column">
39
+ <%= form.translated :text_field, :developer_group %>
40
+ </div>
41
+
42
+ <div class="row column">
43
+ <%= form.translated :text_field, :local_area %>
44
+ </div>
45
+
46
+ <div class="row column">
47
+ <%= form.translated :text_field, :meta_scope %>
48
+ </div>
49
+
50
+ <div class="row column">
51
+ <%= form.translated :text_field, :target %>
52
+ </div>
53
+
54
+ <div class="row column">
55
+ <%= form.translated :text_field, :participatory_scope %>
56
+ </div>
57
+
58
+ <div class="row column">
59
+ <%= form.translated :text_field, :participatory_structure %>
60
+ </div>
61
+ </div>
62
+
63
+ <div class="card-divider">
64
+ <h2 class="card-title"><%= t(".visibility") %></h2>
65
+ </div>
14
66
 
15
- <div class="row column">
16
- <%= form.upload :hero_image %>
67
+ <div class="card-section">
68
+ <div class="row column">
69
+ <%= form.check_box :promoted %>
70
+ </div>
71
+ </div>
17
72
  </div>