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.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/accountability/highlighted_results_for_component_cell.rb +0 -3
  3. data/app/cells/decidim/accountability/project_cell.rb +1 -6
  4. data/app/cells/decidim/accountability/result_l_cell.rb +1 -2
  5. data/app/cells/decidim/accountability/result_metadata_cell.rb +0 -6
  6. data/app/cells/decidim/accountability/results_cell.rb +0 -2
  7. data/app/cells/decidim/accountability/status_cell.rb +11 -8
  8. data/app/commands/decidim/accountability/admin/create_imported_result.rb +18 -85
  9. data/app/commands/decidim/accountability/admin/create_result.rb +12 -86
  10. data/app/commands/decidim/accountability/admin/create_status.rb +3 -31
  11. data/app/commands/decidim/accountability/admin/create_timeline_entry.rb +3 -30
  12. data/app/commands/decidim/accountability/admin/has_result_command.rb +54 -0
  13. data/app/commands/decidim/accountability/admin/update_imported_result.rb +16 -70
  14. data/app/commands/decidim/accountability/admin/update_result.rb +10 -72
  15. data/app/commands/decidim/accountability/admin/update_status.rb +3 -39
  16. data/app/commands/decidim/accountability/admin/update_timeline_entry.rb +3 -38
  17. data/app/controllers/decidim/accountability/admin/results_controller.rb +1 -1
  18. data/app/controllers/decidim/accountability/admin/statuses_controller.rb +7 -8
  19. data/app/controllers/decidim/accountability/admin/timeline_entries_controller.rb +8 -8
  20. data/app/controllers/decidim/accountability/results_controller.rb +1 -21
  21. data/app/forms/decidim/accountability/admin/result_form.rb +1 -1
  22. data/app/forms/decidim/accountability/admin/timeline_entry_form.rb +1 -1
  23. data/app/helpers/decidim/accountability/application_helper.rb +0 -34
  24. data/app/helpers/decidim/accountability/breadcrumb_helper.rb +0 -4
  25. data/app/mailers/decidim/accountability/import_projects_mailer.rb +0 -3
  26. data/app/models/decidim/accountability/result.rb +1 -1
  27. data/app/models/decidim/accountability/status.rb +1 -1
  28. data/app/packs/src/decidim/accountability/index.js +1 -1
  29. data/app/services/decidim/accountability/results_csv_importer.rb +1 -1
  30. data/app/views/decidim/accountability/admin/results/index.html.erb +7 -15
  31. data/app/views/decidim/accountability/admin/statuses/index.html.erb +2 -2
  32. data/app/views/decidim/accountability/admin/timeline_entries/index.html.erb +1 -1
  33. data/app/views/decidim/accountability/import_projects_mailer/import.html.erb +1 -1
  34. data/app/views/decidim/accountability/results/_home_categories.html.erb +2 -2
  35. data/app/views/decidim/accountability/results/_nav_breadcrumb.html.erb +8 -8
  36. data/app/views/decidim/accountability/results/_project.html.erb +1 -1
  37. data/app/views/decidim/accountability/results/_scope_filters.html.erb +3 -3
  38. data/app/views/decidim/participatory_spaces/_result.html.erb +3 -3
  39. data/config/locales/ar.yml +13 -90
  40. data/config/locales/bg.yml +10 -15
  41. data/config/locales/ca.yml +0 -12
  42. data/config/locales/cs.yml +0 -13
  43. data/config/locales/da.yml +4 -27
  44. data/config/locales/de.yml +3 -15
  45. data/config/locales/el.yml +8 -12
  46. data/config/locales/en.yml +0 -12
  47. data/config/locales/es-MX.yml +0 -12
  48. data/config/locales/es-PY.yml +0 -12
  49. data/config/locales/es.yml +0 -12
  50. data/config/locales/eu.yml +34 -46
  51. data/config/locales/fi-plain.yml +4 -16
  52. data/config/locales/fi.yml +15 -27
  53. data/config/locales/fr-CA.yml +8 -21
  54. data/config/locales/fr.yml +5 -18
  55. data/config/locales/ga-IE.yml +3 -11
  56. data/config/locales/gl.yml +6 -18
  57. data/config/locales/gn-PY.yml +0 -11
  58. data/config/locales/he-IL.yml +8 -14
  59. data/config/locales/hu.yml +11 -16
  60. data/config/locales/id-ID.yml +3 -21
  61. data/config/locales/is-IS.yml +6 -18
  62. data/config/locales/it.yml +3 -72
  63. data/config/locales/ja.yml +1 -13
  64. data/config/locales/kaa.yml +2 -2
  65. data/config/locales/ko.yml +6 -12
  66. data/config/locales/lb.yml +7 -19
  67. data/config/locales/lt.yml +10 -12
  68. data/config/locales/lv.yml +3 -24
  69. data/config/locales/nl.yml +3 -15
  70. data/config/locales/no.yml +3 -15
  71. data/config/locales/pl.yml +9 -12
  72. data/config/locales/pt-BR.yml +10 -16
  73. data/config/locales/pt.yml +0 -18
  74. data/config/locales/ro-RO.yml +16 -22
  75. data/config/locales/ru.yml +4 -22
  76. data/config/locales/si-LK.yml +0 -19
  77. data/config/locales/sk.yml +3 -24
  78. data/config/locales/sl.yml +3 -17
  79. data/config/locales/sq-AL.yml +7 -12
  80. data/config/locales/sr-CS.yml +3 -21
  81. data/config/locales/sv.yml +29 -80
  82. data/config/locales/th-TH.yml +6 -6
  83. data/config/locales/tr-TR.yml +6 -19
  84. data/config/locales/uk.yml +3 -24
  85. data/config/locales/zh-CN.yml +3 -23
  86. data/config/locales/zh-TW.yml +7 -12
  87. data/decidim-accountability.gemspec +2 -2
  88. data/lib/decidim/accountability/component.rb +0 -4
  89. data/lib/decidim/accountability/seeds.rb +76 -67
  90. data/lib/decidim/accountability/test/factories.rb +0 -4
  91. data/lib/decidim/accountability/version.rb +1 -1
  92. data/lib/decidim/api/accountability_type.rb +3 -1
  93. data/lib/decidim/api/result_type.rb +1 -1
  94. metadata +26 -31
  95. data/app/commands/decidim/accountability/admin/destroy_result.rb +0 -43
  96. data/app/services/decidim/accountability/result_stats_calculator.rb +0 -49
  97. data/app/views/decidim/accountability/results/_stats_box.html.erb +0 -79
  98. data/config/locales/bn-BD.yml +0 -1
  99. data/config/locales/bs-BA.yml +0 -175
  100. data/config/locales/ca-IT.yml +0 -304
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d682ce8d4abee7a0a97537d2b3a6f80d3b2e2d378b6c0c04d9bca20bcebca21
4
- data.tar.gz: 9ff2bff902e26ee2cf6c07e6729d022fb6e5723db6b33fe2ff34f14f6e667cc6
3
+ metadata.gz: e5066128dfe96611650d7c9136807b2a466eb4620811a7d0ce3cb21cc260f71f
4
+ data.tar.gz: 178b5e88b8d8c1a675111acf39f98a76cff77f7762cd188a780a0e3ac06d46b6
5
5
  SHA512:
