decidim-accountability 0.26.10 → 0.27.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/accountability/highlighted_results_for_component_cell.rb +13 -1
  3. data/app/commands/decidim/accountability/admin/create_imported_result.rb +1 -1
  4. data/app/commands/decidim/accountability/admin/create_result.rb +1 -1
  5. data/app/commands/decidim/accountability/admin/create_status.rb +6 -3
  6. data/app/commands/decidim/accountability/admin/create_timeline_entry.rb +11 -7
  7. data/app/commands/decidim/accountability/admin/destroy_result.rb +1 -1
  8. data/app/commands/decidim/accountability/admin/update_imported_result.rb +1 -1
  9. data/app/commands/decidim/accountability/admin/update_result.rb +1 -1
  10. data/app/commands/decidim/accountability/admin/update_status.rb +6 -3
  11. data/app/commands/decidim/accountability/admin/update_timeline_entry.rb +9 -5
  12. data/app/controllers/decidim/accountability/admin/statuses_controller.rb +5 -3
  13. data/app/controllers/decidim/accountability/admin/timeline_entries_controller.rb +5 -3
  14. data/app/controllers/decidim/accountability/results_controller.rb +12 -12
  15. data/app/forms/decidim/accountability/admin/result_form.rb +2 -2
  16. data/app/forms/decidim/accountability/admin/timeline_entry_form.rb +2 -1
  17. data/app/helpers/decidim/accountability/breadcrumb_helper.rb +2 -2
  18. data/app/models/decidim/accountability/result.rb +9 -5
  19. data/app/models/decidim/accountability/status.rb +6 -2
  20. data/app/models/decidim/accountability/timeline_entry.rb +6 -0
  21. data/app/permissions/decidim/accountability/admin/permissions.rb +1 -7
  22. data/app/presenters/decidim/accountability/admin_log/status_presenter.rb +38 -0
  23. data/app/presenters/decidim/accountability/admin_log/timeline_entry_presenter.rb +37 -0
  24. data/app/services/decidim/accountability/results_calculator.rb +10 -6
  25. data/app/views/decidim/accountability/admin/import_results/new.html.erb +3 -8
  26. data/app/views/decidim/accountability/admin/results/edit.html.erb +0 -1
  27. data/app/views/decidim/accountability/admin/results/index.html.erb +1 -2
  28. data/app/views/decidim/accountability/admin/results/new.html.erb +0 -1
  29. data/app/views/decidim/accountability/admin/statuses/edit.html.erb +0 -1
  30. data/app/views/decidim/accountability/admin/statuses/index.html.erb +0 -1
  31. data/app/views/decidim/accountability/admin/statuses/new.html.erb +0 -1
  32. data/app/views/decidim/accountability/admin/timeline_entries/_form.html.erb +5 -1
  33. data/app/views/decidim/accountability/admin/timeline_entries/index.html.erb +3 -3
  34. data/app/views/decidim/accountability/results/_home_categories.html.erb +2 -2
  35. data/app/views/decidim/accountability/results/_nav_breadcrumb.html.erb +3 -3
  36. data/app/views/decidim/accountability/results/_results_leaf.html.erb +3 -3
  37. data/app/views/decidim/accountability/results/_results_parent.html.erb +1 -1
  38. data/app/views/decidim/accountability/results/_scope_filters.html.erb +3 -3
  39. data/app/views/decidim/accountability/results/_search.html.erb +1 -1
  40. data/app/views/decidim/accountability/results/_show_leaf.html.erb +2 -2
  41. data/app/views/decidim/accountability/results/_timeline.html.erb +8 -2
  42. data/app/views/decidim/accountability/results/home.html.erb +3 -1
  43. data/app/views/decidim/accountability/versions/show.html.erb +3 -1
  44. data/app/views/decidim/participatory_spaces/_result.html.erb +2 -2
  45. data/config/locales/am-ET.yml +1 -0
  46. data/config/locales/ar.yml +24 -41
  47. data/config/locales/bg.yml +3 -1
  48. data/config/locales/ca.yml +13 -23
  49. data/config/locales/cs.yml +13 -23
  50. data/config/locales/da.yml +3 -1
  51. data/config/locales/de.yml +13 -23
  52. data/config/locales/el.yml +3 -2
  53. data/config/locales/en.yml +12 -23
  54. data/config/locales/eo.yml +1 -0
  55. data/config/locales/es-MX.yml +13 -23
  56. data/config/locales/es-PY.yml +13 -23
  57. data/config/locales/es.yml +13 -23
  58. data/config/locales/et.yml +1 -0
  59. data/config/locales/eu.yml +52 -72
  60. data/config/locales/fi-plain.yml +13 -23
  61. data/config/locales/fi.yml +19 -29
  62. data/config/locales/fr-CA.yml +13 -23
  63. data/config/locales/fr.yml +13 -23
  64. data/config/locales/ga-IE.yml +2 -0
  65. data/config/locales/gl.yml +3 -1
  66. data/config/locales/hr.yml +1 -0
  67. data/config/locales/hu.yml +12 -32
  68. data/config/locales/id-ID.yml +1 -1
  69. data/config/locales/is-IS.yml +3 -2
  70. data/config/locales/it.yml +3 -1
  71. data/config/locales/ja.yml +14 -24
  72. data/config/locales/ko.yml +1 -14
  73. data/config/locales/lb.yml +3 -1
  74. data/config/locales/lt.yml +13 -23
  75. data/config/locales/lv.yml +3 -1
  76. data/config/locales/mt.yml +1 -0
  77. data/config/locales/nl.yml +2 -1
  78. data/config/locales/no.yml +11 -9
  79. data/config/locales/om-ET.yml +1 -0
  80. data/config/locales/pl.yml +13 -2
  81. data/config/locales/pt-BR.yml +4 -26
  82. data/config/locales/pt.yml +3 -1
  83. data/config/locales/ro-RO.yml +9 -8
  84. data/config/locales/ru.yml +1 -1
  85. data/config/locales/si-LK.yml +2 -1
  86. data/config/locales/sk.yml +2 -1
  87. data/config/locales/sl.yml +2 -1
  88. data/config/locales/so-SO.yml +1 -0
  89. data/config/locales/sr-CS.yml +1 -1
  90. data/config/locales/sv.yml +5 -23
  91. data/config/locales/sw-KE.yml +1 -0
  92. data/config/locales/ti-ER.yml +1 -0
  93. data/config/locales/tr-TR.yml +3 -25
  94. data/config/locales/uk.yml +1 -1
  95. data/config/locales/val-ES.yml +1 -0
  96. data/config/locales/vi.yml +1 -0
  97. data/config/locales/zh-CN.yml +2 -1
  98. data/config/locales/zh-TW.yml +1 -267
  99. data/db/migrate/20220331150008_add_title_to_timeline_entries.rb +7 -0
  100. data/db/migrate/20220331150155_move_legacy_description_to_title_of_timeline_entries.rb +13 -0
  101. data/lib/decidim/accountability/component.rb +2 -1
  102. data/lib/decidim/accountability/test/factories.rb +1 -0
  103. data/lib/decidim/accountability/version.rb +1 -1
  104. data/lib/decidim/api/timeline_entry_type.rb +1 -0
  105. metadata +28 -34
  106. data/app/services/decidim/accountability/result_search.rb +0 -48
  107. data/config/environment.rb +0 -3
  108. data/config/locales/fa-IR.yml +0 -1
  109. data/config/locales/gn-PY.yml +0 -15
  110. data/config/locales/ka-GE.yml +0 -1
  111. data/config/locales/kaa.yml +0 -89
  112. data/config/locales/lo-LA.yml +0 -1
  113. data/config/locales/oc-FR.yml +0 -1
  114. data/config/locales/sq-AL.yml +0 -212
  115. data/config/locales/th-TH.yml +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed6100ed90d5e3fac894d1635e5907f0353ef548263afe8cff5472b11a966eb3
