decidim-accountability 0.26.9 → 0.27.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/accountability/highlighted_results_for_component_cell.rb +13 -1
- data/app/commands/decidim/accountability/admin/create_imported_result.rb +1 -1
- data/app/commands/decidim/accountability/admin/create_result.rb +1 -1
- data/app/commands/decidim/accountability/admin/create_status.rb +6 -3
- data/app/commands/decidim/accountability/admin/create_timeline_entry.rb +11 -7
- data/app/commands/decidim/accountability/admin/destroy_result.rb +1 -1
- data/app/commands/decidim/accountability/admin/update_imported_result.rb +1 -1
- data/app/commands/decidim/accountability/admin/update_result.rb +1 -1
- data/app/commands/decidim/accountability/admin/update_status.rb +6 -3
- data/app/commands/decidim/accountability/admin/update_timeline_entry.rb +9 -5
- data/app/controllers/decidim/accountability/admin/statuses_controller.rb +5 -3
- data/app/controllers/decidim/accountability/admin/timeline_entries_controller.rb +5 -3
- data/app/controllers/decidim/accountability/results_controller.rb +12 -12
- data/app/forms/decidim/accountability/admin/result_form.rb +2 -2
- data/app/forms/decidim/accountability/admin/timeline_entry_form.rb +2 -1
- data/app/helpers/decidim/accountability/breadcrumb_helper.rb +2 -2
- data/app/models/decidim/accountability/result.rb +9 -5
- data/app/models/decidim/accountability/status.rb +6 -2
- data/app/models/decidim/accountability/timeline_entry.rb +6 -0
- data/app/permissions/decidim/accountability/admin/permissions.rb +1 -7
- data/app/presenters/decidim/accountability/admin_log/status_presenter.rb +38 -0
- data/app/presenters/decidim/accountability/admin_log/timeline_entry_presenter.rb +37 -0
- data/app/services/decidim/accountability/results_calculator.rb +10 -6
- data/app/views/decidim/accountability/admin/import_results/new.html.erb +3 -8
- data/app/views/decidim/accountability/admin/results/edit.html.erb +0 -1
- data/app/views/decidim/accountability/admin/results/index.html.erb +1 -2
- data/app/views/decidim/accountability/admin/results/new.html.erb +0 -1
- data/app/views/decidim/accountability/admin/statuses/edit.html.erb +0 -1
- data/app/views/decidim/accountability/admin/statuses/index.html.erb +0 -1
- data/app/views/decidim/accountability/admin/statuses/new.html.erb +0 -1
- data/app/views/decidim/accountability/admin/timeline_entries/_form.html.erb +5 -1
- data/app/views/decidim/accountability/admin/timeline_entries/index.html.erb +3 -3
- data/app/views/decidim/accountability/results/_home_categories.html.erb +2 -2
- data/app/views/decidim/accountability/results/_nav_breadcrumb.html.erb +3 -3
- data/app/views/decidim/accountability/results/_results_leaf.html.erb +3 -3
- data/app/views/decidim/accountability/results/_results_parent.html.erb +1 -1
- data/app/views/decidim/accountability/results/_scope_filters.html.erb +3 -3
- data/app/views/decidim/accountability/results/_search.html.erb +1 -1
- data/app/views/decidim/accountability/results/_show_leaf.html.erb +2 -2
- data/app/views/decidim/accountability/results/_timeline.html.erb +8 -2
- data/app/views/decidim/accountability/results/home.html.erb +3 -1
- data/app/views/decidim/accountability/versions/show.html.erb +3 -1
- data/app/views/decidim/participatory_spaces/_result.html.erb +2 -2
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +24 -41
- data/config/locales/bg.yml +3 -1
- data/config/locales/ca.yml +13 -23
- data/config/locales/cs.yml +13 -23
- data/config/locales/da.yml +3 -1
- data/config/locales/de.yml +13 -23
- data/config/locales/el.yml +3 -2
- data/config/locales/en.yml +12 -23
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +13 -23
- data/config/locales/es-PY.yml +13 -23
- data/config/locales/es.yml +13 -23
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +52 -72
- data/config/locales/fi-plain.yml +13 -23
- data/config/locales/fi.yml +19 -29
- data/config/locales/fr-CA.yml +13 -23
- data/config/locales/fr.yml +13 -23
- data/config/locales/ga-IE.yml +2 -0
- data/config/locales/gl.yml +3 -1
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +12 -32
- data/config/locales/id-ID.yml +1 -1
- data/config/locales/is-IS.yml +3 -2
- data/config/locales/it.yml +3 -1
- data/config/locales/ja.yml +14 -24
- data/config/locales/ko.yml +1 -14
- data/config/locales/lb.yml +3 -1
- data/config/locales/lt.yml +13 -23
- data/config/locales/lv.yml +3 -1
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +2 -1
- data/config/locales/no.yml +11 -9
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +13 -2
- data/config/locales/pt-BR.yml +4 -26
- data/config/locales/pt.yml +3 -1
- data/config/locales/ro-RO.yml +9 -8
- data/config/locales/ru.yml +1 -1
- data/config/locales/si-LK.yml +2 -1
- data/config/locales/sk.yml +2 -1
- data/config/locales/sl.yml +2 -1
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +1 -1
- data/config/locales/sv.yml +5 -23
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +3 -25
- data/config/locales/uk.yml +1 -1
- data/config/locales/val-ES.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +2 -1
- data/config/locales/zh-TW.yml +1 -267
- data/db/migrate/20220331150008_add_title_to_timeline_entries.rb +7 -0
- data/db/migrate/20220331150155_move_legacy_description_to_title_of_timeline_entries.rb +13 -0
- data/lib/decidim/accountability/component.rb +2 -1
- data/lib/decidim/accountability/test/factories.rb +1 -0
- data/lib/decidim/accountability/version.rb +1 -1
- data/lib/decidim/api/timeline_entry_type.rb +1 -0
- metadata +28 -34
- data/app/services/decidim/accountability/result_search.rb +0 -48
- data/config/environment.rb +0 -3
- data/config/locales/fa-IR.yml +0 -1
- data/config/locales/gn-PY.yml +0 -15
- data/config/locales/ka-GE.yml +0 -1
- data/config/locales/kaa.yml +0 -89
- data/config/locales/lo-LA.yml +0 -1
- data/config/locales/oc-FR.yml +0 -1
- data/config/locales/sq-AL.yml +0 -212
- data/config/locales/th-TH.yml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c075f66ece3b892202c3936512fe378f3badd528a66d50e27c3b05e0139b330
|
4
|
+
data.tar.gz: 888ec8f73f7b72a36167359670cffb1228bfa30c29ed7f35f73213d30db35864
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 <
|
8
|
+
class CreateImportedResult < Decidim::Command
|
9
9
|
def initialize(form, parent_id = nil)
|
10
10
|
@form = form
|
11
11
|
@parent_id = parent_id
|
@@ -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 <
|
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 =
|
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 <
|
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 =
|
32
|
-
|
33
|
-
|
34
|
-
|
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 <
|
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 <
|
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 <
|
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 <
|
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
|
-
|
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 <
|
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
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
21
|
-
|
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 ||=
|
29
|
+
@result ||= search_collection.includes(:timeline_entries).find_by(id: params[:id])
|
26
30
|
end
|
27
31
|
|
28
|
-
def
|
29
|
-
|
32
|
+
def search_collection
|
33
|
+
Result.where(component: current_component)
|
30
34
|
end
|
31
35
|
|
32
36
|
def default_filter_params
|
33
37
|
{
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
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 :
|
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][:
|
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, :
|
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::
|
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
|
-
#
|
89
|
-
|
90
|
-
|
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
|
-
|
22
|
-
|
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
|
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 ||=
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
<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? :
|
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
|
|
@@ -9,7 +9,11 @@
|
|
9
9
|
</div>
|
10
10
|
|
11
11
|
<div class="row column">
|
12
|
-
<%= form.translated :text_field, :
|
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>
|