decidim-budgets 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 (137) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/budgets/budgets_header/show.erb +1 -1
  3. data/app/cells/decidim/budgets/order_activity_cell.rb +29 -0
  4. data/app/commands/decidim/budgets/add_line_item.rb +4 -2
  5. data/app/commands/decidim/budgets/admin/create_budget.rb +1 -1
  6. data/app/commands/decidim/budgets/admin/create_order_reminders.rb +66 -0
  7. data/app/commands/decidim/budgets/admin/create_project.rb +5 -2
  8. data/app/commands/decidim/budgets/admin/destroy_budget.rb +1 -1
  9. data/app/commands/decidim/budgets/admin/destroy_project.rb +1 -1
  10. data/app/commands/decidim/budgets/admin/import_proposals_to_budgets.rb +6 -6
  11. data/app/commands/decidim/budgets/admin/update_budget.rb +1 -1
  12. data/app/commands/decidim/budgets/admin/update_project.rb +5 -2
  13. data/app/commands/decidim/budgets/admin/update_project_category.rb +48 -0
  14. data/app/commands/decidim/budgets/admin/update_project_scope.rb +54 -0
  15. data/app/commands/decidim/budgets/admin/update_project_selection.rb +56 -0
  16. data/app/commands/decidim/budgets/cancel_order.rb +1 -1
  17. data/app/commands/decidim/budgets/checkout.rb +10 -3
  18. data/app/commands/decidim/budgets/remove_line_item.rb +1 -1
  19. data/app/controllers/decidim/budgets/admin/application_controller.rb +2 -0
  20. data/app/controllers/decidim/budgets/admin/attachment_collections_controller.rb +1 -3
  21. data/app/controllers/decidim/budgets/admin/attachments_controller.rb +1 -7
  22. data/app/controllers/decidim/budgets/admin/budgets_controller.rb +1 -1
  23. data/app/controllers/decidim/budgets/admin/projects_controller.rb +149 -1
  24. data/app/controllers/decidim/budgets/line_items_controller.rb +2 -2
  25. data/app/controllers/decidim/budgets/orders_controller.rb +1 -1
  26. data/app/controllers/decidim/budgets/projects_controller.rb +15 -19
  27. data/app/forms/decidim/budgets/admin/budget_form.rb +3 -4
  28. data/app/forms/decidim/budgets/admin/order_reminder_form.rb +75 -0
  29. data/app/forms/decidim/budgets/admin/project_form.rb +19 -3
  30. data/app/helpers/decidim/budgets/admin/project_bulk_actions_helper.rb +20 -0
  31. data/app/helpers/decidim/budgets/projects_helper.rb +29 -0
  32. data/app/jobs/decidim/budgets/send_vote_reminder_job.rb +16 -0
  33. data/app/mailers/decidim/budgets/vote_reminder_mailer.rb +39 -0
  34. data/app/models/decidim/budgets/order.rb +2 -4
  35. data/app/models/decidim/budgets/project.rb +14 -10
  36. data/app/packs/entrypoints/decidim_budgets_admin.js +1 -0
  37. data/app/packs/src/decidim/budgets/admin/projects.js +143 -0
  38. data/app/permissions/decidim/budgets/admin/permissions.rb +8 -3
  39. data/app/queries/decidim/budgets/filtered_projects.rb +1 -1
  40. data/app/serializers/decidim/budgets/{data_portability_budgets_order_serializer.rb → download_your_data_budgets_order_serializer.rb} +2 -2
  41. data/app/services/decidim/budgets/order_reminder_generator.rb +85 -0
  42. data/app/views/decidim/budgets/admin/budgets/_form.html.erb +1 -1
  43. data/app/views/decidim/budgets/admin/budgets/edit.html.erb +0 -1
  44. data/app/views/decidim/budgets/admin/budgets/index.html.erb +3 -1
  45. data/app/views/decidim/budgets/admin/budgets/new.html.erb +0 -1
  46. data/app/views/decidim/budgets/admin/projects/_bulk-actions.html.erb +13 -0
  47. data/app/views/decidim/budgets/admin/projects/_form.html.erb +6 -0
  48. data/app/views/decidim/budgets/admin/projects/_project-tr.html.erb +50 -0
  49. data/app/views/decidim/budgets/admin/projects/bulk_actions/_change-selected.html.erb +15 -0
  50. data/app/views/decidim/budgets/admin/projects/bulk_actions/_dropdown.html.erb +36 -0
  51. data/app/views/decidim/budgets/admin/projects/bulk_actions/_recategorize.html.erb +15 -0
  52. data/app/views/decidim/budgets/admin/projects/bulk_actions/_scope-change.html.erb +25 -0
  53. data/app/views/decidim/budgets/admin/projects/edit.html.erb +0 -1
  54. data/app/views/decidim/budgets/admin/projects/index.html.erb +6 -55
  55. data/app/views/decidim/budgets/admin/projects/new.html.erb +0 -1
  56. data/app/views/decidim/budgets/admin/projects/update_attribute.js.erb +26 -0
  57. data/app/views/decidim/budgets/admin/proposals_imports/new.html.erb +0 -1
  58. data/app/views/decidim/budgets/order_summary_mailer/order_summary.html.erb +0 -1
  59. data/app/views/decidim/budgets/projects/_filters.html.erb +4 -4
  60. data/app/views/decidim/budgets/projects/index.html.erb +28 -1
  61. data/app/views/decidim/budgets/projects/show.html.erb +7 -2
  62. data/app/views/decidim/budgets/vote_reminder_mailer/vote_reminder.html.erb +21 -0
  63. data/config/assets.rb +2 -1
  64. data/config/locales/am-ET.yml +1 -0
  65. data/config/locales/ar.yml +5 -1
  66. data/config/locales/bg.yml +1 -0
  67. data/config/locales/ca.yml +48 -5
  68. data/config/locales/cs.yml +53 -8
  69. data/config/locales/da.yml +1 -0
  70. data/config/locales/de.yml +50 -16
  71. data/config/locales/el.yml +3 -33
  72. data/config/locales/en.yml +46 -4
  73. data/config/locales/eo.yml +1 -0
  74. data/config/locales/es-MX.yml +46 -6
  75. data/config/locales/es-PY.yml +49 -6
  76. data/config/locales/es.yml +50 -7
  77. data/config/locales/et.yml +1 -0
  78. data/config/locales/eu.yml +46 -62
  79. data/config/locales/fi-plain.yml +47 -4
  80. data/config/locales/fi.yml +93 -50
  81. data/config/locales/fr-CA.yml +47 -5
  82. data/config/locales/fr.yml +48 -6
  83. data/config/locales/ga-IE.yml +2 -1
  84. data/config/locales/gl.yml +11 -0
  85. data/config/locales/hr.yml +1 -0
  86. data/config/locales/hu.yml +21 -149
  87. data/config/locales/id-ID.yml +2 -1
  88. data/config/locales/is-IS.yml +4 -2
  89. data/config/locales/it.yml +4 -2
  90. data/config/locales/ja.yml +44 -5
  91. data/config/locales/ko.yml +1 -0
  92. data/config/locales/lb.yml +5 -5
  93. data/config/locales/lt.yml +1 -338
  94. data/config/locales/lv.yml +2 -1
  95. data/config/locales/mt.yml +1 -0
  96. data/config/locales/nl.yml +16 -30
  97. data/config/locales/no.yml +18 -1
  98. data/config/locales/om-ET.yml +1 -0
  99. data/config/locales/pl.yml +3 -24
  100. data/config/locales/pt-BR.yml +4 -21
  101. data/config/locales/pt.yml +3 -3
  102. data/config/locales/ro-RO.yml +2 -3
  103. data/config/locales/ru.yml +2 -1
  104. data/config/locales/si-LK.yml +1 -0
  105. data/config/locales/sk.yml +2 -1
  106. data/config/locales/sl.yml +1 -0
  107. data/config/locales/so-SO.yml +1 -0
  108. data/config/locales/sr-CS.yml +1 -0
  109. data/config/locales/sv.yml +26 -7
  110. data/config/locales/sw-KE.yml +1 -0
  111. data/config/locales/ti-ER.yml +1 -0
  112. data/config/locales/tr-TR.yml +3 -3
  113. data/config/locales/uk.yml +3 -2
  114. data/config/locales/val-ES.yml +1 -0
  115. data/config/locales/vi.yml +1 -0
  116. data/config/locales/zh-CN.yml +1 -3
  117. data/config/locales/zh-TW.yml +1 -326
  118. data/db/migrate/20200804175222_votes_enabled_to_votes_choices.rb +2 -2
  119. data/db/migrate/20220428072638_add_geolocalization_fields_to_projects.rb +9 -0
  120. data/lib/decidim/budgets/admin_engine.rb +3 -0
  121. data/lib/decidim/budgets/component.rb +7 -6
  122. data/lib/decidim/budgets/engine.rb +17 -0
  123. data/lib/decidim/budgets/test/factories.rb +11 -0
  124. data/lib/decidim/budgets/version.rb +1 -1
  125. data/lib/decidim/budgets/workflows/all.rb +1 -1
  126. data/lib/decidim/budgets/workflows/base.rb +1 -1
  127. metadata +38 -27
  128. data/app/services/decidim/budgets/project_search.rb +0 -45
  129. data/config/environment.rb +0 -3
  130. data/config/locales/fa-IR.yml +0 -1
  131. data/config/locales/gn-PY.yml +0 -1
  132. data/config/locales/ka-GE.yml +0 -1
  133. data/config/locales/kaa.yml +0 -11
  134. data/config/locales/lo-LA.yml +0 -1
  135. data/config/locales/oc-FR.yml +0 -1
  136. data/config/locales/sq-AL.yml +0 -1
  137. data/config/locales/th-TH.yml +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd0a1fb2dce4b41d7bc04ee39f452c7294fdc00346e4a232389cb86a9a88406e