4
- data.tar.gz: 694dc8d8039a9b57f948b49fcf1918dfd1b3ecc179825b41d18863c5fc0684c7
3
+ metadata.gz: 3c075f66ece3b892202c3936512fe378f3badd528a66d50e27c3b05e0139b330
4
+ data.tar.gz: 888ec8f73f7b72a36167359670cffb1228bfa30c29ed7f35f73213d30db35864
5
5
  SHA512:
6
- metadata.gz: 021d0e003f2a60d3e5e97c2f9fc30b7b61294caa35be260c31c2dc20ffdb244496f8a3fa4df5183a9f0d85ee8aa101168e5be8c56a8ab148bd76ff3395dbd2f4
7
- data.tar.gz: 48d88affb096c6130653d973d2a6f4b639f871764ff7cd23b31cd5d5a9dffc1bf333d31bb4f2cd1f92831b92c6e740b9d9041f86e5b4c4e66cae72ea3a02ebcf
6
+ metadata.gz: 8e9e0be0ac5170614d786e784e310c2f30cc1f7e03ff9b3eb16fe1a3911beee160fcdb2f1f39f87dd3ebfda418325a634199b29ef25250bef55afb9ba7e73897
7
+ data.tar.gz: 07a0e0128905106e8ac06ffeda3b60ae1c820039637cc32011e7524521d6af0340e4a930f9c04f7f065d3ed7b0f1cd75ecc801889310d5d9f535597c0c4cd723
@@ -21,7 +21,7 @@ module Decidim
21
21
  private
