decidim-budgets 0.26.10 → 0.27.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/budgets/budgets_header/show.erb +1 -1
- data/app/cells/decidim/budgets/order_activity_cell.rb +29 -0
- data/app/commands/decidim/budgets/add_line_item.rb +4 -2
- data/app/commands/decidim/budgets/admin/create_budget.rb +1 -1
- data/app/commands/decidim/budgets/admin/create_order_reminders.rb +66 -0
- data/app/commands/decidim/budgets/admin/create_project.rb +5 -2
- data/app/commands/decidim/budgets/admin/destroy_budget.rb +1 -1
- data/app/commands/decidim/budgets/admin/destroy_project.rb +1 -1
- data/app/commands/decidim/budgets/admin/import_proposals_to_budgets.rb +6 -6
- data/app/commands/decidim/budgets/admin/update_budget.rb +1 -1
- data/app/commands/decidim/budgets/admin/update_project.rb +5 -2
- data/app/commands/decidim/budgets/admin/update_project_category.rb +48 -0
- data/app/commands/decidim/budgets/admin/update_project_scope.rb +54 -0
- data/app/commands/decidim/budgets/admin/update_project_selection.rb +56 -0
- data/app/commands/decidim/budgets/cancel_order.rb +1 -1
- data/app/commands/decidim/budgets/checkout.rb +10 -3
- data/app/commands/decidim/budgets/remove_line_item.rb +1 -1
- data/app/controllers/decidim/budgets/admin/application_controller.rb +2 -0
- data/app/controllers/decidim/budgets/admin/attachment_collections_controller.rb +1 -3
- data/app/controllers/decidim/budgets/admin/attachments_controller.rb +1 -7
- data/app/controllers/decidim/budgets/admin/budgets_controller.rb +1 -1
- data/app/controllers/decidim/budgets/admin/projects_controller.rb +149 -1
- data/app/controllers/decidim/budgets/line_items_controller.rb +2 -2
- data/app/controllers/decidim/budgets/orders_controller.rb +1 -1
- data/app/controllers/decidim/budgets/projects_controller.rb +15 -19
- data/app/forms/decidim/budgets/admin/budget_form.rb +3 -4
- data/app/forms/decidim/budgets/admin/order_reminder_form.rb +75 -0
- data/app/forms/decidim/budgets/admin/project_form.rb +19 -3
- data/app/helpers/decidim/budgets/admin/project_bulk_actions_helper.rb +20 -0
- data/app/helpers/decidim/budgets/projects_helper.rb +29 -0
- data/app/jobs/decidim/budgets/send_vote_reminder_job.rb +16 -0
- data/app/mailers/decidim/budgets/vote_reminder_mailer.rb +39 -0
- data/app/models/decidim/budgets/order.rb +2 -4
- data/app/models/decidim/budgets/project.rb +14 -10
- data/app/packs/entrypoints/decidim_budgets_admin.js +1 -0
- data/app/packs/src/decidim/budgets/admin/projects.js +143 -0
- data/app/permissions/decidim/budgets/admin/permissions.rb +8 -3
- data/app/queries/decidim/budgets/filtered_projects.rb +1 -1
- data/app/serializers/decidim/budgets/{data_portability_budgets_order_serializer.rb → download_your_data_budgets_order_serializer.rb} +2 -2
- data/app/services/decidim/budgets/order_reminder_generator.rb +85 -0
- data/app/views/decidim/budgets/admin/budgets/_form.html.erb +1 -1
- data/app/views/decidim/budgets/admin/budgets/edit.html.erb +0 -1
- data/app/views/decidim/budgets/admin/budgets/index.html.erb +3 -1
- data/app/views/decidim/budgets/admin/budgets/new.html.erb +0 -1
- data/app/views/decidim/budgets/admin/projects/_bulk-actions.html.erb +13 -0
- data/app/views/decidim/budgets/admin/projects/_form.html.erb +6 -0
- data/app/views/decidim/budgets/admin/projects/_project-tr.html.erb +50 -0
- data/app/views/decidim/budgets/admin/projects/bulk_actions/_change-selected.html.erb +15 -0
- data/app/views/decidim/budgets/admin/projects/bulk_actions/_dropdown.html.erb +36 -0
- data/app/views/decidim/budgets/admin/projects/bulk_actions/_recategorize.html.erb +15 -0
- data/app/views/decidim/budgets/admin/projects/bulk_actions/_scope-change.html.erb +25 -0
- data/app/views/decidim/budgets/admin/projects/edit.html.erb +0 -1
- data/app/views/decidim/budgets/admin/projects/index.html.erb +6 -55
- data/app/views/decidim/budgets/admin/projects/new.html.erb +0 -1
- data/app/views/decidim/budgets/admin/projects/update_attribute.js.erb +26 -0
- data/app/views/decidim/budgets/admin/proposals_imports/new.html.erb +0 -1
- data/app/views/decidim/budgets/order_summary_mailer/order_summary.html.erb +0 -1
- data/app/views/decidim/budgets/projects/_filters.html.erb +4 -4
- data/app/views/decidim/budgets/projects/index.html.erb +28 -1
- data/app/views/decidim/budgets/projects/show.html.erb +7 -2
- data/app/views/decidim/budgets/vote_reminder_mailer/vote_reminder.html.erb +21 -0
- data/config/assets.rb +2 -1
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +5 -1
- data/config/locales/bg.yml +1 -0
- data/config/locales/ca.yml +48 -5
- data/config/locales/cs.yml +53 -8
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +50 -16
- data/config/locales/el.yml +3 -33
- data/config/locales/en.yml +46 -4
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +46 -6
- data/config/locales/es-PY.yml +49 -6
- data/config/locales/es.yml +50 -7
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +46 -62
- data/config/locales/fi-plain.yml +47 -4
- data/config/locales/fi.yml +93 -50
- data/config/locales/fr-CA.yml +47 -5
- data/config/locales/fr.yml +48 -6
- data/config/locales/ga-IE.yml +2 -1
- data/config/locales/gl.yml +11 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +21 -149
- data/config/locales/id-ID.yml +2 -1
- data/config/locales/is-IS.yml +4 -2
- data/config/locales/it.yml +4 -2
- data/config/locales/ja.yml +44 -5
- data/config/locales/ko.yml +1 -0
- data/config/locales/lb.yml +5 -5
- data/config/locales/lt.yml +1 -338
- data/config/locales/lv.yml +2 -1
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +16 -30
- data/config/locales/no.yml +18 -1
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +3 -24
- data/config/locales/pt-BR.yml +4 -21
- data/config/locales/pt.yml +3 -3
- data/config/locales/ro-RO.yml +2 -3
- data/config/locales/ru.yml +2 -1
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +2 -1
- data/config/locales/sl.yml +1 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +1 -0
- data/config/locales/sv.yml +26 -7
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +3 -3
- data/config/locales/uk.yml +3 -2
- data/config/locales/val-ES.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +1 -3
- data/config/locales/zh-TW.yml +1 -326
- data/db/migrate/20200804175222_votes_enabled_to_votes_choices.rb +2 -2
- data/db/migrate/20220428072638_add_geolocalization_fields_to_projects.rb +9 -0
- data/lib/decidim/budgets/admin_engine.rb +3 -0
- data/lib/decidim/budgets/component.rb +7 -6
- data/lib/decidim/budgets/engine.rb +17 -0
- data/lib/decidim/budgets/test/factories.rb +11 -0
- data/lib/decidim/budgets/version.rb +1 -1
- data/lib/decidim/budgets/workflows/all.rb +1 -1
- data/lib/decidim/budgets/workflows/base.rb +1 -1
- metadata +38 -27
- data/app/services/decidim/budgets/project_search.rb +0 -45
- data/config/environment.rb +0 -3
- data/config/locales/fa-IR.yml +0 -1
- data/config/locales/gn-PY.yml +0 -1
- data/config/locales/ka-GE.yml +0 -1
- data/config/locales/kaa.yml +0 -11
- data/config/locales/lo-LA.yml +0 -1
- data/config/locales/oc-FR.yml +0 -1
- data/config/locales/sq-AL.yml +0 -1
- 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: 3fa531ee417f1965e642ac669891a7ab1705d2a39bbad0fbd20b862d2366887a
|
|
4
|
+
data.tar.gz: 014fee8507d07e68e6dcce958912efac0d6c4264ba08a380a4cc6bf77b95171f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 347007356a92385202d42ba9380cab18a1b04122a18477df5b640d54d84daf8b440a0e5c6300b3161d5d69b87b1ba5dc4dd04903be5eb0d7f68eb638df34fe5f
|
|
7
|
+
data.tar.gz: 5174a84a9e0a1c73efb3fd0b94c4a7ed4fc9a176891905e4497adbccc4181af2d924740df96e704666f13f594879f70a8ffa162e39dc4ad0f31e403ee88ca88e
|
|
@@ -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 <
|
|
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
|
-
|
|
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
|
|
@@ -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 <
|
|
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 <
|
|
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 <
|
|
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 <
|
|
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
|
-
|
|
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 changes a Project from the admin
|
|
7
7
|
# panel.
|
|
8
|
-
class UpdateProject <
|
|
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 checkout.
|
|
6
|
-
class Checkout <
|
|
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
|
-
|
|
36
|
-
|
|
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 <
|
|
6
|
+
class RemoveLineItem < Decidim::Command
|
|
7
7
|
# Public: Initializes the command.
|
|
8
8
|
#
|
|
9
9
|
# order - The current order for the user
|
|
@@ -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 ||=
|
|
21
|
+
@project ||= Decidim::Budgets::Project.find(params[:project_id])
|
|
28
22
|
end
|
|
29
23
|
end
|
|
30
24
|
end
|