4
- data.tar.gz: b115656e85dec113373f601fe3bc851037190420da5d8a16518487ae2565366c
3
+ metadata.gz: 3fa531ee417f1965e642ac669891a7ab1705d2a39bbad0fbd20b862d2366887a
4
+ data.tar.gz: 014fee8507d07e68e6dcce958912efac0d6c4264ba08a380a4cc6bf77b95171f
5
5
  SHA512:
6
- metadata.gz: 9b1ec32da26ae5ae2c7fbf9ff40c2e262257fd91eef493368f46c44f2ebb8acc1bc65fef6adc347a5bb550889c0490b1e90101c5c4b2980f3d764e8794b435e8
7
- data.tar.gz: ca6852114e2e925cbf7b1a5012e9e836be8c60be144a40f5217fe1e6b414d2eccee70056363fd4651579b875027532fb95df1fda34f32b2c311f029869baf8a5
6
+ metadata.gz: 347007356a92385202d42ba9380cab18a1b04122a18477df5b640d54d84daf8b440a0e5c6300b3161d5d69b87b1ba5dc4dd04903be5eb0d7f68eb638df34fe5f
7
+ data.tar.gz: 5174a84a9e0a1c73efb3fd0b94c4a7ed4fc9a176891905e4497adbccc4181af2d924740df96e704666f13f594879f70a8ffa162e39dc4ad0f31e403ee88ca88e
@@ -1,7 +1,7 @@
1
1
  <div class="row">