22
22
 
23
23
  def results
24
- @results ||= Decidim::Accountability::Result.where(component: model).order_randomly(rand * 2 - 1)
24
+ @results ||= Decidim::Accountability::Result.where(component: model).order_randomly((rand * 2) - 1)
25
25
  end
26
26
 
27
27
  def results_to_render
@@ -31,6 +31,18 @@ module Decidim
31
31
  def results_count
32
32
  @results_count ||= results.count
33
33
  end
34
+
35
+ def cache_hash
36
+ hash = []
37
+ hash << "decidim/accountability/highlighted_results_for_component"
38
+ hash << results.cache_key_with_version
39
+ hash << I18n.locale.to_s
40
+ hash.join(Decidim.cache_key_separator)
41
+ end
42
+
43
+ def cache_expiry_time
44
+ 10.minutes
45
+ end
34
46
  end
35
47
  end
36
48
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user creates a Result from the admin
7
7
  # panel.
8
- class CreateImportedResult < Rectify::Command
8
+ class CreateImportedResult < Decidim::Command
9
9
  def initialize(form, parent_id = nil)
10
10
  @form = form
11
11
  @parent_id = parent_id
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user creates a Result from the admin
7
7
  # panel.
8
- class CreateResult < Rectify::Command
8
+ class CreateResult < Decidim::Command
9
9
  def initialize(form)
10
10
  @form = form
11
11
  end
@@ -5,9 +5,10 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user creates a Status from the admin
7
7
  # panel.
8
- class CreateStatus < Rectify::Command
9
- def initialize(form)
8
+ class CreateStatus < Decidim::Command
9
+ def initialize(form, user)
10
10
  @form = form
11
+ @user = user
11
12
  end
12
13
 
13
14
  # Creates the status if valid.
@@ -28,7 +29,9 @@ module Decidim
28
29
  attr_reader :status
29
30
 
30
31
  def create_status