6
- metadata.gz: 4cdfab5c8f8555a9a102265af88a97b054e7c65b7c5fd5886c23a0e966f6c3f88106b381805aa2354e2197d6b9204d7d50e725aa90d3ce905e4b14dd55d6684f
7
- data.tar.gz: c096120b0edb9151d677564bd0ec7d49f7e50a8515a9efde7ef8dfd01060d4628878f47dd5ef05a5d458d318470bf277f821ea9befc8e0312bdb57910de3aa6a
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,8 +6,6 @@ module Decidim
6
6
  module Accountability
7
7
  # This cell renders a list of results
8
8
  class ResultsCell < Decidim::ViewModel
9
- include Decidim::CardHelper
10
-
11
9
  alias results model
12
10
  end
13
11
  end
@@ -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
- decidim_html_escape translated_attribute(model.name)
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::Command
9
- def initialize(form, parent_id = nil)
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
- # Creates the result if valid.
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
- transaction do
21
- create_result
22
- link_meetings
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 :result
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 meetings
74
- @meetings ||= result.sibling_scope(:meetings).where(id: meeting_ids)
75
- end
24
+ def resource_class = Decidim::Accountability::Result
76
25
 
77
- def link_proposals
78
- result.link_resources(proposals, "included_proposals")
79
- end
26
+ def extra_params = { visibility: "all" }
80
27
 
81
- def link_projects
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 notify_proposal_followers
90
- proposals.each do |proposal|
91
- Decidim::EventsManager.publish(
92
- event: "decidim.events.accountability.proposal_linked",
93
- event_class: Decidim::Accountability::ProposalLinkedEvent,
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::Command
9
- def initialize(form)
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
- transaction do
20
- create_result
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
- attr_reader :result
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
- @result = Decidim.traceability.create!(
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 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
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 notify_proposal_followers
89
- proposals.each do |proposal|
90
- Decidim::EventsManager.publish(
91
- event: "decidim.events.accountability.proposal_linked",
92
- event_class: Decidim::Accountability::ProposalLinkedEvent,
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::Command
9
- def initialize(form, user)
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
- attr_reader :status
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::Command
9
- def initialize(form, user)
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
- attr_reader :timeline_entry, :form
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 changes a Result from the admin
7
- # panel.
8
- class UpdateImportedResult < Decidim::Command
9
- # Initializes an UpdateResult Command.
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
- @form = form
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
- attr_reader :result, :form
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 link_meetings
85
- result.link_resources(meetings, "meetings_through_proposals")
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