2
2
  <div class="columns medium-7 mediumlarge-8">
3
3
  <div class="section">
4
- <%= decidim_sanitize_editor_admin(landing_page_content) %>
4
+ <%= decidim_sanitize_editor(landing_page_content) %>
5
5
  </div>
6
6
  </div>
7
7
  </div>
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ # A cell to display when actions happen on an order.
6
+ class OrderActivityCell < ActivityCell
7
+ def title
8
+ I18n.t(
9
+ "decidim.budgets.last_activity.new_vote_at_html",
10
+ link: participatory_space_link
11
+ )
12
+ end
13
+
14
+ def resource_link_path
15
+ resource_locator(budget).path
16
+ end
17
+
18
+ def resource_link_text
19
+ decidim_html_escape(translated_attribute(budget.title))
20
+ end
21
+
22
+ private
23
+
24
+ def budget
25
+ @budget ||= resource.budget
26
+ end
27
+ end
28
+ end
29
+ end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Budgets
5
5
  # A command with all the business to add new line items to orders
6
- class AddLineItem < Rectify::Command
6
+ class AddLineItem < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # order - The current order for the user or nil if it is not created yet.
@@ -23,11 +23,13 @@ module Decidim
23
23
  # Returns nothing.
24
24
  def call
25
25
  transaction do