31
- @status = Status.create!(
32
+ @status = Decidim.traceability.create!(
33
+ Status,
34
+ @user,
32
35
  component: @form.current_component,
33
36
  key: @form.key,
34
37
  name: @form.name,
@@ -5,9 +5,10 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user creates a TimelineEntry
7
7
  # for a Result from the admin panel.
8
- class CreateTimelineEntry < Rectify::Command
9
- def initialize(form)
8
+ class CreateTimelineEntry < Decidim::Command
9
+ def initialize(form, user)
10
10
  @form = form
11
+ @user = user
11
12
  end
12
13
 
13
14
  # Creates the timeline_entry if valid.
@@ -25,13 +26,16 @@ module Decidim
25
26
 
26
27
  private
27
28
 
28
- attr_reader :timeline_entry
29
+ attr_reader :timeline_entry, :form
29
30
 
30
31
  def create_timeline_entry
31
- @timeline_entry = TimelineEntry.create!(
32
- decidim_accountability_result_id: @form.decidim_accountability_result_id,
33
- entry_date: @form.entry_date,
34
- description: @form.description
32
+ @timeline_entry = Decidim.traceability.create!(
33
+ TimelineEntry,
34
+ @user,
35
+ decidim_accountability_result_id: form.decidim_accountability_result_id,
36
+ entry_date: form.entry_date,
37
+ title: form.title,
38
+ description: form.description
35
39
  )
36
40
  end
37
41
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user destroys a Result from the admin
7
7
  # panel.
8
- class DestroyResult < Rectify::Command
8
+ class DestroyResult < Decidim::Command
9
9
  # Initializes an UpdateResult Command.
10
10
  #
11
11
  # result - The current instance of the result to be destroyed.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user changes a Result from the admin
7
7
  # panel.
8
- class UpdateImportedResult < Rectify::Command
8
+ class UpdateImportedResult < Decidim::Command
9
9
  # Initializes an UpdateResult Command.
10
10
  #
11
11
  # form - The form from which to get the data.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user changes a Result from the admin
7
7
  # panel.
8
- class UpdateResult < Rectify::Command
8
+ class UpdateResult < Decidim::Command
9
9
  # Initializes an UpdateResult Command.
10
10
  #
11
11
  # form - The form from which to get the data.
@@ -5,14 +5,15 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user changes a Result from the admin
7
7
  # panel.
8
- class UpdateStatus < Rectify::Command
8
+ class UpdateStatus < Decidim::Command
9
9
  # Initializes an UpdateStatus Command.
10
10
  #
11
11
  # form - The form from which to get the data.
12
12
  # status - The current instance of the status to be updated.
13
- def initialize(form, status)
13
+ def initialize(form, status, user)
14
14
  @form = form
15
15
  @status = status
16
+ @user = user
16
17
  end
17
18
 
18
19
  # Updates the status if valid.
@@ -33,7 +34,9 @@ module Decidim
33
34
  attr_reader :status, :form
34
35
 
35
36
  def update_status
36
- status.update!(
37
+ Decidim.traceability.update!(
38
+ status,
39
+ @user,
37
40
  key: @form.key,
38
41
  name: @form.name,
39
42
  description: @form.description,
@@ -5,14 +5,15 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user changes a Result from the admin
7
7
  # panel.
8
- class UpdateTimelineEntry < Rectify::Command
8
+ class UpdateTimelineEntry < Decidim::Command
9
9
  # Initializes an UpdateTimelineEntry Command.
10
10
  #
11
11
  # form - The form from which to get the data.
12
12
  # timeline_entry - The current instance of the timeline_entry to be updated.
13
- def initialize(form, timeline_entry)
13
+ def initialize(form, timeline_entry, user)
14
14
  @form = form
15
15
  @timeline_entry = timeline_entry
16
+ @user = user
16
17
  end
17
18
 
18
19
  # Updates the timeline_entry if valid.
@@ -33,9 +34,12 @@ module Decidim
33
34
  attr_reader :timeline_entry, :form
34
35
 
35
36
  def update_timeline_entry
36
- timeline_entry.update!(
37
- entry_date: @form.entry_date,
38
- description: @form.description
37
+ Decidim.traceability.update!(
38
+ timeline_entry,
39
+ @user,
40
+ entry_date: form.entry_date,
41
+ title: form.title,
42
+ description: form.description
39
43
  )
40
44
  end
41
45
  end
@@ -18,7 +18,7 @@ module Decidim
18
18
 
19
19
  @form = form(StatusForm).from_params(params)
20
20
 
21
- CreateStatus.call(@form) do
21
+ CreateStatus.call(@form, current_user) do
22
22
  on(:ok) do
23
23
  flash[:notice] = I18n.t("statuses.create.success", scope: "decidim.accountability.admin")
24
24
  redirect_to statuses_path
@@ -42,7 +42,7 @@ module Decidim
42
42
 
43
43
  @form = form(StatusForm).from_params(params)
44
44
 
45
- UpdateStatus.call(@form, status) do
45
+ UpdateStatus.call(@form, status, current_user) do
46
46
  on(:ok) do
47
47
  flash[:notice] = I18n.t("statuses.update.success", scope: "decidim.accountability.admin")
48
48
  redirect_to statuses_path
@@ -58,7 +58,9 @@ module Decidim
58
58
  def destroy
59
59
  enforce_permission_to :destroy, :status, status: status
60
60
 
61
- status.destroy!
61
+ Decidim.traceability.perform_action!("delete", status, current_user) do
62
+ status.destroy!
63
+ end
62
64
 
63
65
  flash[:notice] = I18n.t("statuses.destroy.success", scope: "decidim.accountability.admin")
64
66
 
@@ -19,7 +19,7 @@ module Decidim
19
19
  @form = form(TimelineEntryForm).from_params(params)
20
20
  @form.decidim_accountability_result_id = params[:result_id]
21
21
 
22
- CreateTimelineEntry.call(@form) do
22
+ CreateTimelineEntry.call(@form, current_user) do
23
23
  on(:ok) do
24
24
  flash[:notice] = I18n.t("timeline_entries.create.success", scope: "decidim.accountability.admin")
25
25
  redirect_to result_timeline_entries_path(params[:result_id])
@@ -43,7 +43,7 @@ module Decidim
43
43
 
44
44
  @form = form(TimelineEntryForm).from_params(params)
45
45
 
46
- UpdateTimelineEntry.call(@form, timeline_entry) do
46
+ UpdateTimelineEntry.call(@form, timeline_entry, current_user) do
47
47
  on(:ok) do
48
48
  flash[:notice] = I18n.t("timeline_entries.update.success", scope: "decidim.accountability.admin")
49
49
  redirect_to result_timeline_entries_path(params[:result_id])
@@ -59,7 +59,9 @@ module Decidim
59
59
  def destroy
60
60
  enforce_permission_to :destroy, :timeline_entry, timeline_entry: timeline_entry
61
61
 
62
- timeline_entry.destroy!
62
+ Decidim.traceability.perform_action!("delete", timeline_entry, current_user) do
63
+ timeline_entry.destroy!
64
+ end
63
65
 
64
66
  flash[:notice] = I18n.t("timeline_entries.destroy.success", scope: "decidim.accountability.admin")
65
67
 
@@ -17,30 +17,30 @@ module Decidim
17
17
  private
18
18
 
19
19
  def results
20
- parent_id = params[:parent_id].presence
21
- @results ||= search.results.where(parent_id: parent_id).page(params[:page]).per(12)
20
+ @results ||= begin
21
+ parent_id = params[:parent_id].presence
22
+ search.result.where(
23
+ parent_id: [parent_id] + Result.where(parent_id: parent_id).pluck(:id)
24
+ ).page(params[:page]).per(12)
25
+ end
22
26
  end
23
27
 
24
28
  def result
25
- @result ||= Result.includes(:timeline_entries).where(component: current_component).find(params[:id])
29
+ @result ||= search_collection.includes(:timeline_entries).find_by(id: params[:id])
26
30
  end
27
31
 
28
- def search_klass
29
- ResultSearch
32
+ def search_collection
33
+ Result.where(component: current_component)
30
34
  end
31
35
 
32
36
  def default_filter_params
33
37
  {
34
- search_text: "",
35
- scope_id: "",
36
- category_id: ""
38
+ search_text_cont: "",
39
+ with_scope: "",
40
+ with_category: ""
37
41
  }
38
42
  end
39
43
 
40
- def context_params
41
- { component: current_component, organization: current_organization }
42
- end
43
-
44
44
  def first_class_categories
45
45
  @first_class_categories ||= current_participatory_space.categories.first_class
46
46
  end
@@ -59,14 +59,14 @@ module Decidim
59
59
  #
60
60
  # Returns a Decidim::Scope
61
61
  def scope
62
- @scope ||= @decidim_scope_id ? current_component.scopes.find_by(id: @decidim_scope_id) : current_component.scope
62
+ @scope ||= @attributes["decidim_scope_id"].value ? current_component.scopes.find_by(id: @attributes["decidim_scope_id"].value) : current_component.scope
63
63
  end
64
64
 
65
65
  # Scope identifier
66
66
  #
67
67
  # Returns the scope identifier related to the result
68
68
  def decidim_scope_id
69
- @decidim_scope_id || scope&.id
69
+ super || scope&.id
70
70
  end
71
71
 
72
72
  def category
@@ -10,10 +10,11 @@ module Decidim
10
10
 
11
11
  attribute :decidim_accountability_result_id, Integer
12
12
  attribute :entry_date, Decidim::Attributes::LocalizedDate
13
+ translatable_attribute :title, String
13
14
  translatable_attribute :description, String
14
15
 
15
16
  validates :entry_date, presence: true
16
- validates :description, translatable_presence: true
17
+ validates :title, translatable_presence: true
17
18
  end
18
19
  end
19
20
  end
@@ -10,7 +10,7 @@ module Decidim
10
10
  end
11
11
 
12
12
  def current_scope
13
- params[:filter][:scope_id] if params[:filter]
13
+ params[:filter][:with_scope] if params[:filter]
14
14
  end
15
15
 
16
16
  def progress_calculator(scope_id, category_id)
@@ -18,7 +18,7 @@ module Decidim
18
18
  end
19
19
 
20
20
  def category
21
- return if (category_id = params.dig(:filter, :category_id)).blank?
21
+ return if (category_id = params.dig(:filter, :with_category)).blank?
22
22
 
23
23
  @category ||= current_participatory_space.categories.find(category_id.is_a?(Array) ? category_id.first : category_id)
24
24
  end
@@ -15,10 +15,11 @@ module Decidim
15
15
  include Decidim::Comments::CommentableWithComponent
16
16
  include Decidim::Traceable
17
17
  include Decidim::Loggable
18
- include Decidim::DataPortability
18
+ include Decidim::DownloadYourData
19
19
  include Decidim::Randomable
20
20
  include Decidim::Searchable
21
21
  include Decidim::TranslatableResource
22
+ include Decidim::FilterableResource
22
23
 
23
24
  component_manifest_name "accountability"
24
25
 
@@ -81,14 +82,17 @@ module Decidim
81
82
  true
82
83
  end
83
84
 
85
+ def self.ransackable_scopes(_auth_object = nil)
86
+ [:with_category, :with_scope]
87
+ end
88
+
84
89
  ransacker :id_string do
85
90
  Arel.sql(%{cast("decidim_accountability_results"."id" as text)})
86
91
  end
87
92
 
88
- # Allow ransacker to search for a key in a hstore column (`title`.`en`)
89
- ransacker :title do |parent|
90
- Arel::Nodes::InfixOperation.new("->>", parent.table[:title], Arel::Nodes.build_quoted(I18n.locale.to_s))
91
- end
93
+ # Create i18n ransackers for :title and :description.
94
+ # Create the :search_text ransacker alias for searching from both of these.
95
+ ransacker_i18n_multi :search_text, [:title, :description]
92
96
 
93
97
  private
94
98
 
@@ -7,6 +7,8 @@ module Decidim
7
7
  class Status < Accountability::ApplicationRecord
8
8
  include Decidim::HasComponent
9
9
  include Decidim::TranslatableResource
10
+ include Decidim::FilterableResource
11
+ include Decidim::Traceable
10
12
 
11
13
  component_manifest_name "accountability"
12
14
 
@@ -18,8 +20,10 @@ module Decidim
18
20
  validates :name, presence: true
19
21
 
20
22
  # Allow ransacker to search for a key in a hstore column (`name`.`en`)
21
- ransacker :name do |parent|
22
- Arel::Nodes::InfixOperation.new("->>", parent.table[:name], Arel::Nodes.build_quoted(I18n.locale.to_s))
23
+ ransacker_i18n :name
24
+
25
+ def self.log_presenter_class_for(_log)
26
+ Decidim::Accountability::AdminLog::StatusPresenter
23
27
  end
24
28
  end
25
29
  end
@@ -6,9 +6,15 @@ module Decidim
6
6
  # It stores a date, and localized description.
7
7
  class TimelineEntry < Accountability::ApplicationRecord
8
8
  include Decidim::TranslatableResource
9
+ include Decidim::Traceable
9
10
 
11
+ translatable_fields :title
10
12
  translatable_fields :description
11
13
  belongs_to :result, foreign_key: "decidim_accountability_result_id", class_name: "Decidim::Accountability::Result", inverse_of: :timeline_entries
14
+
15
+ def self.log_presenter_class_for(_log)
16
+ Decidim::Accountability::AdminLog::TimelineEntryPresenter
17
+ end
12
18
  end
13
19
  end
14
20
  end
@@ -30,10 +30,9 @@ module Decidim
30
30
 
31
31
  def can_perform_actions_on?(subject, resource)
32
32
  return unless permission_action.subject == subject
33
- return false if can_create_grandchildren_results?
34
33
 
35
34
  case permission_action.action
36
- when :create, :create_children
35
+ when :create
37
36
  true
38
37
  when :update, :destroy
39
38
  resource.present?
@@ -41,11 +40,6 @@ module Decidim
41
40
  false
42
41
  end
43
42
  end
44
-
45
- def can_create_grandchildren_results?
46
- result&.parent&.present? &&
47
- permission_action.action == :create_children
48
- end
49
43
  end
50
44
  end
51
45
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Accountability
5
+ module AdminLog
6
+ # This class holds the logic to present a `Decidim::Accountability::Status`
7
+ # for the `AdminLog` log.
8
+ #
9
+ # Usage should be automatic and you shouldn't need to call this class
10
+ # directly, but here's an example:
11
+ #
12
+ # action_log = Decidim::ActionLog.last
13
+ # view_helpers # => this comes from the views
14
+ # StatusPresenter.new(action_log, view_helpers).present
15
+ class StatusPresenter < Decidim::Log::BasePresenter
16
+ private
17
+
18
+ def action_string
19
+ case action
20
+ when "create", "delete", "update"
21
+ "decidim.accountability.admin_log.status.#{action}"
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+ def diff_fields_mapping
28
+ {
29
+ key: :string,
30
+ name: :i18n,
31
+ description: :i18n,
32
+ progress: :integer
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Accountability
5
+ module AdminLog
6
+ # This class holds the logic to present a `Decidim::Accountability::TimelineEntry`
7
+ # for the `AdminLog` log.
8
+ #
9
+ # Usage should be automatic and you shouldn't need to call this class
10
+ # directly, but here's an example:
11
+ #
12
+ # action_log = Decidim::ActionLog.last
13
+ # view_helpers # => this comes from the views
14
+ # TimelineEntryPresenter.new(action_log, view_helpers).present
15
+ class TimelineEntryPresenter < Decidim::Log::BasePresenter
16
+ private
17
+
18
+ def action_string
19
+ case action
20
+ when "create", "delete", "update"
21
+ "decidim.accountability.admin_log.timeline_entry.#{action}"
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+ def diff_fields_mapping
28
+ {
29
+ entry_date: :date,
30
+ description: :i18n,
31
+ title: :i18n
32
+ }
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -22,12 +22,16 @@ module Decidim
22
22
  attr_reader :component, :scope_id, :category_id
23
23
 
24
24
  def results
25
- @results ||= ResultSearch.new(
26
- component: component,
27
- scope_id: scope_id,
28
- category_id: category_id,
29
- deep_search: false
30
- ).results
25
+ @results ||= begin
26
+ query = Result.where(
27
+ parent_id: nil,
28
+ component: component
29
+ )
30
+ query = query.with_any_scope(scope_id) if scope_id
31
+ query = query.with_any_category(category_id) if category_id
32
+
33
+ query
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -1,4 +1,3 @@
1
- <% add_decidim_page_title(t(".title")) %>
2
1
  <%= form_tag(import_results_path, multipart: true, class: "form new_import") do %>
3
2
  <div class="card">
4
3
  <div class="card-divider">
@@ -8,13 +7,6 @@
8
7
  </div>
9
8
 
10
9
  <div class="card-section">
11
- <div class="mb-s">
12
- <p><%= t(".info",
13
- link_new_status: new_status_path,
14
- link_new_result: new_result_path,
15
- link_export_csv: link_to(t(".download_export"),exports_path(current_component, id: "results", format: "CSV"), method: :post)
16
- ).try("html_safe") %></p>
17
- </div>
18
10
  <div class="row column">
19
11
  <%= file_field_tag :csv_file %>
20
12
  </div>
@@ -24,4 +16,7 @@
24
16
  <div class="button--double form-general-submit">
25
17
  <%= submit_tag t(".import"), class: "button" %>
26
18
  </div>
19
+ <div class="import-process-info">
20
+ <%= t(".info", link_new_status: new_status_path, link_new_result: new_result_path, link_export_csv: link_to(t(".link"), exports_path(current_component, id: "results", format: "CSV"), method: :post)).try("html_safe") %>
21
+ </div>
27
22
  <% end %>
@@ -1,4 +1,3 @@
1
- <% add_decidim_page_title(t(".title")) %>
2
1
  <%= decidim_form_for(@form, html: { class: "form edit_result" }) do |f| %>
3
2
  <%= render partial: "form", object: f, locals: { title: t(".title") } %>
4
3
 
@@ -1,4 +1,3 @@
1
- <% add_decidim_page_title(t(".title")) %>
2
1
  <div class="card">
3
2
  <div class="card-divider">
4
3
  <h2 class="card-title">
@@ -75,7 +74,7 @@
75
74
  <td class="table-list__actions">
76
75
  <%= icon_link_to "eye", resource_locator(result).path, t("actions.preview", scope: "decidim.accountability"), class: "action-icon--preview", target: :blank %>
77
76
 
78
- <% if allowed_to? :create_children, :result, result: result %>
77
+ <% if allowed_to? :update, :result, result: result %>
79
78
  <%= icon_link_to "plus", results_path(parent_id: result.id), t("actions.new", scope: "decidim.accountability", name: t("models.result.name", scope: "decidim.accountability.admin")), class: "action-icon--plus" %>
80
79
  <% end %>
81
80
 
@@ -1,4 +1,3 @@
1
- <% add_decidim_page_title(t(".title")) %>
2
1
  <%= decidim_form_for(@form, html: { class: "form new_result" }) do |f| %>
3
2
  <%= render partial: "form", object: f, locals: { title: t(".title") } %>
4
3
 
@@ -1,4 +1,3 @@
1
- <% add_decidim_page_title(t(".title")) %>
2
1
  <%= decidim_form_for(@form, html: { class: "form edit_status" }) do |f| %>
3
2
  <%= render partial: "form", object: f, locals: { title: t(".title") } %>
4
3
 
@@ -1,4 +1,3 @@
1
- <% add_decidim_page_title(t(".title")) %>
2
1
  <div class="card">
3
2
  <div class="card-divider">
4
3
  <h2 class="card-title">
@@ -1,4 +1,3 @@
1
- <% add_decidim_page_title(t(".title")) %>
2
1
  <%= decidim_form_for(@form, html: { class: "form new_status" }) do |f| %>
3
2
  <%= render partial: "form", object: f, locals: { title: t(".title") } %>
4
3
 
@@ -9,7 +9,11 @@
9
9
  </div>
10
10
 
11
11
  <div class="row column">
12
- <%= form.translated :text_field, :description %>
12
+ <%= form.translated :text_field, :title %>
13
+ </div>
14
+
15
+ <div class="row column">
16
+ <%= form.translated :editor, :description %>
13
17
  </div>
14
18
  </div>
15
19
  </div>