decidim-participatory_processes 0.10.1 → 0.11.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/javascripts/decidim/participatory_processes/admin/participatory_processes.js.es6 +4 -4
  4. data/app/assets/javascripts/decidim/participatory_processes/filters.js.es6 +8 -8
  5. data/app/commands/decidim/participatory_processes/admin/activate_participatory_process_step.rb +8 -8
  6. data/app/commands/decidim/participatory_processes/admin/copy_participatory_process.rb +9 -9
  7. data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +11 -0
  8. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb +4 -4
  9. data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +1 -0
  10. data/app/constraints/decidim/participatory_processes/{current_feature.rb → current_component.rb} +7 -7
  11. data/app/controllers/decidim/participatory_processes/admin/{feature_permissions_controller.rb → component_permissions_controller.rb} +2 -2
  12. data/app/controllers/decidim/participatory_processes/admin/{features_controller.rb → components_controller.rb} +2 -2
  13. data/app/controllers/decidim/participatory_processes/admin/participatory_space_private_users_controller.rb +25 -0
  14. data/app/controllers/decidim/participatory_processes/participatory_process_groups_controller.rb +5 -1
  15. data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +5 -3
  16. data/app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb +1 -1
  17. data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +3 -2
  18. data/app/models/decidim/participatory_process.rb +8 -2
  19. data/app/models/decidim/participatory_process_step.rb +1 -1
  20. data/app/models/decidim/participatory_processes/abilities/admin/admin_ability.rb +1 -0
  21. data/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb +9 -9
  22. data/app/queries/decidim/participatory_processes/organization_prioritized_participatory_processes.rb +3 -2
  23. data/app/queries/decidim/participatory_processes/organization_published_participatory_processes.rb +3 -1
  24. data/app/queries/decidim/participatory_processes/visible_participatory_processes.rb +22 -0
  25. data/app/types/decidim/participatory_processes/participatory_process_type.rb +4 -1
  26. data/app/views/decidim/participatory_process_groups/_participatory_process_group.html.erb +1 -1
  27. data/app/views/decidim/participatory_processes/_participatory_process.html.erb +4 -4
  28. data/app/views/decidim/participatory_processes/admin/participatory_process_copies/_form.html.erb +1 -1
  29. data/app/views/decidim/participatory_processes/admin/participatory_process_copies/new.html.erb +1 -1
  30. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/edit.html.erb +2 -2
  31. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/index.html.erb +3 -3
  32. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/new.html.erb +1 -1
  33. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/show.html.erb +1 -2
  34. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/edit.html.erb +1 -1
  35. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/index.html.erb +3 -3
  36. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/new.html.erb +1 -1
  37. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/show.html.erb +1 -2
  38. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/edit.html.erb +1 -1
  39. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/index.html.erb +1 -1
  40. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/new.html.erb +1 -1
  41. data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +4 -0
  42. data/app/views/decidim/participatory_processes/admin/participatory_processes/edit.html.erb +2 -3
  43. data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +12 -4
  44. data/app/views/decidim/participatory_processes/admin/participatory_processes/new.html.erb +1 -1
  45. data/app/views/decidim/participatory_processes/participatory_process_steps/_timeline.html.erb +1 -1
  46. data/app/views/decidim/participatory_processes/participatory_process_steps/index.html.erb +2 -2
  47. data/app/views/decidim/participatory_processes/participatory_process_widgets/show.html.erb +1 -1
  48. data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process.html.erb +1 -1
  49. data/app/views/decidim/participatory_processes/participatory_processes/_statistics.html.erb +1 -1
  50. data/app/views/decidim/participatory_processes/participatory_processes/index.html.erb +2 -2
  51. data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +6 -2
  52. data/app/views/layouts/decidim/_process_header.html.erb +13 -13
  53. data/app/views/layouts/decidim/_process_header_steps.html.erb +1 -1
  54. data/app/views/layouts/decidim/admin/participatory_process.html.erb +15 -10
  55. data/app/views/layouts/decidim/admin/participatory_process_groups.html.erb +1 -1
  56. data/app/views/layouts/decidim/admin/participatory_processes.html.erb +1 -1
  57. data/app/views/layouts/decidim/participatory_process.html.erb +2 -2
  58. data/config/locales/ca.yml +8 -2
  59. data/config/locales/en.yml +8 -2
  60. data/config/locales/es.yml +8 -2
  61. data/config/locales/eu.yml +8 -2
  62. data/config/locales/fi.yml +8 -2
  63. data/config/locales/fr.yml +13 -7
  64. data/config/locales/gl.yml +8 -2
  65. data/config/locales/it.yml +8 -2
  66. data/config/locales/nl.yml +58 -52
  67. data/config/locales/pl.yml +8 -2
  68. data/config/locales/pt-BR.yml +8 -2
  69. data/config/locales/pt.yml +8 -2
  70. data/config/locales/ru.yml +0 -2
  71. data/config/locales/sv.yml +8 -2
  72. data/config/locales/uk.yml +0 -2
  73. data/db/migrate/20170720120135_make_features_polymorphic.rb +8 -8
  74. data/db/migrate/20180122110007_add_private_to_participatory_processes.rb +7 -0
  75. data/lib/decidim/participatory_processes/admin_engine.rb +10 -5
  76. data/lib/decidim/participatory_processes/engine.rb +6 -6
  77. data/lib/decidim/participatory_processes/participatory_space.rb +1 -1
  78. data/lib/decidim/participatory_processes/test/factories.rb +4 -3
  79. data/lib/decidim/participatory_processes/version.rb +1 -1
  80. metadata +16 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0644d5ce5e841fc3f944e551e2667a8040bb5cb0c2d69be4361e3f20bf6b36c7