26
- return broadcast(:invalid) if voting_not_enabled? || order.checked_out? || exceeds_budget?
26
+ raise ActiveRecord::RecordInvalid if voting_not_enabled? || order.checked_out? || exceeds_budget?
27
27
 
28
28
  add_line_item
29
29
  broadcast(:ok, order)
30
30
  end
31
+ rescue ActiveRecord::RecordInvalid
32
+ broadcast(:invalid)
31
33
  end
32
34
 
33
35
  private
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user creates an Budget
7
7
  # from the admin panel.
8
- class CreateBudget < Rectify::Command
8
+ class CreateBudget < Decidim::Command
9
9
  def initialize(form)
10
10
  @form = form
11
11
  end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ module Admin
6
+ # This command is executed when admin sends vote reminders.
7
+ class CreateOrderReminders < Decidim::Command
8
+ def initialize(form)
9
+ @form = form
10
+ end
11
+
12
+ def call
13
+ return broadcast(:invalid) if form.invalid?
14
+ return broadcast(:invalid) unless voting_enabled?
15
+ return broadcast(:invalid) if voting_ends_soon?
16
+
17
+ generator.generate_for(current_component, &alternative_refresh_state)
18
+
19
+ broadcast(:ok, generator.reminder_jobs_queued)
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :form
25
+
26
+ def alternative_refresh_state
27
+ proc do |reminder|
28
+ reminder.records.each do |record|
29
+ next if %w(active pending).exclude? record.state
30
+
31
+ record.state = begin
32
+ if record.remindable.created_at > minimum_time_between_reminders ||
33
+ (reminder.deliveries.present? && reminder.deliveries.last.created_at > minimum_time_between_reminders)
34
+ "pending"
35
+ else
36
+ "active"
37
+ end
38
+ end
39
+ record.save if record.changed?
40
+ end
41
+ end
42
+ end
43
+
44
+ def minimum_time_between_reminders
45
+ form.minimum_interval_between_reminders.ago
46
+ end
47
+
48
+ def generator
49
+ @generator ||= Decidim::Budgets::OrderReminderGenerator.new
50
+ end
51
+
52
+ def current_component
53
+ form.current_component
54
+ end
55
+
56
+ def voting_enabled?
57
+ form.voting_enabled?
58
+ end
59
+
60
+ def voting_ends_soon?
61
+ form.voting_ends_soon?
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user creates a Project from the admin
7
7
  # panel.
8
- class CreateProject < Rectify::Command
8
+ class CreateProject < Decidim::Command
9
9
  include ::Decidim::AttachmentMethods
10
10
  include ::Decidim::GalleryMethods
11
11
 
@@ -44,7 +44,10 @@ module Decidim
44
44
  category: form.category,
45
45
  title: form.title,
46
46
  description: form.description,
47
- budget_amount: form.budget_amount
47
+ budget_amount: form.budget_amount,
48
+ address: form.address,
49
+ latitude: form.latitude,
50
+ longitude: form.longitude
48
51
  }
49
52
 
50
53
  @project = Decidim.traceability.create!(
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user destroys a Budget
7
7
  # from the admin panel.
8
- class DestroyBudget < Rectify::Command
8
+ class DestroyBudget < Decidim::Command
9
9
  def initialize(budget, current_user)
10
10
  @budget = budget
11
11
  @current_user = current_user
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user deletes a Project from the admin
7
7
  # panel.
8
- class DestroyProject < Rectify::Command
8
+ class DestroyProject < Decidim::Command
9
9
  # Initializes an UpdateProject Command.
10
10
  #
11
11
  # project - The current instance of the project to be destroyed.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when an admin imports proposals from
7
7
  # one component to projects of a budget.
8
- class ImportProposalsToBudgets < Rectify::Command
8
+ class ImportProposalsToBudgets < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -48,7 +48,10 @@ module Decidim
48
48
  description: original_proposal.body,
49
49
  budget_amount: budget_for(original_proposal),
50
50
  category: original_proposal.category,
51
- scope: original_proposal.scope
51
+ scope: original_proposal.scope,
52
+ address: original_proposal.address,
53
+ latitude: original_proposal.latitude,
54
+ longitude: original_proposal.longitude
52
55
  }
