decidim-accountability 0.31.5 → 0.32.0.rc2

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 (81) 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/controllers/concerns/decidim/accountability/admin/filterable.rb +1 -5
  10. data/app/controllers/decidim/accountability/admin/import_components_controller.rb +3 -3
  11. data/app/controllers/decidim/accountability/admin/import_results_controller.rb +1 -1
  12. data/app/controllers/decidim/accountability/admin/milestones_controller.rb +2 -2
  13. data/app/controllers/decidim/accountability/admin/results_bulk_actions_controller.rb +6 -6
  14. data/app/controllers/decidim/accountability/admin/results_controller.rb +2 -2
  15. data/app/controllers/decidim/accountability/admin/statuses_controller.rb +15 -3
  16. data/app/controllers/decidim/accountability/results_controller.rb +15 -17
  17. data/app/controllers/decidim/accountability/versions_controller.rb +10 -0
  18. data/app/helpers/decidim/accountability/breadcrumb_helper.rb +0 -4
  19. data/app/helpers/decidim/accountability/calculator_helper.rb +16 -0
  20. data/app/mailers/decidim/accountability/import_projects_mailer.rb +3 -2
  21. data/app/mailers/decidim/accountability/import_proposals_mailer.rb +1 -0
  22. data/app/models/decidim/accountability/result.rb +9 -7
  23. data/app/models/decidim/accountability/status.rb +5 -2
  24. data/app/packs/stylesheets/accountability.scss +2 -2
  25. data/app/permissions/decidim/accountability/permissions.rb +13 -0
  26. data/app/views/decidim/accountability/admin/import_components/new.html.erb +1 -1
  27. data/app/views/decidim/accountability/admin/import_results/new.html.erb +1 -1
  28. data/app/views/decidim/accountability/admin/results/_result-tr.html.erb +1 -4
  29. data/app/views/decidim/accountability/admin/results/_results-thead.html.erb +0 -3
  30. data/app/views/decidim/accountability/admin/statuses/index.html.erb +3 -3
  31. data/app/views/decidim/accountability/results/_home_taxonomies.html.erb +2 -2
  32. data/app/views/decidim/accountability/results/{_project.html.erb → _result.html.erb} +4 -4
  33. data/app/views/decidim/accountability/results/index.html.erb +1 -1
  34. data/app/views/decidim/accountability/results/show.html.erb +1 -1
  35. data/config/locales/ar.yml +0 -1
  36. data/config/locales/bg.yml +0 -1
  37. data/config/locales/ca-IT.yml +1 -1
  38. data/config/locales/ca.yml +1 -1
  39. data/config/locales/cs.yml +0 -1
  40. data/config/locales/de.yml +1 -1
  41. data/config/locales/el.yml +1 -1
  42. data/config/locales/en.yml +1 -1
  43. data/config/locales/es-MX.yml +1 -1
  44. data/config/locales/es-PY.yml +1 -1
  45. data/config/locales/es.yml +1 -1
  46. data/config/locales/eu.yml +1 -1
  47. data/config/locales/fi-plain.yml +1 -1
  48. data/config/locales/fi.yml +1 -1
  49. data/config/locales/fr-CA.yml +1 -1
  50. data/config/locales/fr.yml +1 -1
  51. data/config/locales/ga-IE.yml +0 -1
  52. data/config/locales/gl.yml +0 -1
  53. data/config/locales/he-IL.yml +0 -1
  54. data/config/locales/hu.yml +0 -1
  55. data/config/locales/is-IS.yml +0 -1
  56. data/config/locales/it.yml +0 -1
  57. data/config/locales/ja.yml +1 -1
  58. data/config/locales/ko.yml +0 -1
  59. data/config/locales/lb.yml +0 -1
  60. data/config/locales/lt.yml +0 -1
  61. data/config/locales/nl.yml +0 -1
  62. data/config/locales/no.yml +0 -1
  63. data/config/locales/pl.yml +0 -1
  64. data/config/locales/pt-BR.yml +1 -1
  65. data/config/locales/pt.yml +0 -1
  66. data/config/locales/ro-RO.yml +1 -1
  67. data/config/locales/sk.yml +1 -1
  68. data/config/locales/sq-AL.yml +0 -1
  69. data/config/locales/sv.yml +1 -1
  70. data/config/locales/tr-TR.yml +1 -1
  71. data/config/locales/zh-TW.yml +0 -1
  72. data/db/data/20260113140600_reindex_results.rb +13 -0
  73. data/decidim-accountability.gemspec +12 -15
  74. data/lib/decidim/accountability/component.rb +13 -5
  75. data/lib/decidim/accountability/seeds.rb +2 -2
  76. data/lib/decidim/accountability/version.rb +1 -1
  77. data/lib/decidim/api/accountability_type.rb +14 -2
  78. metadata +30 -32
  79. data/app/views/decidim/accountability/results/index.js.erb +0 -5
  80. /data/app/cells/decidim/accountability/{project → result_show}/show.erb +0 -0
  81. /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: 8282353918c8c05b403667bf847e95e351575e384fb49e96115616c5d8148631