4
- data.tar.gz: 5a22b0939b8aef456ed004de6110e9ef9111a03f2c76fe9e210fc8f4b6e86cdd
3
+ metadata.gz: a8700942bf2a10ee7a919e159805a990fc3b32519ce665f59e8cb30ddbca87c2
4
+ data.tar.gz: '09d8769220a8d723b7aaf877622ce2595296b935656a196af07832bfbb6715fc'
5
5
  SHA512:
6
- metadata.gz: f2effee79a5f001a3e7e379b1dcc1f845e7d6e8c4109c301428993909cb93fe6ccf60a0fbd0e9f18a02f0e2c9b6474b850f30ddf07a173c390a036eca961699f
7
- data.tar.gz: fe91578cfe3cae5054324cdfc5e7099b119762490e0d3cd1cfc62db346e86407437d886ac894571cfbcfe143819aadf9f9688b431f6b85119f0c0a16833bed67
6
+ metadata.gz: a4ce8f1ab0e47c463329d9f23ded84f2a536e268f082eb530c8ca2b7d696fb4b7fd5cba4248446e76b5098aaa03ca7474aeb4d32758815d3aaf77111aaee5fe2
7
+ data.tar.gz: 275cde5c760c7428d87933123d63fe47998639e40c5423e1f47bfd4823ed47c65f22b868b3dfaba213d7fd9da8a946bc4896528be4a7e126d49917916faec79e
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Participatory processes are the standard Decidim's participatory space.
4
4
 
5
- A participatory process can define its own steps, and attach different features
5
+ A participatory process can define its own steps, and attach different components
6
6
  (such as meetings or proposals) with different configurations to each of them.
7
7
 
8
8
  A participatory process can have attachments, be associated to custom