53
56
 
54
57
  @project = Decidim.traceability.create!(
@@ -81,10 +84,7 @@ module Decidim
81
84
  end
82
85
 
83
86
  def proposal_already_copied?(original_proposal)
84
- # Note: we are including also projects from unpublished components
85
- # because otherwise duplicates could be created until the component is
86
- # published.
87
- original_proposal.linked_resources(:projects, "included_proposals", component_published: false).any? do |project|
87
+ original_proposal.linked_resources(:projects, "included_proposals").any? do |project|
88
88
  project.budget == form.budget
89
89
  end
90
90
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user updates a Budget
7
7
  # from the admin panel.
8
- class UpdateBudget < Rectify::Command
8
+ class UpdateBudget < Decidim::Command
9
9
  def initialize(form, budget)
10
10
  @form = form
11
11
  @budget = budget
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user changes a Project from the admin
7
7
  # panel.
8
- class UpdateProject < Rectify::Command
8
+ class UpdateProject < Decidim::Command
9
9
  include ::Decidim::AttachmentMethods
10
10
  include ::Decidim::GalleryMethods
11
11
 
@@ -53,7 +53,10 @@ module Decidim
53
53
  title: form.title,
54
54
  description: form.description,
55
55
  budget_amount: form.budget_amount,
56
- selected_at: selected_at
56
+ selected_at: selected_at,
57
+ address: form.address,
58
+ latitude: form.latitude,
59
+ longitude: form.longitude
57
60
  )
58
61
  end
59
62
 
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ module Admin
6
+ class UpdateProjectCategory < Decidim::Command
7
+ include TranslatableAttributes
8
+
9
+ # Public: Initializes the command.
10
+ #
11
+ # category_id - the category id to update
12
+ # project_ids - the project ids to update.
13
+ def initialize(category_id, project_ids)
14
+ @category = Decidim::Category.find_by id: category_id
15
+ @project_ids = project_ids
16
+ @response = { category_name: "", successful: [], errored: [] }
17
+ end
18
+
19
+ def call
20
+ return broadcast(:invalid_category) if @category.blank?
21
+ return broadcast(:invalid_project_ids) if @project_ids.blank?
22
+
23
+ @response[:category_name] = @category.translated_name
24
+ Project.where(id: @project_ids).find_each do |project|
25
+ if @category == project.category
26
+ @response[:errored] << translated_attribute(project.title)
27
+ else
28
+ transaction do
29
+ update_project_category project
30
+ end
31
+ @response[:successful] << translated_attribute(project.title)
32
+ end
33
+ end
34
+
35
+ broadcast(:update_projects_category, @response)
36
+ end
37
+
38
+ private
39
+
40
+ def update_project_category(project)
41
+ project.update!(
42
+ category: @category
43
+ )
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ module Admin
6
+ class UpdateProjectScope < Decidim::Command
7
+ include TranslatableAttributes
8
+
9
+ # Public: Initializes the command.
10
+ #
11
+ # scope_id - the scope id to update
12
+ # project_ids - the project ids to update.
13
+ def initialize(scope_id, project_ids)
14
+ @scope = ::Decidim::Scope.find_by id: scope_id
15
+ @project_ids = project_ids
16
+ @response = { scope_name: "", successful: [], errored: [] }
17
+ end
18
+
19
+ def call
20
+ return broadcast(:invalid_scope) if @scope.blank?
21
+ return broadcast(:invalid_project_ids) if @project_ids.blank?
22
+
23
+ update_projects_scope
24
+
25
+ broadcast(:update_projects_scope, @response)
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :scope, :project_ids
31
+
32
+ def update_projects_scope
33
+ @response[:scope_name] = translated_attribute(scope.name, scope.organization)
34
+ ::Decidim::Budgets::Project.where(id: project_ids).find_each do |project|
35
+ if scope == project.scope
36
+ @response[:errored] << translated_attribute(project.title)
37
+ else
38
+ transaction do
39
+ update_project_scope project
40
+ end
41
+ @response[:successful] << translated_attribute(project.title)
42
+ end
43
+ end
44
+ end
45
+
46
+ def update_project_scope(project)
47
+ project.update!(
48
+ scope: scope
49
+ )
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ module Admin
6
+ class UpdateProjectSelection < Decidim::Command
7
+ include TranslatableAttributes
8
+
9
+ # Public: Initializes the command.
10
+ #
11
+ # selection - Defines if projects are selected (for implementation)
12
+ # project_ids - the project ids to update.
13
+ def initialize(selection, project_ids)
14
+ @selection = selection
15
+ @project_ids = project_ids
16
+ @response = { selection_name: "", successful: [], errored: [] }
17
+ end
18
+
19
+ def call
20
+ return broadcast(:invalid_selection) if @selection.blank? || [true, false, "true", "false"].exclude?(@selection)
21
+ return broadcast(:invalid_project_ids) if @project_ids.blank?
22
+
23
+ @selection = ActiveModel::Type::Boolean.new.cast(@selection)
24
+
25
+ update_projects_selection
26
+
27
+ broadcast(:update_projects_selection, @response)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :selection, :project_ids
33
+
34
+ def update_projects_selection
35
+ ::Decidim::Budgets::Project.where(id: project_ids).find_each do |project|
36
+ if (selection == false && !project.selected?) || (selection && project.selected?)
37
+ @response[:errored] << translated_attribute(project.title)
38
+ else
39
+ transaction do
40
+ update_project_selection project
41
+ end
42
+ @response[:successful] << translated_attribute(project.title)
43
+ end
44
+ end
45
+ end
46
+
47
+ def update_project_selection(project)
48
+ selected_at = selection ? Time.current : nil
49
+ project.update!(
50
+ selected_at: selected_at
51
+ )
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Budgets
5
5
  # A command with all the business to cancel an order.
