decidim-accountability 0.28.6 → 0.29.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.
- checksums.yaml +4 -4
- data/app/cells/decidim/accountability/highlighted_results_for_component_cell.rb +0 -3
- data/app/cells/decidim/accountability/project_cell.rb +1 -6
- data/app/cells/decidim/accountability/result_l_cell.rb +1 -2
- data/app/cells/decidim/accountability/result_metadata_cell.rb +0 -6
- data/app/cells/decidim/accountability/results_cell.rb +0 -2
- data/app/cells/decidim/accountability/status_cell.rb +11 -8
- data/app/commands/decidim/accountability/admin/create_imported_result.rb +18 -85
- data/app/commands/decidim/accountability/admin/create_result.rb +12 -86
- data/app/commands/decidim/accountability/admin/create_status.rb +3 -31
- data/app/commands/decidim/accountability/admin/create_timeline_entry.rb +3 -30
- data/app/commands/decidim/accountability/admin/has_result_command.rb +54 -0
- data/app/commands/decidim/accountability/admin/update_imported_result.rb +16 -70
- data/app/commands/decidim/accountability/admin/update_result.rb +10 -72
- data/app/commands/decidim/accountability/admin/update_status.rb +3 -39
- data/app/commands/decidim/accountability/admin/update_timeline_entry.rb +3 -38
- data/app/controllers/decidim/accountability/admin/results_controller.rb +1 -1
- data/app/controllers/decidim/accountability/admin/statuses_controller.rb +7 -8
- data/app/controllers/decidim/accountability/admin/timeline_entries_controller.rb +8 -8
- data/app/controllers/decidim/accountability/results_controller.rb +1 -21
- data/app/forms/decidim/accountability/admin/result_form.rb +1 -1
- data/app/forms/decidim/accountability/admin/timeline_entry_form.rb +1 -1
- data/app/helpers/decidim/accountability/application_helper.rb +0 -34
- data/app/helpers/decidim/accountability/breadcrumb_helper.rb +0 -4
- data/app/mailers/decidim/accountability/import_projects_mailer.rb +0 -3
- data/app/models/decidim/accountability/result.rb +1 -1
- data/app/models/decidim/accountability/status.rb +1 -1
- data/app/packs/src/decidim/accountability/index.js +1 -1
- data/app/services/decidim/accountability/results_csv_importer.rb +1 -1
- data/app/views/decidim/accountability/admin/results/index.html.erb +7 -15
- data/app/views/decidim/accountability/admin/statuses/index.html.erb +2 -2
- data/app/views/decidim/accountability/admin/timeline_entries/index.html.erb +1 -1
- data/app/views/decidim/accountability/import_projects_mailer/import.html.erb +1 -1
- data/app/views/decidim/accountability/results/_home_categories.html.erb +2 -2
- data/app/views/decidim/accountability/results/_nav_breadcrumb.html.erb +8 -8
- data/app/views/decidim/accountability/results/_project.html.erb +1 -1
- data/app/views/decidim/accountability/results/_scope_filters.html.erb +3 -3
- data/app/views/decidim/participatory_spaces/_result.html.erb +3 -3
- data/config/locales/ar.yml +13 -90
- data/config/locales/bg.yml +10 -15
- data/config/locales/ca.yml +0 -12
- data/config/locales/cs.yml +0 -13
- data/config/locales/da.yml +4 -27
- data/config/locales/de.yml +3 -15
- data/config/locales/el.yml +8 -12
- data/config/locales/en.yml +0 -12
- data/config/locales/es-MX.yml +0 -12
- data/config/locales/es-PY.yml +0 -12
- data/config/locales/es.yml +0 -12
- data/config/locales/eu.yml +34 -46
- data/config/locales/fi-plain.yml +4 -16
- data/config/locales/fi.yml +15 -27
- data/config/locales/fr-CA.yml +8 -21
- data/config/locales/fr.yml +5 -18
- data/config/locales/ga-IE.yml +3 -11
- data/config/locales/gl.yml +6 -18
- data/config/locales/gn-PY.yml +0 -11
- data/config/locales/he-IL.yml +8 -14
- data/config/locales/hu.yml +11 -16
- data/config/locales/id-ID.yml +3 -21
- data/config/locales/is-IS.yml +6 -18
- data/config/locales/it.yml +3 -72
- data/config/locales/ja.yml +1 -13
- data/config/locales/kaa.yml +2 -2
- data/config/locales/ko.yml +6 -12
- data/config/locales/lb.yml +7 -19
- data/config/locales/lt.yml +10 -12
- data/config/locales/lv.yml +3 -24
- data/config/locales/nl.yml +3 -15
- data/config/locales/no.yml +3 -15
- data/config/locales/pl.yml +9 -12
- data/config/locales/pt-BR.yml +10 -16
- data/config/locales/pt.yml +0 -18
- data/config/locales/ro-RO.yml +16 -22
- data/config/locales/ru.yml +4 -22
- data/config/locales/si-LK.yml +0 -19
- data/config/locales/sk.yml +3 -24
- data/config/locales/sl.yml +3 -17
- data/config/locales/sq-AL.yml +7 -12
- data/config/locales/sr-CS.yml +3 -21
- data/config/locales/sv.yml +29 -80
- data/config/locales/th-TH.yml +6 -6
- data/config/locales/tr-TR.yml +6 -19
- data/config/locales/uk.yml +3 -24
- data/config/locales/zh-CN.yml +3 -23
- data/config/locales/zh-TW.yml +7 -12
- data/decidim-accountability.gemspec +2 -2
- data/lib/decidim/accountability/component.rb +0 -4
- data/lib/decidim/accountability/seeds.rb +76 -67
- data/lib/decidim/accountability/test/factories.rb +0 -4
- data/lib/decidim/accountability/version.rb +1 -1
- data/lib/decidim/api/accountability_type.rb +3 -1
- data/lib/decidim/api/result_type.rb +1 -1
- metadata +26 -31
- data/app/commands/decidim/accountability/admin/destroy_result.rb +0 -43
- data/app/services/decidim/accountability/result_stats_calculator.rb +0 -49
- data/app/views/decidim/accountability/results/_stats_box.html.erb +0 -79
- data/config/locales/bn-BD.yml +0 -1
- data/config/locales/bs-BA.yml +0 -175
- data/config/locales/ca-IT.yml +0 -304
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5066128dfe96611650d7c9136807b2a466eb4620811a7d0ce3cb21cc260f71f
|
4
|
+
data.tar.gz: 178b5e88b8d8c1a675111acf39f98a76cff77f7762cd188a780a0e3ac06d46b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc439260b2cd7806e116f3dc11ef2ed7188d698fd21de653074e531e5a4c613f725162bf2cb4a98e4a91421dcaa5d0e7e2477264b7225c7f86ef4d0b7e46ac63
|
7
|
+
data.tar.gz: 78df80399a808127946f638f8489d45b178f7efad952493d3d2082fc77911edd84b6a8e0c79c300859c2b3c2774b950b4b8b1ecc147ed097a7103fffa4f61386
|
@@ -8,10 +8,7 @@ module Decidim
|
|
8
8
|
# It is intended to be used in the `participatory_space_highlighted_elements`
|
9
9
|
# view hook.
|
10
10
|
class HighlightedResultsForComponentCell < Decidim::ViewModel
|
11
|
-
include ActiveSupport::NumberHelper
|
12
11
|
include Decidim::Accountability::ApplicationHelper
|
13
|
-
include Decidim::ComponentPathHelper
|
14
|
-
include Decidim::LayoutHelper
|
15
12
|
include Cell::ViewModel::Partial
|
16
13
|
|
17
14
|
delegate :snippets, to: :controller
|
@@ -6,12 +6,7 @@ module Decidim
|
|
6
6
|
module Accountability
|
7
7
|
# This cell renders a project
|
8
8
|
class ProjectCell < Decidim::ViewModel
|
9
|
-
include ApplicationHelper
|
10
|
-
include Decidim::ResourceHelper
|
11
|
-
include Decidim::TranslationsHelper
|
12
|
-
include Decidim::AttachmentsHelper
|
13
|
-
|
14
|
-
delegate :current_component, :component_settings, to: :controller
|
9
|
+
include Decidim::Accountability::ApplicationHelper
|
15
10
|
delegate :children, :timeline_entries, to: :model
|
16
11
|
|
17
12
|
alias result model
|
@@ -7,8 +7,7 @@ module Decidim
|
|
7
7
|
# This cell renders the List (:l) result card
|
8
8
|
# for an instance of a Result
|
9
9
|
class ResultLCell < Decidim::CardLCell
|
10
|
-
include ApplicationHelper
|
11
|
-
include ActiveSupport::NumberHelper
|
10
|
+
include Decidim::Accountability::ApplicationHelper
|
12
11
|
|
13
12
|
alias result model
|
14
13
|
|
@@ -4,13 +4,7 @@ module Decidim
|
|
4
4
|
module Accountability
|
5
5
|
# This cell renders metadata for an instance of a Result
|
6
6
|
class ResultMetadataCell < Decidim::CardMetadataCell
|
7
|
-
include Decidim::SanitizeHelper
|
8
|
-
include Decidim::TranslationsHelper
|
9
|
-
include ActiveSupport::NumberHelper
|
10
|
-
include Decidim::ResourceReferenceHelper
|
11
|
-
include Decidim::ResourceVersionsHelper
|
12
7
|
include Decidim::Accountability::Engine.routes.url_helpers
|
13
|
-
include Decidim::LayoutHelper
|
14
8
|
|
15
9
|
delegate :start_date, :end_date, :status, :category, :parent, :reference, to: :model
|
16
10
|
|
@@ -6,15 +6,10 @@ module Decidim
|
|
6
6
|
module Accountability
|
7
7
|
# This cell renders the status of a category
|
8
8
|
class StatusCell < Decidim::ViewModel
|
9
|
-
include ApplicationHelper
|
10
|
-
include BreadcrumbHelper
|
11
|
-
include Decidim::SanitizeHelper
|
12
|
-
include Decidim::TranslationsHelper
|
13
|
-
include ActiveSupport::NumberHelper
|
9
|
+
include Decidim::Accountability::ApplicationHelper
|
10
|
+
include Decidim::Accountability::BreadcrumbHelper
|
14
11
|
include ActionView::Helpers::NumberHelper
|
15
12
|
|
16
|
-
delegate :current_component, :component_settings, to: :controller
|
17
|
-
|
18
13
|
def show
|
19
14
|
return unless render?
|
20
15
|
|
@@ -41,7 +36,7 @@ module Decidim
|
|
41
36
|
|
42
37
|
def title
|
43
38
|
if model.is_a? Decidim::Category
|
44
|
-
|
39
|
+
decidim_escape_translated(model.name)
|
45
40
|
else
|
46
41
|
options[:title]
|
47
42
|
end
|
@@ -75,6 +70,14 @@ module Decidim
|
|
75
70
|
display_count(results_count)
|
76
71
|
end
|
77
72
|
|
73
|
+
def display_count(count)
|
74
|
+
heading_parent_level_results(count)
|
75
|
+
end
|
76
|
+
|
77
|
+
def heading_parent_level_results(count)
|
78
|
+
t("results.count.results_count", scope: "decidim.accountability", count:)
|
79
|
+
end
|
80
|
+
|
78
81
|
def render_count
|
79
82
|
return true unless options.has_key?(:render_count)
|
80
83
|
|
@@ -4,101 +4,34 @@ module Decidim
|
|
4
4
|
module Accountability
|
5
5
|
module Admin
|
6
6
|
# This command is executed when the user creates a Result from the admin
|
7
|
-
# panel
|
8
|
-
class CreateImportedResult < Decidim::
|
9
|
-
|
10
|
-
@form = form
|
11
|
-
@parent_id = parent_id
|
12
|
-
end
|
7
|
+
# panel using the "Import results from CSV file" feature
|
8
|
+
class CreateImportedResult < Decidim::Commands::CreateResource
|
9
|
+
include Decidim::Accountability::Admin::HasResultCommand
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
# Broadcasts :ok if successful, :invalid otherwise.
|
17
|
-
def call
|
18
|
-
return broadcast(:invalid) if @form.invalid?
|
11
|
+
fetch_form_attributes :scope, :component, :category, :parent_id, :title, :description, :start_date,
|
12
|
+
:end_date, :progress, :decidim_accountability_status_id, :external_id, :weight
|
19
13
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
link_proposals
|
24
|
-
link_projects
|
25
|
-
notify_proposal_followers
|
26
|
-
end
|
27
|
-
|
28
|
-
broadcast(:ok)
|
14
|
+
def initialize(form, parent_id = nil)
|
15
|
+
super(form)
|
16
|
+
@parent_id = parent_id
|
29
17
|
end
|
30
18
|
|
31
19
|
private
|
32
20
|
|
33
|
-
attr_reader :
|
34
|
-
|
35
|
-
def create_result
|
36
|
-
params = {
|
37
|
-
component: @form.current_component,
|
38
|
-
scope: @form.scope,
|
39
|
-
category: @form.category,
|
40
|
-
parent_id: @parent_id,
|
41
|
-
title: @form.title,
|
42
|
-
description: @form.description,
|
43
|
-
start_date: @form.start_date,
|
44
|
-
end_date: @form.end_date,
|
45
|
-
progress: @form.progress,
|
46
|
-
decidim_accountability_status_id: @form.decidim_accountability_status_id,
|
47
|
-
external_id: @form.external_id.presence,
|
48
|
-
weight: @form.weight
|
49
|
-
}
|
50
|
-
|
51
|
-
@result = Decidim.traceability.create!(
|
52
|
-
Result,
|
53
|
-
@form.current_user,
|
54
|
-
params,
|
55
|
-
visibility: "all"
|
56
|
-
)
|
57
|
-
end
|
58
|
-
|
59
|
-
def proposals
|
60
|
-
@proposals ||= result.sibling_scope(:proposals).where(id: @form.proposal_ids)
|
61
|
-
end
|
62
|
-
|
63
|
-
def projects
|
64
|
-
@projects ||= result.sibling_scope(:projects).where(id: @form.project_ids)
|
65
|
-
end
|
66
|
-
|
67
|
-
def meeting_ids
|
68
|
-
@meeting_ids ||= proposals.flat_map do |proposal|
|
69
|
-
proposal.linked_resources(:meetings, "proposals_from_meeting").pluck(:id)
|
70
|
-
end.uniq
|
71
|
-
end
|
21
|
+
attr_reader :parent_id
|
22
|
+
alias result resource
|
72
23
|
|
73
|
-
def
|
74
|
-
@meetings ||= result.sibling_scope(:meetings).where(id: meeting_ids)
|
75
|
-
end
|
24
|
+
def resource_class = Decidim::Accountability::Result
|
76
25
|
|
77
|
-
def
|
78
|
-
result.link_resources(proposals, "included_proposals")
|
79
|
-
end
|
26
|
+
def extra_params = { visibility: "all" }
|
80
27
|
|
81
|
-
def
|
82
|
-
result.link_resources(projects, "included_projects")
|
83
|
-
end
|
84
|
-
|
85
|
-
def link_meetings
|
86
|
-
result.link_resources(meetings, "meetings_through_proposals")
|
87
|
-
end
|
28
|
+
def attributes = super.merge(parent_id:)
|
88
29
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
resource: result,
|
95
|
-
affected_users: proposal.notifiable_identities,
|
96
|
-
followers: proposal.followers - proposal.notifiable_identities,
|
97
|
-
extra: {
|
98
|
-
proposal_id: proposal.id
|
99
|
-
}
|
100
|
-
)
|
101
|
-
end
|
30
|
+
def run_after_hooks
|
31
|
+
link_meetings
|
32
|
+
link_proposals
|
33
|
+
link_projects
|
34
|
+
notify_proposal_followers
|
102
35
|
end
|
103
36
|
end
|
104
37
|
end
|
@@ -5,99 +5,25 @@ 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 < Decidim::
|
9
|
-
|
10
|
-
@form = form
|
11
|
-
end
|
12
|
-
|
13
|
-
# Creates the result if valid.
|
14
|
-
#
|
15
|
-
# Broadcasts :ok if successful, :invalid otherwise.
|
16
|
-
def call
|
17
|
-
return broadcast(:invalid) if @form.invalid?
|
8
|
+
class CreateResult < Decidim::Commands::CreateResource
|
9
|
+
include Decidim::Accountability::Admin::HasResultCommand
|
18
10
|
|
19
|
-
|
20
|
-
|
21
|
-
link_meetings
|
22
|
-
link_proposals
|
23
|
-
link_projects
|
24
|
-
notify_proposal_followers
|
25
|
-
end
|
26
|
-
|
27
|
-
broadcast(:ok)
|
28
|
-
end
|
11
|
+
fetch_form_attributes :scope, :component, :category, :parent_id, :title, :description, :start_date,
|
12
|
+
:end_date, :progress, :decidim_accountability_status_id, :external_id, :weight
|
29
13
|
|
30
14
|
private
|
31
15
|
|
32
|
-
|
33
|
-
|
34
|
-
def create_result
|
35
|
-
params = {
|
36
|
-
component: @form.current_component,
|
37
|
-
scope: @form.scope,
|
38
|
-
category: @form.category,
|
39
|
-
parent_id: @form.parent_id,
|
40
|
-
title: @form.title,
|
41
|
-
description: @form.description,
|
42
|
-
start_date: @form.start_date,
|
43
|
-
end_date: @form.end_date,
|
44
|
-
progress: @form.progress,
|
45
|
-
decidim_accountability_status_id: @form.decidim_accountability_status_id,
|
46
|
-
external_id: @form.external_id.presence,
|
47
|
-
weight: @form.weight
|
48
|
-
}
|
16
|
+
alias result resource
|
49
17
|
|
50
|
-
|
51
|
-
Result,
|
52
|
-
@form.current_user,
|
53
|
-
params,
|
54
|
-
visibility: "all"
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
def proposals
|
59
|
-
@proposals ||= result.sibling_scope(:proposals).where(id: @form.proposal_ids)
|
60
|
-
end
|
61
|
-
|
62
|
-
def projects
|
63
|
-
@projects ||= result.sibling_scope(:projects).where(id: @form.project_ids)
|
64
|
-
end
|
18
|
+
def resource_class = Decidim::Accountability::Result
|
65
19
|
|
66
|
-
def
|
67
|
-
@meeting_ids ||= proposals.flat_map do |proposal|
|
68
|
-
proposal.linked_resources(:meetings, "proposals_from_meeting").pluck(:id)
|
69
|
-
end.uniq
|
70
|
-
end
|
71
|
-
|
72
|
-
def meetings
|
73
|
-
@meetings ||= result.sibling_scope(:meetings).where(id: meeting_ids)
|
74
|
-
end
|
75
|
-
|
76
|
-
def link_proposals
|
77
|
-
result.link_resources(proposals, "included_proposals")
|
78
|
-
end
|
79
|
-
|
80
|
-
def link_projects
|
81
|
-
result.link_resources(projects, "included_projects")
|
82
|
-
end
|
83
|
-
|
84
|
-
def link_meetings
|
85
|
-
result.link_resources(meetings, "meetings_through_proposals")
|
86
|
-
end
|
20
|
+
def extra_params = { visibility: "all" }
|
87
21
|
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
resource: result,
|
94
|
-
affected_users: proposal.notifiable_identities,
|
95
|
-
followers: proposal.followers - proposal.notifiable_identities,
|
96
|
-
extra: {
|
97
|
-
proposal_id: proposal.id
|
98
|
-
}
|
99
|
-
)
|
100
|
-
end
|
22
|
+
def run_after_hooks
|
23
|
+
link_meetings
|
24
|
+
link_proposals
|
25
|
+
link_projects
|
26
|
+
notify_proposal_followers
|
101
27
|
end
|
102
28
|
end
|
103
29
|
end
|
@@ -5,40 +5,12 @@ 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 < Decidim::
|
9
|
-
|
10
|
-
@form = form
|
11
|
-
@user = user
|
12
|
-
end
|
13
|
-
|
14
|
-
# Creates the status if valid.
|
15
|
-
#
|
16
|
-
# Broadcasts :ok if successful, :invalid otherwise.
|
17
|
-
def call
|
18
|
-
return broadcast(:invalid) if @form.invalid?
|
19
|
-
|
20
|
-
transaction do
|
21
|
-
create_status
|
22
|
-
end
|
23
|
-
|
24
|
-
broadcast(:ok)
|
25
|
-
end
|
8
|
+
class CreateStatus < Decidim::Commands::CreateResource
|
9
|
+
fetch_form_attributes :key, :name, :description, :progress, :component
|
26
10
|
|
27
11
|
private
|
28
12
|
|
29
|
-
|
30
|
-
|
31
|
-
def create_status
|
32
|
-
@status = Decidim.traceability.create!(
|
33
|
-
Status,
|
34
|
-
@user,
|
35
|
-
component: @form.current_component,
|
36
|
-
key: @form.key,
|
37
|
-
name: @form.name,
|
38
|
-
description: @form.description,
|
39
|
-
progress: @form.progress
|
40
|
-
)
|
41
|
-
end
|
13
|
+
def resource_class = Decidim::Accountability::Status
|
42
14
|
end
|
43
15
|
end
|
44
16
|
end
|
@@ -5,39 +5,12 @@ 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 < Decidim::
|
9
|
-
|
10
|
-
@form = form
|
11
|
-
@user = user
|
12
|
-
end
|
13
|
-
|
14
|
-
# Creates the timeline_entry if valid.
|
15
|
-
#
|
16
|
-
# Broadcasts :ok if successful, :invalid otherwise.
|
17
|
-
def call
|
18
|
-
return broadcast(:invalid) if @form.invalid?
|
19
|
-
|
20
|
-
transaction do
|
21
|
-
create_timeline_entry
|
22
|
-
end
|
23
|
-
|
24
|
-
broadcast(:ok)
|
25
|
-
end
|
8
|
+
class CreateTimelineEntry < Decidim::Commands::CreateResource
|
9
|
+
fetch_form_attributes :decidim_accountability_result_id, :entry_date, :title, :description
|
26
10
|
|
27
11
|
private
|
28
12
|
|
29
|
-
|
30
|
-
|
31
|
-
def create_timeline_entry
|
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
|
39
|
-
)
|
40
|
-
end
|
13
|
+
def resource_class = Decidim::Accountability::TimelineEntry
|
41
14
|
end
|
42
15
|
end
|
43
16
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Accountability
|
5
|
+
module Admin
|
6
|
+
module HasResultCommand
|
7
|
+
def proposals
|
8
|
+
@proposals ||= resource.sibling_scope(:proposals).where(id: form.proposal_ids)
|
9
|
+
end
|
10
|
+
|
11
|
+
def projects
|
12
|
+
@projects ||= resource.sibling_scope(:projects).where(id: form.project_ids)
|
13
|
+
end
|
14
|
+
|
15
|
+
def meeting_ids
|
16
|
+
@meeting_ids ||= proposals.flat_map do |proposal|
|
17
|
+
proposal.linked_resources(:meetings, "proposals_from_meeting").pluck(:id)
|
18
|
+
end.uniq
|
19
|
+
end
|
20
|
+
|
21
|
+
def meetings
|
22
|
+
@meetings ||= resource.sibling_scope(:meetings).where(id: meeting_ids)
|
23
|
+
end
|
24
|
+
|
25
|
+
def link_proposals
|
26
|
+
resource.link_resources(proposals, "included_proposals")
|
27
|
+
end
|
28
|
+
|
29
|
+
def link_projects
|
30
|
+
resource.link_resources(projects, "included_projects")
|
31
|
+
end
|
32
|
+
|
33
|
+
def link_meetings
|
34
|
+
resource.link_resources(meetings, "meetings_through_proposals")
|
35
|
+
end
|
36
|
+
|
37
|
+
def notify_proposal_followers
|
38
|
+
proposals.each do |proposal|
|
39
|
+
Decidim::EventsManager.publish(
|
40
|
+
event: "decidim.events.accountability.proposal_linked",
|
41
|
+
event_class: Decidim::Accountability::ProposalLinkedEvent,
|
42
|
+
resource:,
|
43
|
+
affected_users: proposal.notifiable_identities,
|
44
|
+
followers: proposal.followers - proposal.notifiable_identities,
|
45
|
+
extra: {
|
46
|
+
proposal_id: proposal.id
|
47
|
+
}
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -3,86 +3,32 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Accountability
|
5
5
|
module Admin
|
6
|
-
# This command is executed when the user
|
7
|
-
# panel
|
8
|
-
class UpdateImportedResult < Decidim::
|
9
|
-
|
6
|
+
# This command is executed when the user imports a Result from the admin
|
7
|
+
# panel using the "Import results from CSV file" feature
|
8
|
+
class UpdateImportedResult < Decidim::Commands::UpdateResource
|
9
|
+
include Decidim::Accountability::Admin::HasResultCommand
|
10
|
+
|
11
|
+
fetch_form_attributes :scope, :category, :title, :description, :start_date, :end_date, :progress,
|
12
|
+
:decidim_accountability_status_id, :external_id, :weight
|
13
|
+
|
14
|
+
# Initializes an UpdateImportedResult Command.
|
10
15
|
#
|
11
16
|
# form - The form from which to get the data.
|
12
17
|
# result - The current instance of the result to be updated.
|
13
18
|
def initialize(form, result, parent_id = nil)
|
14
|
-
|
15
|
-
@result = result
|
19
|
+
super(form, result)
|
16
20
|
@parent_id = parent_id
|
17
21
|
end
|
18
22
|
|
19
|
-
# Updates the result if valid.
|
20
|
-
#
|
21
|
-
# Broadcasts :ok if successful, :invalid otherwise.
|
22
|
-
def call
|
23
|
-
return broadcast(:invalid) if form.invalid?
|
24
|
-
|
25
|
-
transaction do
|
26
|
-
update_result
|
27
|
-
link_proposals
|
28
|
-
link_meetings
|
29
|
-
link_projects
|
30
|
-
send_notifications if should_notify_followers?
|
31
|
-
end
|
32
|
-
|
33
|
-
broadcast(:ok)
|
34
|
-
end
|
35
|
-
|
36
23
|
private
|
37
24
|
|
38
|
-
|
39
|
-
|
40
|
-
def update_result
|
41
|
-
Decidim.traceability.update!(
|
42
|
-
result,
|
43
|
-
form.current_user,
|
44
|
-
scope: @form.scope,
|
45
|
-
category: @form.category,
|
46
|
-
parent_id: @parent_id,
|
47
|
-
title: @form.title,
|
48
|
-
description: @form.description,
|
49
|
-
start_date: @form.start_date,
|
50
|
-
end_date: @form.end_date,
|
51
|
-
progress: @form.progress,
|
52
|
-
decidim_accountability_status_id: @form.decidim_accountability_status_id,
|
53
|
-
external_id: @form.external_id.presence,
|
54
|
-
weight: @form.weight
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
def proposals
|
59
|
-
@proposals ||= result.sibling_scope(:proposals).where(id: form.proposal_ids)
|
60
|
-
end
|
61
|
-
|
62
|
-
def projects
|
63
|
-
@projects ||= result.sibling_scope(:projects).where(id: form.project_ids)
|
64
|
-
end
|
65
|
-
|
66
|
-
def meeting_ids
|
67
|
-
@meeting_ids ||= proposals.flat_map do |proposal|
|
68
|
-
proposal.linked_resources(:meetings, "proposals_from_meeting").pluck(:id)
|
69
|
-
end.uniq
|
70
|
-
end
|
71
|
-
|
72
|
-
def meetings
|
73
|
-
@meetings ||= result.sibling_scope(:meetings).where(id: meeting_ids)
|
74
|
-
end
|
75
|
-
|
76
|
-
def link_proposals
|
77
|
-
result.link_resources(proposals, "included_proposals")
|
78
|
-
end
|
79
|
-
|
80
|
-
def link_projects
|
81
|
-
result.link_resources(projects, "included_projects")
|
82
|
-
end
|
25
|
+
alias result resource
|
83
26
|
|
84
|
-
def
|
85
|
-
|
27
|
+
def run_after_hooks
|
28
|
+
link_proposals
|
29
|
+
link_meetings
|
30
|
+
link_projects
|
31
|
+
send_notifications if should_notify_followers?
|
86
32
|
end
|
87
33
|
|
88
34
|
def send_notifications
|