4
- data.tar.gz: 0660dc95b1448d03e60a629a5410c9013a123b41b61f421011a311fafc8c67a7
3
+ metadata.gz: 9eba04a15a624218351dd6c849696555c738519560465a3dbb9f0557f6fd20d3
4
+ data.tar.gz: 74ecda47916f43511aa2d3ac207ab72353c8670c03da7dec91e86cd6568c2037
5
5
  SHA512:
6
- metadata.gz: e716ec5098729ca8960531254e7bef801cb104618292809ccd8e84108162c2a950271bf59ce62a3a4fa12ca11c240a4a4c704b452716e3f2caceb1a016b6938b
7
- data.tar.gz: be075e82c621becda672e11bc92d7bd98497c48a082c057e7a30249c65c7cf3f53cb5c9e8a890a49505a06fe34d51f4d485715ebe5a48431364fb338e4c72f87
6
+ metadata.gz: 38c87c66c05c767564e3afafdb6e6a0ee398c8a38971c4c07a71e406d21e7452cc2df3dcecec0ab6de3cb7ff3e20431b5e05a55ba73167e44d21c0837931af6a
7
+ data.tar.gz: 23ac3bee5ac778cf0daf9c19c2663973aeaf4096df51eda0f484aa55ebf153f2b415876cf3af12760597b84ca9a078d0bf444d59db32a711944e8fd6e4ada0bf
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
@@ -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)
@@ -15,14 +15,14 @@ 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
@@ -21,7 +21,7 @@ module Decidim
21
21
  redirect_to import_results_path(current_participatory_space, current_component)
22
22
  else
23
23
  flash[:alert] = I18n.t("imports.create.invalid", scope: "decidim.accountability.admin")
24
- render action: "new", status: :unprocessable_entity
24
+ render action: "new", status: :unprocessable_content
25
25
  end
26
26
  end
27
27
 
@@ -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
@@ -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
@@ -38,7 +38,7 @@ module Decidim
38
38
 
39
39
  on(:invalid) do
40
40
  flash.now[:alert] = I18n.t("results.create.invalid", scope: "decidim.accountability.admin")
41
- render action: "new", status: :unprocessable_entity
41
+ render action: "new", status: :unprocessable_content
42
42
  end
43
43
  end
44
44
  end
@@ -62,7 +62,7 @@ module Decidim
62
62
 
63
63
  on(:invalid) do
64
64
  flash.now[:alert] = I18n.t("results.update.invalid", scope: "decidim.accountability.admin")
65
- render action: "edit", status: :unprocessable_entity
65
+ render action: "edit", status: :unprocessable_content
66
66
  end
67
67
  end
68
68
  end
@@ -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,12 +5,12 @@ 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
@@ -66,27 +66,25 @@ module Decidim
66
66
  end
67
67
  end
68
68
 
69
- def count_calculator(taxonomy_id)
70
- Decidim::Accountability::ResultsCalculator.new(current_component, taxonomy_id).count
71
- end
72
-
73
- def controller_breadcrumb_items
74
- @controller_breadcrumb_items ||= []
75
- end
76
-
77
- def set_controller_breadcrumb
78
- controller_breadcrumb_items << breadcrumb_item
79
- end
80
-
81
- def breadcrumb_item
69
+ def add_parent_breadcrumb_item
82
70
  return {} if result&.parent.blank?
83
71
 
84
72
  {
85
73
  label: translated_attribute(result.parent.title),
86
- url: result_path(result.parent),
74
+ url: Decidim::EngineRouter.main_proxy(current_component).result_path(result.parent),
87
75
  active: true
88
76
  }
89
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
90
88
  end
91
89
  end
92
90
  end
@@ -19,6 +19,16 @@ module Decidim
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
@@ -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
@@ -39,13 +39,15 @@ module Decidim
39
39
 
40
40
  after_save :update_parent_progress, if: -> { parent_id.present? }
41
41
 