@@ -1,14 +1,14 @@
1
1
  $(() => {
2
2
  ((exports) => {
3
- const $participatoryProcessScopeEnabled = $('#participatory_process_scopes_enabled');
3
+ const $participatoryProcessScopeEnabled = $("#participatory_process_scopes_enabled");
4
4
  const $participatoryProcessScopeId = $("#participatory_process_scope_id");
5
5
 
6
- if ($('.edit_participatory_process, .new_participatory_process').length > 0) {
7
- $participatoryProcessScopeEnabled.on('change', (event) => {
6
+ if ($(".edit_participatory_process, .new_participatory_process").length > 0) {
7
+ $participatoryProcessScopeEnabled.on("change", (event) => {
8
8
  const checked = event.target.checked;
9
9
  exports.theDataPicker.enabled($participatoryProcessScopeId, checked);
10
10
  })
11
- exports.theDataPicker.enabled($participatoryProcessScopeId, $participatoryProcessScopeEnabled.prop('checked'));
11
+ exports.theDataPicker.enabled($participatoryProcessScopeId, $participatoryProcessScopeEnabled.prop("checked"));
12
12
  }
13
13
  })(window);
14
14
  });
@@ -1,23 +1,23 @@
1
1
  $(() => {
2
2
  ((exports) => {
3
- const $processesGrid = $('#processes-grid');
4
- const $loading = $processesGrid.find('.loading');
5
- const filterLinksSelector = '.order-by__tabs a'
3
+ const $processesGrid = $("#processes-grid");
4
+ const $loading = $processesGrid.find(".loading");
5
+ const filterLinksSelector = ".order-by__tabs a"
6
6
 
7
7
  $loading.hide();
8
8
 
9
- $processesGrid.on('click', filterLinksSelector, (event) => {
9
+ $processesGrid.on("click", filterLinksSelector, (event) => {
10
10
  const $target = $(event.target);
11
- const $processesGridCards = $processesGrid.find('.card-grid .column');
11
+ const $processesGridCards = $processesGrid.find(".card-grid .column");
12
12
 
13
- $(filterLinksSelector).removeClass('is-active');
14
- $target.addClass('is-active');
13
+ $(filterLinksSelector).removeClass("is-active");
14
+ $target.addClass("is-active");
15
15
 
16
16
  $processesGridCards.hide();
17
17
  $loading.show();
18
18
 
19
19
  if (exports.history) {
20
- exports.history.pushState(null, null, $target.attr('href'));
20
+ exports.history.pushState(null, null, $target.attr("href"));
21
21
  }
22
22
  });
23
23
  })(window);
@@ -65,23 +65,23 @@ module Decidim
65
65
  end
66
66
 
67
67
  def publish_step_settings_change
68
- step.participatory_process.features.each do |feature|
68
+ step.participatory_process.components.each do |component|
69
69
  Decidim::SettingsChange.publish(
70
- feature,
71
- previous_step_settings(feature).to_h,
72
- current_step_settings(feature).to_h
70
+ component,
71
+ previous_step_settings(component).to_h,
72
+ current_step_settings(component).to_h
73
73
  )
74
74
  end
75
75
  end
76
76
 
77
- def current_step_settings(feature)
78
- feature.step_settings.fetch(step.id.to_s)
77
+ def current_step_settings(component)
78
+ component.step_settings.fetch(step.id.to_s)
79
79
  end
80
80
 
81
- def previous_step_settings(feature)
81
+ def previous_step_settings(component)
82
82
  return {} unless @previous_step
83
83
 
84
- feature.step_settings.fetch(@previous_step.id.to_s)
84
+ component.step_settings.fetch(@previous_step.id.to_s)
85
85
  end
86
86
  end
87
87
  end
@@ -28,7 +28,7 @@ module Decidim
28
28
  copy_participatory_process
29
29
  copy_participatory_process_steps if @form.copy_steps?
30
30
  copy_participatory_process_categories if @form.copy_categories?
31
- copy_participatory_process_features if @form.copy_features?
31
+ copy_participatory_process_components if @form.copy_components?
32
32
  end
33
33
 
34
34
  broadcast(:ok, @copied_process)
@@ -91,17 +91,17 @@ module Decidim
91
91
  end
92
92
  end
93
93
 
94
- def copy_participatory_process_features
95
- @participatory_process.features.each do |feature|
96
- copied_step_settings = @form.copy_steps? ? map_step_settings(feature.step_settings) : {}
97
- new_feature = Feature.create!(
98
- manifest_name: feature.manifest_name,
99
- name: feature.name,
94
+ def copy_participatory_process_components
95
+ @participatory_process.components.each do |component|
96
+ copied_step_settings = @form.copy_steps? ? map_step_settings(component.step_settings) : {}
97
+ new_component = Component.create!(
98
+ manifest_name: component.manifest_name,
99
+ name: component.name,
100
100
  participatory_space: @copied_process,
101
- settings: feature.settings,
101
+ settings: component.settings,
102
102
  step_settings: copied_step_settings
103
103
  )
104
- feature.manifest.run_hooks(:copy, new_feature: new_feature, old_feature: feature)
104
+ component.manifest.run_hooks(:copy, new_component: new_component, old_component: component)
105
105
  end
106
106
  end
107
107
 
@@ -51,6 +51,7 @@ module Decidim
51
51
  promoted: form.promoted,
52
52
  scopes_enabled: form.scopes_enabled,
53
53
  scope: form.scope,
54
+ private_space: form.private_space,
54
55
  developer_group: form.developer_group,
55
56
  local_area: form.local_area,
56
57
  target: form.target,
@@ -101,6 +102,16 @@ module Decidim
101
102
  Decidim::CreateFollow.new(form, admin).call
102
103
  end
103
104
  end
105
+
106
+ def create_participatory_process_users(process)
107
+ return unless form.private_process
108
+ form.users.each do |user|
109
+ ParticipatoryProcessUser.create!(
110
+ participatory_process: process,
111
+ user: user
112
+ )
113
+ end
114
+ end
104
115
  end
105
116
  end
106
117
  end
@@ -64,20 +64,20 @@ module Decidim
64
64
  end
65
65
 
66
66
  def existing_role
67
- Decidim::ParticipatoryProcessUserRole.where(
67
+ Decidim::ParticipatoryProcessUserRole.find_by(
68
68
  role: form.role.to_sym,
69
69
  user: user,
70
70
  participatory_process: @participatory_process
71
- ).first
71
+ )
72
72
  end
73
73
 
74
74
  def existing_user
75
75
  return @existing_user if defined?(@existing_user)
76
76
 
77
- @existing_user = User.where(
77
+ @existing_user = User.find_by(
78
78
  email: form.email,
79
79
  organization: participatory_process.organization
80
- ).first
80
+ )
81
81
 
82
82
  InviteUserAgain.call(@existing_user, invitation_instructions) if @existing_user && !@existing_user.invitation_accepted?
83
83
 
@@ -64,6 +64,7 @@ module Decidim
64
64
  short_description: form.short_description,
65
65
  scopes_enabled: form.scopes_enabled,
66
66
  scope: form.scope,
67
+ private_space: form.private_space,
67
68
  developer_group: form.developer_group,
68
69
  local_area: form.local_area,
69
70
  target: form.target,
@@ -2,26 +2,26 @@
2
2
 
3
3
  module Decidim
4
4
  module ParticipatoryProcesses
5
- # This class infers the current feature on a participatory process context
5
+ # This class infers the current component on a participatory process context
6
6
  # request parameters and injects it into the environment.
7
- class CurrentFeature
7
+ class CurrentComponent
8
8
  # Public: Initializes the class.
9
9
  #
10
- # manifest - The manifest of the feature to check against.
10
+ # manifest - The manifest of the component to check against.
11
11
  def initialize(manifest)
12
12
  @manifest = manifest
13
13
  end
14
14
 
15
- # Public: Matches the request against a feature and injects it into the
15
+ # Public: Matches the request against a component and injects it into the
16
16
  # environment.
17
17
  #
18
- # request - The request that holds the current feature relevant information.
18
+ # request - The request that holds the current component relevant information.
19
19
  #
20
20
  # Returns a true if the request matches a participatory process and a
21
- # feature belonging to that participatory process, false otherwise
21
+ # component belonging to that participatory process, false otherwise
22
22
  def matches?(request)
23
23
  CurrentParticipatoryProcess.new.matches?(request) &&
24
- Decidim::CurrentFeature.new(@manifest).matches?(request)
24
+ Decidim::CurrentComponent.new(@manifest).matches?(request)
25
25
  end
26
26
  end
27
27
  end
@@ -3,10 +3,10 @@
3
3
  module Decidim
4
4
  module ParticipatoryProcesses
5
5
  module Admin
6
- # Controller that allows managing the Participatory Process' Feature
6
+ # Controller that allows managing the Participatory Process' Component
7
7
  # permissions in the admin panel.
8
8
  #
9
- class FeaturePermissionsController < Decidim::Admin::FeaturePermissionsController
9
+ class ComponentPermissionsController < Decidim::Admin::ComponentPermissionsController
10
10
  include Concerns::ParticipatoryProcessAdmin
11
11
  end
12
12
  end
@@ -3,10 +3,10 @@
3
3
  module Decidim
4
4
  module ParticipatoryProcesses
5
5
  module Admin
6
- # Controller that allows managing the Participatory Process' Features in the
6
+ # Controller that allows managing the Participatory Process' Components in the
7
7
  # admin panel.
8
8
  #
9
- class FeaturesController < Decidim::Admin::FeaturesController
9
+ class ComponentsController < Decidim::Admin::ComponentsController
10
10
  include Concerns::ParticipatoryProcessAdmin
11
11
  end
12
12
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ module Admin
6
+ # Controller that allows managing participatory process privte users
7
+ class ParticipatorySpacePrivateUsersController < Decidim::Admin::ApplicationController
8
+ include Concerns::ParticipatoryProcessAdmin
9
+ include Decidim::Admin::Concerns::HasPrivateUsers
10
+
11
+ def after_destroy_path
12
+ participatory_space_private_users_path(current_participatory_process)
13
+ end
14
+
15
+ def privatable_to
16
+ current_participatory_process
17
+ end
18
+
19
+ def authorization_object
20
+ @participatory_space_private_user || ParticipatorySpacePrivateUser
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -15,7 +15,11 @@ module Decidim
15
15
  private
16
16
 
17
17
  def participatory_processes
18
- @participatory_processes ||= group.participatory_processes.published
18
+ @participatory_processes ||= if current_user
19
+ group.participatory_processes.visible_for(current_user.id).published
20
+ else
21
+ group.participatory_processes.published
22
+ end
19
23
  end
20
24
  alias collection participatory_processes
21
25
 
@@ -25,7 +25,9 @@ module Decidim
25
25
  authorize! :read, ParticipatoryProcessGroup
26
26
  end
27
27
 
28
- def show; end
28
+ def show
29
+ check_current_user_can_visit_space
30
+ end
29
31
 
30
32
  private
31
33
 
@@ -42,7 +44,7 @@ module Decidim
42
44
  end
43
45
 
44
46
  def published_processes
45
- @published_processes ||= OrganizationPublishedParticipatoryProcesses.new(current_organization)
47
+ @published_processes ||= OrganizationPublishedParticipatoryProcesses.new(current_organization, current_user)
46
48
  end
47
49
 
48
50
  def collection
@@ -50,7 +52,7 @@ module Decidim
50
52
  end
51
53
 
52
54
  def filtered_participatory_processes(filter = default_filter)
53
- OrganizationPrioritizedParticipatoryProcesses.new(current_organization, filter)
55
+ OrganizationPrioritizedParticipatoryProcesses.new(current_organization, filter, current_user)
54
56
  end
55
57
 
56
58
  def participatory_processes
@@ -16,7 +16,7 @@ module Decidim
16
16
  attribute :slug, String
17
17
  attribute :copy_steps, Boolean
18
18
  attribute :copy_categories, Boolean
19
- attribute :copy_features, Boolean
19
+ attribute :copy_components, Boolean
20
20
 
21
21
  validates :slug, presence: true, format: { with: Decidim::ParticipatoryProcess.slug_format }
22
22
  validates :title, translatable_presence: true
@@ -36,6 +36,7 @@ module Decidim
36
36
  attribute :remove_banner_image
37
37
  attribute :participatory_process_group_id, Integer
38
38
  attribute :show_statistics, Boolean
39
+ attribute :private_space, Boolean
39
40
 
40
41
  validates :slug, presence: true, format: { with: Decidim::ParticipatoryProcess.slug_format }
41
42
  validates :title, :subtitle, :description, :short_description, translatable_presence: true
@@ -52,11 +53,11 @@ module Decidim
52
53
  end
53
54
 
54
55
  def scope
55
- @scope ||= current_organization.scopes.where(id: scope_id).first
56
+ @scope ||= current_organization.scopes.find_by(id: scope_id)
56
57
  end
57
58
 
58
59
  def participatory_process_group
59
- Decidim::ParticipatoryProcessGroup.where(id: participatory_process_group_id).first
60
+ Decidim::ParticipatoryProcessGroup.find_by(id: participatory_process_group_id)
60
61
  end
61
62
 
62
63
  private
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  # Interaction between a user and an organization is done via a
5
5
  # ParticipatoryProcess. It's a unit of action from the Organization point of
6
- # view that groups several features (proposals, debates...) distributed in
6
+ # view that groups several components (proposals, debates...) distributed in
7
7
  # steps that get enabled or disabled depending on which step is currently
8
8
  # active.
9
9
  class ParticipatoryProcess < ApplicationRecord
@@ -15,7 +15,9 @@ module Decidim
15
15
  include Decidim::Followable
16
16
  include Decidim::HasReference
17
17
  include Decidim::Traceable
18
+ include Decidim::HasPrivateUsers
18
19
  include Decidim::Loggable
20
+ include Decidim::ParticipatorySpaceResourceable
19
21
 
20
22
  belongs_to :organization,
21
23
  foreign_key: "decidim_organization_id",
@@ -43,7 +45,7 @@ module Decidim
43
45
  dependent: :destroy,
44
46
  as: :participatory_space
45
47
 
46
- has_many :features, as: :participatory_space, dependent: :destroy
48
+ has_many :components, as: :participatory_space, dependent: :destroy
47
49
 
48
50
  attr_readonly :active_step
49
51
 
@@ -75,5 +77,9 @@ module Decidim
75
77
  def to_param
76
78
  slug
77
79
  end
80
+
81
+ def self.private_processes
82
+ where(private_space: true)
83
+ end
78
84
  end
79
85
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  # A ParticipatoryProcess is composed of many steps that hold different
5
- # features that will show up in the depending on what step is currently
5
+ # components that will show up in the depending on what step is currently
6
6
  # active.
7
7
  class ParticipatoryProcessStep < ApplicationRecord
8
8
  include Traceable
@@ -13,6 +13,7 @@ module Decidim
13
13
  can :manage, ParticipatoryProcess
14
14
  can :manage, ParticipatoryProcessGroup
15
15
  can :manage, ParticipatoryProcessStep
16
+ can :manage, Decidim::ParticipatorySpacePrivateUser
16
17
  end
17
18
  end
18
19
  end
@@ -9,8 +9,8 @@ module Decidim
9
9
 
10
10
  # Public: Render a collection of primary stats.
11
11
  def highlighted
12
- highlighted_stats = feature_stats(priority: StatsRegistry::HIGH_PRIORITY)
13
- highlighted_stats = highlighted_stats.concat(feature_stats(priority: StatsRegistry::MEDIUM_PRIORITY))
12
+ highlighted_stats = component_stats(priority: StatsRegistry::HIGH_PRIORITY)
13
+ highlighted_stats = highlighted_stats.concat(component_stats(priority: StatsRegistry::MEDIUM_PRIORITY))
14
14
  highlighted_stats = highlighted_stats.reject(&:empty?)
15
15
  highlighted_stats = highlighted_stats.reject { |_manifest, _name, data| data.zero? }
16
16
  grouped_highlighted_stats = highlighted_stats.group_by { |stats| stats.first.name }
@@ -30,22 +30,22 @@ module Decidim
30
30
 
31
31
  private
32
32
 
33
- def feature_stats(conditions)
34
- Decidim.feature_manifests.map do |feature_manifest|
35
- feature_manifest.stats.filter(conditions).with_context(published_features).map { |name, data| [feature_manifest, name, data] }.flatten
33
+ def component_stats(conditions)
34
+ Decidim.component_manifests.map do |component_manifest|
35
+ component_manifest.stats.filter(conditions).with_context(published_components).map { |name, data| [component_manifest, name, data] }.flatten
36
36
  end
37
37
  end
38
38
 
39
- def render_stats_data(feature_manifest, name, data, index)
39
+ def render_stats_data(component_manifest, name, data, index)
40
40
  safe_join([
41
- index.zero? ? manifest_icon(feature_manifest) : " /&nbsp".html_safe,
41
+ index.zero? ? manifest_icon(component_manifest) : " /&nbsp".html_safe,
42
42
  content_tag(:span, "#{number_with_delimiter(data)} " + I18n.t(name, scope: "decidim.participatory_processes.statistics"),
43
43
  class: "#{name} process_stats-text")
44
44
  ])
45
45
  end
46
46
 
47
- def published_features
48
- @published_features ||= Feature.where(participatory_space: participatory_process).published
47
+ def published_components
48
+ @published_components ||= Component.where(participatory_space: participatory_process).published
49
49
  end
50
50
  end
51
51
  end
@@ -5,14 +5,15 @@ module Decidim
5
5
  # This query class filters public processes given an organization and a
6
6
  # filter in a meaningful prioritized order.
7
7
  class OrganizationPrioritizedParticipatoryProcesses < Rectify::Query
8
- def initialize(organization, filter = "active")
8
+ def initialize(organization, filter = "active", user = nil)
9
9
  @organization = organization
10
10
  @filter = filter
11
+ @user = user
11
12
  end
12
13
 
13
14
  def query
14
15
  Rectify::Query.merge(
15
- OrganizationPublishedParticipatoryProcesses.new(@organization),
16
+ OrganizationPublishedParticipatoryProcesses.new(@organization, @user),
16
17
  PrioritizedParticipatoryProcesses.new,
17
18
  FilteredParticipatoryProcesses.new(@filter)
18
19
  ).query
@@ -4,13 +4,15 @@ module Decidim
4
4
  module ParticipatoryProcesses
5
5
  # This query class filters published processes given an organization.
6
6
  class OrganizationPublishedParticipatoryProcesses < Rectify::Query
7
- def initialize(organization)
7
+ def initialize(organization, user = nil)
8
8
  @organization = organization
9
+ @user = user
9
10
  end
10
11
 
11
12
  def query
12
13
  Rectify::Query.merge(
13
14
  OrganizationParticipatoryProcesses.new(@organization),
15
+ VisibleParticipatoryProcesses.new(@user),
14
16
  PublishedParticipatoryProcesses.new
15
17
  ).query
16
18
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # This query class filters participatory processes given a current_user.
6
+ class VisibleParticipatoryProcesses < Rectify::Query
7
+ def initialize(current_user)
8
+ @current_user = current_user
9
+ end
10
+
11
+ def query
12
+ processes = Decidim::ParticipatoryProcess.all
13
+
14
+ if @current_user
15
+ processes.visible_for(@current_user.id)
16
+ else
17
+ processes.public_spaces
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -4,7 +4,10 @@ module Decidim
4
4
  module ParticipatoryProcesses
5
5
  # This type represents a ParticipatoryProcess.
6
6
  ParticipatoryProcessType = GraphQL::ObjectType.define do
7
- interfaces [Decidim::Core::ParticipatorySpaceInterface]
7
+ interfaces [
8
+ Decidim::Core::ParticipatorySpaceInterface,
9
+ Decidim::Core::AttachableInterface
10
+ ]
8
11
 
9
12
  name "ParticipatoryProcess"
10
13
  description "A participatory process"
@@ -8,7 +8,7 @@
8
8
  <%= link_to participatory_process_group_path(participatory_process_group), class: "card__link" do %>
9
9
  <h4 class="card__title"><%= translated_attribute participatory_process_group.name %></h4>
10
10
  <% end %>
11
- <p class="card__desc"><%= sanitize html_truncate(translated_attribute(participatory_process_group.description), length: 630, separator: '...') %></p>
11
+ <p class="card__desc"><%= sanitize html_truncate(translated_attribute(participatory_process_group.description), length: 630, separator: "...") %></p>
12
12
  </div>
13
13
  <div class="card__footer">
14
14
  <div class="card__support">
@@ -1,14 +1,14 @@
1
1
  <div class="column">
2
2
  <article class="card card--process">
3
- <%= link_to participatory_process_path(participatory_process), class: "card__link" do %>
3
+ <%= link_to decidim_participatory_processes.participatory_process_path(participatory_process), class: "card__link" do %>
4
4
  <div class="card__image-top"
5
5
  style="background-image:url(<%= participatory_process.hero_image.url %>)"></div>
6
6
  <% end %>
7
7
  <div class="card__content">
8
- <%= link_to participatory_process_path(participatory_process), class: "card__link" do %>
8
+ <%= link_to decidim_participatory_processes.participatory_process_path(participatory_process), class: "card__link" do %>
9
9
  <h4 class="card__title"><%= translated_attribute participatory_process.title %></h4>
10
10
  <% end %>
11
- <p class="card__desc"><%= decidim_sanitize html_truncate(translated_attribute(participatory_process.short_description), length: 630, separator: '...') %></p>
11
+ <p class="card__desc"><%= decidim_sanitize html_truncate(translated_attribute(participatory_process.short_description), length: 630, separator: "...") %></p>
12
12
  </div>
13
13
  <div class="card__footer">
14
14
  <div class="card__support">
@@ -19,7 +19,7 @@
19
19
  </span>
20
20
  <% end %>
21
21
  <span class="card--process__small"></span>
22
- <%= link_to participatory_process_path(participatory_process), class: "card__button button small" do %>
22
+ <%= link_to decidim_participatory_processes.participatory_process_path(participatory_process), class: "card__button button small" do %>
23
23
  <%= t("participatory_processes.participatory_process.take_part", scope: "layouts.decidim") %>
24
24
  <% end %>
25
25
  </div>
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
 
33
33
  <div class="columns xlarge-6">
34
- <%= form.check_box :copy_features %>
34
+ <%= form.check_box :copy_components %>
35
35
  </div>
36
36
  </div>
37
37
  </div>
@@ -1,5 +1,5 @@
1
1
  <%= decidim_form_for(@form, url: participatory_process_copies_path(current_participatory_process), method: :post, html: { class: "form copy_participatory_process" }) do |f| %>
2
- <%= 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")} %>
2
+ <%= 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
3
 
4
4
  <div class="button--double form-general-submit">
5
5
  <%= f.submit t("participatory_process_copies.new.copy", scope: "decidim.admin") %>
@@ -5,12 +5,12 @@
5
5
  <h2 class="card-title">
6
6
  <%= t "participatory_process_groups.edit.title", scope: "decidim.admin" %>
7
7
  <% if can? :destroy, participatory_process_group %>
8
- <%= link_to t("decidim.admin.actions.destroy"), participatory_process_group, method: :delete, class: 'button alert tiny button--title destroy', data: { confirm: t("decidim.admin.actions.confirm_destroy") } %>
8
+ <%= link_to t("decidim.admin.actions.destroy"), participatory_process_group, method: :delete, class: "button alert tiny button--title destroy", data: { confirm: t("decidim.admin.actions.confirm_destroy") } %>
9
9
  <% end %>
10
10
  </h2>
11
11
  </div>
12
12
  <div class="card-section">
13
- <%= render partial: 'form', object: f %>
13
+ <%= render partial: "form", object: f %>
14
14
  </div>
15
15
  </div>
16
16
  <div class="button--double form-general-submit">