decidim-accountability 0.31.9 → 0.32.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -16
  3. data/app/cells/decidim/accountability/result_metadata/{project_aside.erb → result_aside.erb} +1 -1
  4. data/app/cells/decidim/accountability/result_metadata_cell.rb +1 -1
  5. data/app/cells/decidim/accountability/{project → result_show}/milestones.erb +4 -4
  6. data/app/cells/decidim/accountability/{project_cell.rb → result_show_cell.rb} +4 -3
  7. data/app/cells/decidim/accountability/status_cell.rb +1 -5
  8. data/app/commands/decidim/accountability/admin/import_component_to_accountability.rb +1 -1
  9. data/app/commands/decidim/accountability/admin/update_result_dates.rb +3 -5
  10. data/app/commands/decidim/accountability/admin/update_result_status.rb +4 -6
  11. data/app/commands/decidim/accountability/admin/update_result_taxonomies.rb +2 -13
  12. data/app/controllers/concerns/decidim/accountability/admin/filterable.rb +1 -5
  13. data/app/controllers/decidim/accountability/admin/attachment_collections_controller.rb +0 -2
  14. data/app/controllers/decidim/accountability/admin/attachments_controller.rb +0 -2
  15. data/app/controllers/decidim/accountability/admin/import_components_controller.rb +3 -5
  16. data/app/controllers/decidim/accountability/admin/import_results_controller.rb +9 -5
  17. data/app/controllers/decidim/accountability/admin/milestones_controller.rb +2 -2
  18. data/app/controllers/decidim/accountability/admin/results_bulk_actions_controller.rb +9 -9
  19. data/app/controllers/decidim/accountability/admin/results_controller.rb +7 -9
  20. data/app/controllers/decidim/accountability/admin/statuses_controller.rb +15 -3
  21. data/app/controllers/decidim/accountability/results_controller.rb +18 -23
  22. data/app/controllers/decidim/accountability/versions_controller.rb +12 -2
  23. data/app/forms/decidim/accountability/admin/status_form.rb +0 -1
  24. data/app/helpers/decidim/accountability/breadcrumb_helper.rb +0 -4
  25. data/app/helpers/decidim/accountability/calculator_helper.rb +16 -0
  26. data/app/mailers/decidim/accountability/import_projects_mailer.rb +3 -2
  27. data/app/mailers/decidim/accountability/import_proposals_mailer.rb +1 -0
  28. data/app/models/decidim/accountability/result.rb +9 -7
  29. data/app/models/decidim/accountability/status.rb +5 -2
  30. data/app/packs/stylesheets/accountability.scss +2 -2
  31. data/app/permissions/decidim/accountability/permissions.rb +1 -1
  32. data/app/views/decidim/accountability/admin/import_components/new.html.erb +1 -1
  33. data/app/views/decidim/accountability/admin/import_results/new.html.erb +1 -1
  34. data/app/views/decidim/accountability/admin/results/_actions.html.erb +1 -1
  35. data/app/views/decidim/accountability/admin/results/_form.html.erb +3 -5
  36. data/app/views/decidim/accountability/admin/results/_result-tr.html.erb +1 -4
  37. data/app/views/decidim/accountability/admin/results/_results-thead.html.erb +0 -3
  38. data/app/views/decidim/accountability/admin/results/bulk_actions/_dropdown.html.erb +5 -7
  39. data/app/views/decidim/accountability/admin/statuses/index.html.erb +3 -3
  40. data/app/views/decidim/accountability/results/_home_taxonomies.html.erb +2 -2
  41. data/app/views/decidim/accountability/results/{_project.html.erb → _result.html.erb} +4 -4
  42. data/app/views/decidim/accountability/results/index.html.erb +1 -1
  43. data/app/views/decidim/accountability/results/show.html.erb +1 -1
  44. data/config/locales/ar.yml +1 -2
  45. data/config/locales/bg.yml +1 -2
  46. data/config/locales/bs-BA.yml +0 -1
  47. data/config/locales/ca-IT.yml +2 -3
  48. data/config/locales/ca.yml +2 -3
  49. data/config/locales/cs.yml +1 -3
  50. data/config/locales/da.yml +1 -1
  51. data/config/locales/de.yml +2 -3
  52. data/config/locales/el.yml +2 -2
  53. data/config/locales/en.yml +2 -2
  54. data/config/locales/es-MX.yml +3 -4
  55. data/config/locales/es-PY.yml +3 -4
  56. data/config/locales/es.yml +2 -3
  57. data/config/locales/eu.yml +35 -36
  58. data/config/locales/fi-plain.yml +1 -2
  59. data/config/locales/fi.yml +1 -2
  60. data/config/locales/fr-CA.yml +2 -3
  61. data/config/locales/fr.yml +2 -3
  62. data/config/locales/ga-IE.yml +0 -2
  63. data/config/locales/gl.yml +3 -229
  64. data/config/locales/gn-PY.yml +0 -1
  65. data/config/locales/he-IL.yml +4 -2
  66. data/config/locales/hu.yml +1 -2
  67. data/config/locales/id-ID.yml +0 -1
  68. data/config/locales/is-IS.yml +1 -3
  69. data/config/locales/it.yml +1 -2
  70. data/config/locales/ja.yml +2 -3
  71. data/config/locales/kaa.yml +0 -1
  72. data/config/locales/ko.yml +1 -2
  73. data/config/locales/lb.yml +1 -2
  74. data/config/locales/lt.yml +1 -2
  75. data/config/locales/lv.yml +0 -1
  76. data/config/locales/nl.yml +1 -2
  77. data/config/locales/no.yml +1 -2
  78. data/config/locales/pl.yml +1 -5
  79. data/config/locales/pt-BR.yml +2 -2
  80. data/config/locales/pt.yml +1 -2
  81. data/config/locales/ro-RO.yml +2 -2
  82. data/config/locales/ru.yml +0 -234
  83. data/config/locales/si-LK.yml +0 -1
  84. data/config/locales/sk.yml +2 -253
  85. data/config/locales/sl.yml +0 -1
  86. data/config/locales/sq-AL.yml +1 -2
  87. data/config/locales/sr-CS.yml +0 -1
  88. data/config/locales/sv.yml +2 -3
  89. data/config/locales/th-TH.yml +1 -1
  90. data/config/locales/tr-TR.yml +2 -2
  91. data/config/locales/uk.yml +0 -1
  92. data/config/locales/zh-CN.yml +1 -1
  93. data/config/locales/zh-TW.yml +1 -2
  94. data/db/data/20260113140600_reindex_results.rb +13 -0
  95. data/decidim-accountability.gemspec +12 -15
  96. data/lib/decidim/accountability/component.rb +14 -6
  97. data/lib/decidim/accountability/seeds.rb +2 -2
  98. data/lib/decidim/accountability/version.rb +1 -1
  99. data/lib/decidim/api/accountability_type.rb +14 -2
  100. metadata +30 -32
  101. data/app/views/decidim/accountability/results/index.js.erb +0 -5
  102. /data/app/cells/decidim/accountability/{project → result_show}/show.erb +0 -0
  103. /data/app/views/decidim/accountability/results/{_projects_aside.html.erb → _results_aside.html.erb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86abd79466e93ebed7b4c3be0246ca72d17d525dfde7d9319fb8504010fb2870
4
- data.tar.gz: 3f1bb65d1011bc0ef041f170b09864367000828b6b8e888bbd3d36b62ee08d2c
3
+ metadata.gz: b11b03399049993a09e10d946a0963a2f79405496523bdb1b2392e52fab4c9fd
4
+ data.tar.gz: e9a3872042ae120dcd2d34acfdddd1fa96303b041661fe139428093d6915fdc5
5
5
  SHA512:
6
- metadata.gz: 19429f8ba078b38902ecce2f2326faa55a840ab6191c16944d5ad10f8500f1a663e16e221764fb62d8daa07e01e41a66d43f531d3ca43acb24d505720008701b
7
- data.tar.gz: 9b01767b731e102920082ba77d5ab33c0b17777fbd001fae1c86ba2fb3594d54395fb1b20fab7ce9f445fcafab05e47862ea72cd2d1230f1e01e1dde7374180e
6
+ metadata.gz: d92038bd1cbc613f975a6106d0f289c797faf1d3bc3725d4a1343bded0a5f39c80fbd64de70191059819b169af3b3446478be3189668a827ee8cd3b9646aa049
7
+ data.tar.gz: 85e75f6e3ba8b8f09f87c4d24aaa27a11d1a9891ba5ce4e2a38b77593130d7f8cbab98ded6deb29e146fa6ab72c8c8e1ecc345473bb45f4a90ec0c2564944b9f
data/README.md CHANGED
@@ -1,29 +1,19 @@
1
- # Decidim::Accountability
1
+ # decidim-accountability
2
2
 
3
- The Accountability module adds results to any participatory process. It adds a CRUD engine to the admin and public views scoped inside the participatory process. Accountability will link to related meetings and proposals and will be used to show the progress on the related proposals.
3
+ The Accountability module adds results to any participatory space. It adds a CRUD engine to the admin and public views scoped inside the participatory space. Accountability will link to related meetings and proposals and will be used to show the progress on the related proposals.
4
4
 
5
5
  ## Usage
6
6
 
7
- Accountability will be available as a Component for a Participatory Process.
7
+ Accountability will be available as a Component for a Participatory Space.
8
8
 
9
9
  ## Installation
10
10
 
11
- Add this line to your application's Gemfile:
12
-
13
- ```ruby
14
- gem 'decidim-accountability'
15
- ```
16
-
17
- And then execute:
18
-
19
- ```bash
20
- bundle
21
- ```
11
+ This is on the default Decidim installation so you should not change anything to use this component.
22
12
 
23
13
  ## Contributing
24
14
 
25
- See [Decidim](https://github.com/AjuntamentdeBarcelona/decidim).
15
+ See [Decidim](https://github.com/decidim/decidim).
26
16
 
27
17
  ## License
28
18
 
29
- See [Decidim](https://github.com/AjuntamentdeBarcelona/decidim).
19
+ See [Decidim](https://github.com/decidim/decidim).
@@ -1,5 +1,5 @@
1
1
  <% items.each do |item| %>
2
- <div class="accountability__project-aside-item">
2
+ <div class="accountability__result-aside-item">
3
3
  <div><%= icon item[:icon], class: "w-3.5 h-3.5 fill-current text-gray" %><%= item[:text] %></div>
4
4
  <div><%= item[:value] %></div>
5
5
  </div>
@@ -23,7 +23,7 @@ module Decidim
23
23
  private
24
24
 
25
25
  def result_items
26
- return [dates_item, status_item, status_description] if template == :project_aside
26
+ return [dates_item, status_item, status_description] if template == :result_aside
27
27
  return [reference, versions] if template == :show_footer
28
28
 
29
29
  [dates_item_compact, status_item_compact] + taxonomy_items
@@ -1,10 +1,10 @@
1
- <ol class="accountability__project-milestones">
1
+ <ol class="accountability__result-milestones">
2
2
  <% milestones.each_with_index do |milestone, i| %>
3
- <li class="accountability__project-milestones-milestone">
4
- <div class="accountability__project-milestones-milestone-number">
3
+ <li class="accountability__result-milestones-milestone">
4
+ <div class="accountability__result-milestones-milestone-number">
5
5
  <span><%= i + 1 %></span>
6
6
  </div>
7
- <div class="accountability__project-milestones-milestone-attributes">
7
+ <div class="accountability__result-milestones-milestone-attributes">
8
8
  <h3>
9
9
  <%= decidim_sanitize_translated milestone.title %>
10
10
  </h3>
@@ -4,10 +4,11 @@ require "cell/partial"
4
4
 
5
5
  module Decidim
6
6
  module Accountability
7
- # This cell renders a project
8
- class ProjectCell < Decidim::ViewModel
7
+ # This cell renders a result
8
+ class ResultShowCell < Decidim::ViewModel
9
9
  include Decidim::Accountability::ApplicationHelper
10
10
  include Cell::ViewModel::Partial
11
+
11
12
  delegate :children, :milestones, to: :model
12
13
 
13
14
  alias result model
@@ -24,7 +25,7 @@ module Decidim
24
25
  text: t("decidim.accountability.results.milestones.title"),
25
26
  icon: "route-line",
26
27
  method: :cell,
27
- args: ["decidim/accountability/project", result, { template: :milestones }]
28
+ args: ["decidim/accountability/result_show", result, { template: :milestones }]
28
29
  },
29
30
  {
30
31
  enabled: ResultHistoryCell.new(result).render?,
@@ -7,7 +7,7 @@ module Decidim
7
7
  # This cell renders the status of a taxonomy or a result.
8
8
  class StatusCell < Decidim::ViewModel
9
9
  include Decidim::Accountability::ApplicationHelper
10
- include Decidim::Accountability::BreadcrumbHelper
10
+ include Decidim::Accountability::CalculatorHelper
11
11
  include ActionView::Helpers::NumberHelper
12
12
 
13
13
  def show
@@ -80,10 +80,6 @@ module Decidim
80
80
  options[:render_count]
81
81
  end
82
82
 
83
- def count_calculator(taxonomy_id)
84
- Decidim::Accountability::ResultsCalculator.new(current_component, taxonomy_id).count
85
- end
86
-
87
83
  def decidim
88
84
  Decidim::Accountability::Engine.routes.url_helpers
89
85
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Accountability
5
5
  module Admin
6
- # A command with all the business logic when an admin imports projects from
6
+ # A command with all the business logic when an admin imports results from
7
7
  # one component to accountability.
8
8
  class ImportComponentToAccountability < Decidim::Command
9
9
  attr_reader :form
@@ -10,13 +10,11 @@ module Decidim
10
10
  # start_date - the start date to update
11
11
  # end_date - the end date to update
12
12
  # result_ids - the results ids to update
13
- # current_component - the component where the results belong to
14
13
  # current_user - the user performing the action
15
- def initialize(start_date, end_date, result_ids, current_component, current_user)
14
+ def initialize(start_date, end_date, result_ids, current_user)
16
15
  @start_date = start_date
17
16
  @end_date = end_date
18
17
  @result_ids = result_ids
19
- @current_component = current_component
20
18
  @current_user = current_user
21
19
  end
22
20
 
@@ -36,10 +34,10 @@ module Decidim
36
34
 
37
35
  private
38
36
 
39
- attr_reader :start_date, :end_date, :result_ids, :current_component, :current_user
37
+ attr_reader :start_date, :end_date, :result_ids, :current_user
40
38
 
41
39
  def update_results_dates
42
- Decidim::Accountability::Result.where(component: current_component, id: result_ids).find_each do |result|
40
+ Decidim::Accountability::Result.where(id: result_ids).find_each do |result|
43
41
  next if result.start_date == start_date && result.end_date == end_date
44
42
 
45
43
  result.update!(start_date:, end_date:)
@@ -9,12 +9,10 @@ module Decidim
9
9
  #
10
10
  # status_id - the status id to update
11
11
  # result_ids - the results ids to update
12
- # current_component - the component where the results belong to
13
12
  # current_user - the user performing the action
14
- def initialize(status_id, result_ids, current_component, current_user)
13
+ def initialize(status_id, result_ids, current_user)
15
14
  @status_id = status_id
16
15
  @result_ids = result_ids
17
- @current_component = current_component
18
16
  @current_user = current_user
19
17
  end
20
18
 
@@ -34,13 +32,13 @@ module Decidim
34
32
 
35
33
  private
36
34
 
37
- attr_reader :status_id, :result_ids, :current_component, :current_user
35
+ attr_reader :status_id, :result_ids, :current_user
38
36
 
39
37
  def update_results_status
40
- Decidim::Accountability::Result.where(component: current_component, id: result_ids).find_each do |result|
38
+ Decidim::Accountability::Result.where(id: result_ids).find_each do |result|
41
39
  next if result.decidim_accountability_status_id == status_id
42
40
 
43
- status = Decidim::Accountability::Status.where(component: current_component, id: status_id).first
41
+ status = Decidim::Accountability::Status.find_by(id: status_id)
44
42
 
45
43
  next if status.blank?
46
44
 
@@ -9,19 +9,8 @@ module Decidim
9
9
  #
10
10
  # taxonomy_ids - the taxonomy ids to update
11
11
  # result_ids - the results ids to update.
12
- # current_component - the component where the results belong to.
13
- def initialize(taxonomy_ids, result_ids, current_component)
14
- @result_ids = result_ids
15
- @current_component = current_component
16
- super(taxonomy_ids, results, current_component.organization)
17
- end
18
-
19
- private
20
-
21
- attr_reader :result_ids, :current_component
22
-
23
- def results
24
- Decidim::Accountability::Result.where(component: current_component, id: result_ids)
12
+ def initialize(taxonomy_ids, result_ids, organization)
13
+ super(taxonomy_ids, Decidim::Accountability::Result.where(id: result_ids), organization)
25
14
  end
26
15
  end
27
16
  end
@@ -23,10 +23,6 @@ module Decidim
23
23
  collection.includes(:taxonomies).joins(:taxonomies)
24
24
  end
25
25
 
26
- def search_field_predicate
27
- :id_string_or_title_cont
28
- end
29
-
30
26
  def filters
31
27
  [
32
28
  :taxonomies_part_of_contains,
@@ -48,7 +44,7 @@ module Decidim
48
44
  end
49
45
 
50
46
  def status_ids_hash(statuses)
51
- statuses.each_with_object({}) { |status, hash| hash[status.id] = status.id }
47
+ statuses.to_h { |status| [status.id, status.id] }
52
48
  end
53
49
 
54
50
  def translated_status_id_eq(id)
@@ -9,8 +9,6 @@ module Decidim
9
9
  class AttachmentCollectionsController < Admin::ApplicationController
10
10
  include Decidim::Admin::Concerns::HasAttachmentCollections
11
11
 
12
- protected
13
-
14
12
  def after_destroy_path
15
13
  result_attachment_collections_path(result, result.component, current_participatory_space)
16
14
  end
@@ -9,8 +9,6 @@ module Decidim
9
9
  class AttachmentsController < Admin::ApplicationController
10
10
  include Decidim::Admin::Concerns::HasAttachments
11
11
 
12
- protected
13
-
14
12
  def after_destroy_path
15
13
  results_path
16
14
  end
@@ -15,20 +15,18 @@ module Decidim
15
15
  @form = form(Admin::ImportComponentForm).from_params(params, accountability_component: current_component)
16
16
 
17
17
  ImportComponentToAccountability.call(@form) do
18
- on(:ok) do |projects|
19
- flash[:notice] = I18n.t("import_components.new.success", scope: "decidim.accountability.admin", count: projects)
18
+ on(:ok) do |results|
19
+ flash[:notice] = I18n.t("import_components.new.success", scope: "decidim.accountability.admin", count: results)
20
20
  redirect_to results_path
21
21
  end
22
22
 
23
23
  on(:invalid) do
24
24
  flash[:alert] = I18n.t("import_components.create.invalid", scope: "decidim.accountability.admin")
25
- render action: "new", status: :unprocessable_entity
25
+ render action: "new", status: :unprocessable_content
26
26
  end
27
27
  end
28
28
  end
29
29
 
30
- protected
31
-
32
30
  def results_import_params
33
31
  params[:results_import] || {}
34
32
  end
@@ -5,15 +5,13 @@ module Decidim
5
5
  module Admin
6
6
  # This controller allows an admin to import results from a csv file for the Accountability component
7
7
  class ImportResultsController < Admin::ApplicationController
8
- def new
9
- enforce_permission_to :create, :result
8
+ before_action :ensure_permissions
10
9
 
10
+ def new
11
11
  @form = form(Admin::ImportResultsForm).instance
12
12
  end
13
13
 
14
14
  def create
15
- enforce_permission_to :create, :result
16
-
17
15
  @form = form(Admin::ImportResultsForm).from_params(params, current_component:)
18
16
 
19
17
  if @form.valid?
@@ -23,9 +21,15 @@ module Decidim
23
21
  redirect_to import_results_path(current_participatory_space, current_component)
24
22
  else
25
23
  flash[:alert] = I18n.t("imports.create.invalid", scope: "decidim.accountability.admin")
26
- render action: "new", status: :unprocessable_entity
24
+ render action: "new", status: :unprocessable_content
27
25
  end
28
26
  end
27
+
28
+ private
29
+
30
+ def ensure_permissions
31
+ enforce_permission_to :create, :result
32
+ end
29
33
  end
30
34
  end
31
35
  end
@@ -27,7 +27,7 @@ module Decidim
27
27
 
28
28
  on(:invalid) do
29
29
  flash.now[:alert] = I18n.t("milestones.create.invalid", scope: "decidim.accountability.admin")
30
- render action: "new", status: :unprocessable_entity
30
+ render action: "new", status: :unprocessable_content
31
31
  end
32
32
  end
33
33
  end
@@ -51,7 +51,7 @@ module Decidim
51
51
 
52
52
  on(:invalid) do
53
53
  flash.now[:alert] = I18n.t("milestones.update.invalid", scope: "decidim.accountability.admin")
54
- render action: "edit", status: :unprocessable_entity
54
+ render action: "edit", status: :unprocessable_content
55
55
  end
56
56
  end
57
57
  end
@@ -11,7 +11,7 @@ module Decidim
11
11
  def update_taxonomies
12
12
  enforce_permission_to :create, :bulk_update
13
13
 
14
- Admin::UpdateResultTaxonomies.call(result_params[:taxonomies], result_ids, current_component) do
14
+ Admin::UpdateResultTaxonomies.call(result_params[:taxonomies], result_ids, current_organization) do
15
15
  on(:invalid_taxonomies) do
16
16
  flash[:alert] = I18n.t(
17
17
  "results.update_taxonomies.select_a_taxonomy",
@@ -52,7 +52,7 @@ module Decidim
52
52
  def update_status
53
53
  enforce_permission_to :create, :bulk_update
54
54
 
55
- UpdateResultStatus.call(result_params[:decidim_accountability_status_id], result_ids, current_component, current_user) do
55
+ UpdateResultStatus.call(result_params[:decidim_accountability_status_id], result_ids, current_user) do
56
56
  on(:ok) do
57
57
  flash[:notice] = I18n.t("results.update_status.success", scope: "decidim.accountability.admin")
58
58
  redirect_to results_path
@@ -68,7 +68,7 @@ module Decidim
68
68
  def update_dates
69
69
  enforce_permission_to :create, :bulk_update
70
70
 
71
- UpdateResultDates.call(result_params[:start_date], result_params[:end_date], result_ids, current_component, current_user) do
71
+ UpdateResultDates.call(result_params[:start_date], result_params[:end_date], result_ids, current_user) do
72
72
  on(:ok) do
73
73
  flash[:notice] = I18n.t("results.update_dates.success", scope: "decidim.accountability.admin")
74
74
  redirect_to results_path
@@ -88,12 +88,12 @@ module Decidim
88
88
  end
89
89
 
90
90
  def result_params
91
- @result_params ||= params.require(:result_bulk_actions).permit(
92
- :decidim_accountability_status_id,
93
- :start_date,
94
- :end_date,
95
- result_ids: [],
96
- taxonomies: []
91
+ @result_params ||= params.expect(
92
+ result_bulk_actions: [:decidim_accountability_status_id,
93
+ :start_date,
94
+ :end_date,
95
+ { result_ids: [],
96
+ taxonomies: [] }]
97
97
  )
98
98
  end
99
99
  end
@@ -13,6 +13,11 @@ module Decidim
13
13
 
14
14
  helper_method :results, :parent_result, :parent_results, :statuses, :present, :bulk_actions_form
15
15
 
16
+ def collection
17
+ parent_id = params[:parent_id].presence
18
+ @collection ||= Result.where(component: current_component, parent_id:).page(params[:page]).per(15).order(created_at: :asc)
19
+ end
20
+
16
21
  def new
17
22
  enforce_permission_to :create, :result
18
23
 
@@ -33,7 +38,7 @@ module Decidim
33
38
 
34
39
  on(:invalid) do
35
40
  flash.now[:alert] = I18n.t("results.create.invalid", scope: "decidim.accountability.admin")
36
- render action: "new", status: :unprocessable_entity
41
+ render action: "new", status: :unprocessable_content
37
42
  end
38
43
  end
39
44
  end
@@ -57,18 +62,11 @@ module Decidim
57
62
 
58
63
  on(:invalid) do
59
64
  flash.now[:alert] = I18n.t("results.update.invalid", scope: "decidim.accountability.admin")
60
- render action: "edit", status: :unprocessable_entity
65
+ render action: "edit", status: :unprocessable_content
61
66
  end
62
67
  end
63
68
  end
64
69
 
65
- protected
66
-
67
- def collection
68
- parent_id = params[:parent_id].presence
69
- @collection ||= Result.where(component: current_component, parent_id:).page(params[:page]).per(15).order(created_at: :asc)
70
- end
71
-
72
70
  private
73
71
 
74
72
  def trashable_deleted_resource_type
@@ -5,6 +5,8 @@ module Decidim
5
5
  module Admin
6
6
  # This controller allows an admin to manage results from a Participatory Process
7
7
  class StatusesController < Admin::ApplicationController
8
+ include Decidim::Accountability::Admin::Filterable
9
+
8
10
  helper_method :statuses
9
11
 
10
12
  def new
@@ -26,7 +28,7 @@ module Decidim
26
28
 
27
29
  on(:invalid) do
28
30
  flash.now[:alert] = I18n.t("statuses.create.invalid", scope: "decidim.accountability.admin")
29
- render action: "new", status: :unprocessable_entity
31
+ render action: "new", status: :unprocessable_content
30
32
  end
31
33
  end
32
34
  end
@@ -50,7 +52,7 @@ module Decidim
50
52
 
51
53
  on(:invalid) do
52
54
  flash.now[:alert] = I18n.t("statuses.update.invalid", scope: "decidim.accountability.admin")
53
- render action: "edit", status: :unprocessable_entity
55
+ render action: "edit", status: :unprocessable_content
54
56
  end
55
57
  end
56
58
  end
@@ -68,8 +70,18 @@ module Decidim
68
70
 
69
71
  private
70
72
 
73
+ def base_query
74
+ Status.where(component: current_component)
75
+ end
76
+
77
+ def filtered_collection
78
+ query.sorts = ["progress asc", "key asc"] if query.sorts.empty?
79
+
80
+ paginate(query.result)
81
+ end
82
+
71
83
  def statuses
72
- @statuses ||= Status.where(component: current_component).page(params[:page]).per(15)
84
+ @statuses ||= filtered_collection
73
85
  end
74
86
 
75
87
  def status
@@ -5,22 +5,18 @@ module Decidim
5
5
  # Exposes the result resource so users can view them
6
6
  class ResultsController < Decidim::Accountability::ApplicationController
7
7
  include FilterResource
8
+
8
9
  helper Decidim::TraceabilityHelper
9
10
  helper Decidim::Accountability::BreadcrumbHelper
11
+ helper Decidim::Accountability::CalculatorHelper
10
12
 
11
- helper_method :results, :result, :count_calculator, :selected_root_taxonomy, :selected_taxonomy_children, :selected_taxonomy_grandchildren?
12
-
13
- before_action :set_controller_breadcrumb
13
+ helper_method :results, :result, :selected_root_taxonomy, :selected_taxonomy_children, :selected_taxonomy_grandchildren?
14
14
 
15
15
  def show
16
16
  raise ActionController::RoutingError, "Not Found" unless result
17
-
18
- enforce_permission_to :read, :result, result:
19
17
  end
20
18
 
21
19
  def home
22
- enforce_permission_to :read, :result
23
-
24
20
  @all_geocoded_results = results.geocoded
25
21
  end
26
22
 
@@ -29,8 +25,9 @@ module Decidim
29
25
  def results
30
26
  @results ||= begin
31
27
  parent_id = params[:parent_id].presence
32
- child_ids = Result.where(component: current_component, parent_id:).pluck(:id)
33
- search.result.where(parent_id: [parent_id] + child_ids).page(params[:page]).per(12)
28
+ search.result.where(
29
+ parent_id: [parent_id] + Result.where(parent_id:).pluck(:id)
30
+ ).page(params[:page]).per(12)
34
31
  end
35
32
  end
36
33
 
@@ -69,27 +66,25 @@ module Decidim
69
66
  end
70
67
  end
71
68
 
72
- def count_calculator(taxonomy_id)
73
- Decidim::Accountability::ResultsCalculator.new(current_component, taxonomy_id).count
74
- end
75
-
76
- def controller_breadcrumb_items
77
- @controller_breadcrumb_items ||= []
78
- end
79
-
80
- def set_controller_breadcrumb
81
- controller_breadcrumb_items << breadcrumb_item
82
- end
83
-
84
- def breadcrumb_item
69
+ def add_parent_breadcrumb_item
85
70
  return {} if result&.parent.blank?
86
71
 
87
72
  {
88
73
  label: translated_attribute(result.parent.title),
89
- url: result_path(result.parent),
74
+ url: Decidim::EngineRouter.main_proxy(current_component).result_path(result.parent),
90
75
  active: true
91
76
  }
92
77
  end
78
+
79
+ def add_breadcrumb_item
80
+ return {} if result.blank?
81
+
82
+ {
83
+ label: translated_attribute(result.title),
84
+ url: Decidim::EngineRouter.main_proxy(current_component).result_path(result),
85
+ active: false
86
+ }
87
+ end
93
88
  end
94
89
  end
95
90
  end
@@ -10,15 +10,25 @@ module Decidim
10
10
 
11
11
  include Decidim::ResourceVersionsConcern
12
12
 
13
- private
14
-
15
13
  def versioned_resource
16
14
  result
17
15
  end
18
16
 
17
+ private
18
+
19
19
  def result
20
20
  @result ||= Result.includes(:milestones).where(component: current_component).find(params[:result_id])
21
21
  end
22
+
23
+ def add_breadcrumb_item
24
+ return {} if result.blank?
25
+
26
+ {
27
+ label: translated_attribute(result.title),
28
+ url: Decidim::EngineRouter.main_proxy(current_component).result_path(result),
29
+ active: false
30
+ }
31
+ end
22
32
  end
23
33
  end
24
34
  end
@@ -15,7 +15,6 @@ module Decidim
15
15
 
16
16
  validates :key, presence: true
17
17
  validates :name, translatable_presence: true
18
- validates :progress, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 100 }, if: ->(form) { form.progress.present? }
19
18
  end
20
19
  end
21
20
  end
@@ -5,10 +5,6 @@ module Decidim
5
5
  # Helpers needed to render the navigation breadcrumbs in results.
6
6
  #
7
7
  module BreadcrumbHelper
8
- def progress_calculator(taxonomy_id)
9
- Decidim::Accountability::ResultsCalculator.new(current_component, taxonomy_id).progress
10
- end
11
-
12
8
  def taxonomy
13
9
  return if (taxonomy_id = params.dig(:filter, :taxonomies_part_of_contains)).blank?
14
10
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Accountability
5
+ # Helpers for calculating results progress and count
6
+ module CalculatorHelper
7
+ def progress_calculator(taxonomy_id)
8
+ ResultsCalculator.new(current_component, taxonomy_id).progress
9
+ end
10
+
11
+ def count_calculator(taxonomy_id)
12
+ ResultsCalculator.new(current_component, taxonomy_id).count
13
+ end
14
+ end
15
+ end
16
+ end
@@ -3,12 +3,13 @@
3
3
  module Decidim
4
4
  module Accountability
5
5
  # This mailer sends a notification email containing the result of importing
6
- # Cprojects to the results.
6
+ # projects from one budget component to accountability.
7
7
  class ImportProjectsMailer < Decidim::ApplicationMailer
8
8
  include Decidim::TranslatableAttributes
9
+
9
10
  helper Decidim::TranslationsHelper
10
11
 
11
- # Public: Sends a notification email with the result of projects import selected projects to Accountability
12
+ # Public: Sends a notification email with the result of importing projects
12
13
  #
13
14
  # user - The user to be notified.
14
15
  #
@@ -6,6 +6,7 @@ module Decidim
6
6
  # proposals to the results.
7
7
  class ImportProposalsMailer < Decidim::ApplicationMailer
8
8
  include Decidim::TranslatableAttributes
9
+
9
10
  helper Decidim::TranslationsHelper
10
11
 
11
12
  # Public: Sends a notification email with the result of proposals import selected proposals to Accountability