42
- searchable_fields(
43
- scope_id: :decidim_scope_id,
44
- participatory_space: { component: :participatory_space },
45
- A: :title,
46
- D: :description,
47
- datetime: :start_date
48
- )
42
+ searchable_fields({
43
+ scope_id: :decidim_scope_id,
44
+ participatory_space: { component: :participatory_space },
45
+ A: :title,
46
+ D: :description,
47
+ datetime: :start_date
48
+ },
49
+ index_on_create: ->(result) { result.visible? },
50
+ index_on_update: ->(result) { result.visible? })
49
51
 
50
52
  geocoded_by :address
51
53
 
@@ -22,8 +22,11 @@ module Decidim
22
22
  # Allow ransacker to search for a key in a hstore column (`name`.`en`)
23
23
  ransacker_i18n :name
24
24
 
25
- def self.ransackable_attributes(_auth_object = nil)
26
- %w(id name)
25
+ def self.ransackable_attributes(auth_object = nil)
26
+ base = %w(id name)
27
+ return base unless auth_object&.admin?
28
+
29
+ base + %w(key progress)
27
30
  end
28
31
 
29
32
  def self.log_presenter_class_for(_log)
@@ -91,7 +91,7 @@
91
91
  @apply text-3xl;
92
92
  }
93
93
 
94
- &__project &-title {
94
+ &__result &-title {
95
95
  @apply text-gray-2 text-md font-normal;
96
96
  }
97
97
  }
@@ -132,7 +132,7 @@
132
132
  @apply ml-auto rounded px-3 md:px-6 py-4 bg-background font-bold text-gray-2 text-xl w-full md:w-auto min-w-[120px] grid place-items-center;
133
133
  }
134
134
 