6
- class CancelOrder < Rectify::Command
6
+ class CancelOrder < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # order - The current order for the user.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Budgets
5
5
  # A command with all the business to checkout.
6
- class Checkout < Rectify::Command
6
+ class Checkout < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # order - The current order for the user.
@@ -32,8 +32,15 @@ module Decidim
32
32
 
33
33
  @order.with_lock do
34
34
  SendOrderSummaryJob.perform_later(@order)
35
- @order.checked_out_at = Time.current
36
- @order.save
35
+
36
+ Decidim.traceability.update!(
37
+ @order,
38
+ @order.user,
39
+ { checked_out_at: Time.current },
40
+ visibility: "private-only"
41
+ )
42
+ rescue ActiveRecord::RecordInvalid
43
+ false
37
44
  end
38
45
  end
39
46
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Budgets
5
5
  # A command with all the business to add remove line items from orders
6
- class RemoveLineItem < Rectify::Command
6
+ class RemoveLineItem < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # order - The current order for the user
@@ -22,6 +22,8 @@ module Decidim
22
22
  end
23
23
 
24
24
  def project
25
+ return unless projects
26
+
25
27
  @project ||= projects.find(params[:id])
26
28
  end
27
29
  end
@@ -17,9 +17,7 @@ module Decidim
17
17
  end
18
18
 
19
19
  def project
20
- @project ||= Decidim::Budgets::Project
21
- .joins("INNER JOIN decidim_budgets_budgets budget ON budget.id = decidim_budgets_projects.decidim_budgets_budget_id")
22
- .where(budget: { component: current_component }).find(params[:project_id])
20
+ @project ||= Decidim::Budgets::Project.find(params[:project_id])
23
21
  end
24
22
  end
25
23
  end
@@ -17,14 +17,8 @@ module Decidim
17
17
  project
18
18
  end
19
19
 
20
- def projects
21
- @projects ||= Decidim::Budgets::Project
22
- .joins("INNER JOIN decidim_budgets_budgets budget ON budget.id = decidim_budgets_projects.decidim_budgets_budget_id")
23
- .where(budget: { component: current_component })
24
- end
25
-
26
20
  def project
27
- @project ||= projects.find(params[:project_id])
21
+ @project ||= Decidim::Budgets::Project.find(params[:project_id])
28
22
  end
29
23
  end
30
24
  end
@@ -79,7 +79,7 @@ module Decidim
79
79
  end
80
80
 
81
81
  def orders
82
- @orders ||= Order.where(budget: budgets)
82
+ @orders ||= Order.where(decidim_budgets_budget_id: budgets)
83
83
  end
84
84
 
85
85
  def pending_orders