135
- &__project {
135
+ &__result {
136
136
  &-aside {
137
137
  @apply bg-background p-4 rounded divide-y divide-gray-3 [&>*]:py-4 first:[&>*]:pt-0 last:[&>*]:pb-0;
138
138
 
@@ -4,6 +4,7 @@ module Decidim
4
4
  module Accountability
5
5
  class Permissions < Decidim::DefaultPermissions
6
6
  def permissions
7
+ return permission_action if permission_action.scope == :public && public_read_result_action?
7
8
  return permission_action unless user
8
9
 
9
10
  # Delegate the admin permission checks to the admin permissions class
@@ -11,6 +12,18 @@ module Decidim
11
12
 
12
13
  permission_action
13
14
  end
15
+
16
+ private
17
+
18
+ def public_read_result_action?
19
+ return unless permission_action.action == :read && permission_action.subject == :result
20
+
21
+ toggle_allow(result && !result.deleted?)
22
+ end
23
+
24
+ def result
25
+ @result ||= context.fetch(:result, nil)
26
+ end
14
27
  end
15
28
  end
16
29
  end
@@ -7,7 +7,7 @@
7
7
 
8
8
  <div class="item__edit item__edit-1col">
9
9
  <div class="item__edit-form">
10
- <%= render "form" %>
10
+ <%= render "decidim/accountability/admin/import_components/form" %>
11
11
  </div>
12
12
  </div>
13
13
 
@@ -6,7 +6,7 @@
6
6
  </div>
7
7
  <div class="item__edit item__edit-1col">
8
8
  <div class="item__edit-form">
9
- <%= decidim_form_for(@form, url: import_results_path, html: { class: "form form-defaults import_projects" }) do |form| %>
9
+ <%= decidim_form_for(@form, url: import_results_path, html: { class: "form form-defaults import_results" }) do |form| %>
10
10
  <div class="card py-4">
11
11
  <div class="card-section space-y-4 prose max-w-full">
12
12
  <div class="row column">
@@ -2,9 +2,6 @@
2
2
  <td>
3
3
  <%= check_box_tag "result_ids_s[]", result.id, false, data: { result_id: result.id, result_checkbox: true } %><br>
4
4
  </td>
5
- <td data-label="<%= t("models.result.fields.id", scope: "decidim.accountability") %>">
6
- <%= result.id %><br>
7
- </td>
8
5
  <td class="!text-left" data-label="<%= t("models.result.fields.title", scope: "decidim.accountability") %>">
9
6
  <% if result.parent_id.nil? %>
10
7
  <%= link_to translated_attribute(result.title), results_path(parent_id: result.id) %><br>
@@ -21,7 +18,7 @@
21
18
  <% end %>
22
19
  </td>
23
20
  <td data-label="<%= t("models.result.fields.progress", scope: "decidim.accountability") %>">
24
- <%= result.progress&.to_i %>
21
+ <%= result.progress.nil? ? 0 : result.progress&.to_i %>%
25
22
  </td>
26
23
  <td data-label="<%= t("models.result.fields.created_at", scope: "decidim.accountability") %>">
27
24
  <%= l result.created_at, format: :decidim_short %>
@@ -3,9 +3,6 @@
3
3
  <th>
4
4
  <%= check_box_tag "results_bulk", "all", false, data: { "select-all" => true } %>
5
5
  </th>
6
- <th>
7
- <%= sort_link(query, :id, t("models.result.fields.id", scope: "decidim.accountability"), default_order: :desc ) %>
8
- </th>
9
6
  <th class="!text-left">
10
7
  <%= sort_link(query, :title, t("models.result.fields.title", scope: "decidim.accountability")) %>
11
8
  </th>
@@ -10,10 +10,10 @@
10
10
  <table class="table-list">
11
11
  <thead>
12
12
  <tr>
13
- <th><%= t("models.status.fields.key", scope: "decidim.accountability") %></th>
14
- <th><%= t("models.status.fields.name", scope: "decidim.accountability") %></th>
13
+ <th><%= sort_link(query, :key, t("models.status.fields.key", scope: "decidim.accountability")) %></th>
14
+ <th><%= sort_link(query, :name, t("models.status.fields.name", scope: "decidim.accountability")) %></th>
15
15
  <th><%= t("models.status.fields.description", scope: "decidim.accountability") %></th>
16
- <th><%= t("models.status.fields.progress", scope: "decidim.accountability") %></th>
16
+ <th><%= sort_link(query, :progress, t("models.status.fields.progress", scope: "decidim.accountability")) %></th>
17
17
  <th><%= t("actions.title", scope: "decidim.accountability") %></th>
18
18
  </tr>
19
19
  </thead>
@@ -3,7 +3,7 @@
3
3
  </h3>
4
4
 
5
5
  <% if selected_taxonomy_grandchildren? %>
6
- <%= render "two_levels_taxonomies" %>
6
+ <%= render "decidim/accountability/results/two_levels_taxonomies" %>
7
7
  <% else %>
8
- <%= render "one_level_taxonomies" %>
8
+ <%= render "decidim/accountability/results/one_level_taxonomies" %>
9
9
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= render layout: "layouts/decidim/shared/layout_item" do %>
2
- <%= cell("decidim/accountability/project", result) %>
2
+ <%= cell("decidim/accountability/result_show", result) %>
3
3
  <%= cell("decidim/tags", result) %>
4
4
 
5
5
  <section class="layout-main__section layout-main__buttons" data-buttons>
@@ -7,17 +7,17 @@
7
7
  </section>
8
8
 
9
9
  <% content_for :aside do %>
10
- <section class="layout-aside__section layout-aside__buttons accountability__project-aside">
10
+ <section class="layout-aside__section layout-aside__buttons accountability__result-aside">
11
11
  <% if component_settings.display_progress_enabled? %>
12
12
  <%= cell(
13
13
  "decidim/accountability/status",
14
14
  result,
15
15
  title: t("models.result.fields.progress", scope: "decidim.accountability"),
16
- extra_classes: "accountability__status__project"
16
+ extra_classes: "accountability__status__result"
17
17
  ) %>
18
18
  <% end %>
19
19
 
20
- <%= cell("decidim/accountability/result_metadata", result, template: :project_aside) %>
20
+ <%= cell("decidim/accountability/result_metadata", result, template: :result_aside) %>
21
21
  </section>
22
22
  <% end %>
23
23
  <% content_for :item_footer do %>
@@ -8,7 +8,7 @@
8
8
  <%= append_stylesheet_pack_tag "decidim_accountability" %>
9
9
 
10
10
  <% content_for :aside do %>
11
- <%= render partial: "projects_aside", locals: { main_action: true } %>
11
+ <%= render partial: "results_aside", locals: { main_action: true } %>
12
12
  <% end %>
13
13
 
14
14
  <%= render layout: "layouts/decidim/shared/layout_two_col" do %>
@@ -16,4 +16,4 @@ edit_link(
16
16
  <%= append_javascript_pack_tag "decidim_accountability" %>
17
17
  <%= append_stylesheet_pack_tag "decidim_accountability" %>
18
18
 
19
- <%= render partial: "project", locals: { result: } %>
19
+ <%= render partial: "result", locals: { result: } %>
@@ -183,7 +183,6 @@ ar:
183
183
  fields:
184
184
  created_at: تم الإنشاء
185
185
  end_date: تاريخ الانتهاء
186
- id: المعرف ID
187
186
  progress: تقدم
188
187
  start_date: تاريخ البدء
189
188
  status: الحالة