decidim-budgets 0.31.8 → 0.32.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/README.md +3 -13
- data/app/cells/decidim/budgets/budget_list_item_cell.rb +6 -12
- data/app/commands/decidim/budgets/admin/create_project.rb +7 -6
- data/app/commands/decidim/budgets/admin/update_project.rb +7 -6
- data/app/commands/decidim/budgets/checkout.rb +7 -1
- data/app/controllers/concerns/decidim/budgets/admin/filterable.rb +0 -4
- data/app/controllers/concerns/decidim/budgets/needs_current_order.rb +8 -10
- data/app/controllers/decidim/budgets/admin/attachment_collections_controller.rb +0 -2
- data/app/controllers/decidim/budgets/admin/attachments_controller.rb +0 -2
- data/app/controllers/decidim/budgets/admin/budgets_controller.rb +4 -3
- data/app/controllers/decidim/budgets/admin/projects_controller.rb +11 -10
- data/app/controllers/decidim/budgets/admin/proposals_imports_controller.rb +2 -2
- data/app/controllers/decidim/budgets/application_controller.rb +1 -1
- data/app/controllers/decidim/budgets/budgets_controller.rb +1 -5
- data/app/controllers/decidim/budgets/line_items_controller.rb +4 -6
- data/app/controllers/decidim/budgets/orders_controller.rb +0 -4
- data/app/controllers/decidim/budgets/projects_controller.rb +27 -31
- data/app/forms/decidim/budgets/admin/project_form.rb +2 -4
- data/app/forms/decidim/budgets/admin/project_import_proposals_form.rb +0 -13
- data/app/helpers/decidim/budgets/projects_helper.rb +9 -2
- data/app/models/decidim/budgets/project.rb +8 -8
- data/app/packs/stylesheets/budgets.scss +1 -1
- data/app/permissions/decidim/budgets/permissions.rb +2 -23
- data/app/views/decidim/budgets/admin/projects/_actions.html.erb +1 -1
- data/app/views/decidim/budgets/admin/projects/_form.html.erb +1 -1
- data/app/views/decidim/budgets/admin/projects/_project-tr.html.erb +0 -3
- data/app/views/decidim/budgets/admin/projects/_projects-thead.html.erb +0 -1
- data/app/views/decidim/budgets/admin/projects/edit.html.erb +3 -2
- data/app/views/decidim/budgets/admin/projects/new.html.erb +3 -2
- data/app/views/decidim/budgets/projects/_budget_summary.html.erb +1 -1
- data/app/views/decidim/budgets/projects/show.html.erb +2 -18
- data/config/locales/ar.yml +0 -3
- data/config/locales/bg.yml +1 -15
- data/config/locales/bs-BA.yml +0 -1
- data/config/locales/ca-IT.yml +4 -12
- data/config/locales/ca.yml +5 -13
- data/config/locales/cs.yml +4 -12
- data/config/locales/de.yml +3 -15
- data/config/locales/el.yml +1 -11
- data/config/locales/en.yml +4 -11
- data/config/locales/es-MX.yml +4 -12
- data/config/locales/es-PY.yml +4 -12
- data/config/locales/es.yml +4 -12
- data/config/locales/eu.yml +73 -81
- data/config/locales/fi-plain.yml +3 -11
- data/config/locales/fi.yml +3 -11
- data/config/locales/fr-CA.yml +2 -13
- data/config/locales/fr.yml +2 -17
- data/config/locales/ga-IE.yml +0 -1
- data/config/locales/gl.yml +35 -297
- data/config/locales/hu.yml +1 -11
- data/config/locales/id-ID.yml +0 -3
- data/config/locales/is-IS.yml +1 -3
- data/config/locales/it.yml +1 -10
- data/config/locales/ja.yml +4 -12
- data/config/locales/kaa.yml +0 -1
- data/config/locales/ko.yml +0 -3
- data/config/locales/lb.yml +1 -10
- data/config/locales/lt.yml +1 -11
- data/config/locales/lv.yml +0 -3
- data/config/locales/nl.yml +1 -11
- data/config/locales/no.yml +1 -11
- data/config/locales/pl.yml +1 -11
- data/config/locales/pt-BR.yml +4 -11
- data/config/locales/pt.yml +1 -10
- data/config/locales/ro-RO.yml +1 -11
- data/config/locales/ru.yml +0 -3
- data/config/locales/sk.yml +0 -361
- data/config/locales/sq-AL.yml +0 -5
- data/config/locales/sr-CS.yml +0 -1
- data/config/locales/sv.yml +4 -14
- data/config/locales/tr-TR.yml +1 -10
- data/config/locales/uk.yml +0 -3
- data/config/locales/zh-CN.yml +1 -10
- data/config/locales/zh-TW.yml +1 -11
- data/decidim-budgets.gemspec +8 -11
- data/lib/decidim/api/budget_type.rb +0 -2
- data/lib/decidim/api/budgets_type.rb +2 -2
- data/lib/decidim/api/project_type.rb +2 -4
- data/lib/decidim/budgets/component.rb +1 -5
- data/lib/decidim/budgets/project_serializer.rb +2 -2
- data/lib/decidim/budgets/version.rb +1 -1
- data/lib/decidim/budgets.rb +0 -2
- metadata +14 -18
- data/app/jobs/decidim/budgets/send_order_summary_job.rb +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d1e9a57f1570f7e7c744aa5491727f328cddc0eb68cab35598f7f67042e1820
|
|
4
|
+
data.tar.gz: e66a4b84c85494fcd0f56c9f7231dafca776d6e43cdd1c61fcc5e51d258f05b1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 70d15990935083ada78aad11f412d08c9beb4207b848a726eb362bc965a3e0adb0c61e4e85db1742615293691a838c6c7e62db252f20a6b28f5ea548b3b51e1a
|
|
7
|
+
data.tar.gz: 7fa445aa14f232f290e66ff43d57f52302d81b640dc33248dad3868e5de52e2d73d2ca130d2186becacf4e82d5540d67cf61d8a152d0a5e2242d2bf73108a371
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# decidim-budgets
|
|
2
2
|
|
|
3
|
-
The Budgets module adds budgets with projects related to them to any participatory
|
|
3
|
+
The Budgets module adds budgets with projects related to them to any participatory space. It adds a CRUD engine to the admin and public views scoped inside the participatory space. Projects will link to related proposals and have a budget. The users should be able to distribute a budget between these projects.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -16,17 +16,7 @@ This plugin provides:
|
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```ruby
|
|
22
|
-
gem "decidim-budgets"
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
And then execute:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
bundle
|
|
29
|
-
```
|
|
19
|
+
This is on the default Decidim installation so you should not change anything to use this component.
|
|
30
20
|
|
|
31
21
|
## Budget Workflows
|
|
32
22
|
|
|
@@ -47,18 +47,12 @@ module Decidim
|
|
|
47
47
|
# If not (i.e. voting is disabled or finished), then link to the resource itself
|
|
48
48
|
def link_to_resource_or_vote(css_class)
|
|
49
49
|
if voting_open?
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
yield
|
|
57
|
-
end
|
|
58
|
-
else
|
|
59
|
-
link_to budget_projects_path(budget, start_voting: true), class: css_class do
|
|
60
|
-
yield
|
|
61
|
-
end
|
|
50
|
+
action_authorized_link_to "vote",
|
|
51
|
+
budget_projects_path(budget, start_voting: true),
|
|
52
|
+
resource: budget,
|
|
53
|
+
data: { "redirect-url": budget_projects_path(budget) },
|
|
54
|
+
class: css_class do
|
|
55
|
+
yield
|
|
62
56
|
end
|
|
63
57
|
else
|
|
64
58
|
link_to resource_path, class: css_class do
|
|
@@ -6,24 +6,25 @@ module Decidim
|
|
|
6
6
|
# This command is executed when the user creates a Project from the admin
|
|
7
7
|
# panel.
|
|
8
8
|
class CreateProject < Decidim::Commands::CreateResource
|
|
9
|
-
include ::Decidim::
|
|
9
|
+
include ::Decidim::GalleryMethods
|
|
10
|
+
|
|
10
11
|
fetch_form_attributes :budget, :taxonomizations, :title, :description, :budget_amount, :address, :latitude, :longitude
|
|
11
12
|
|
|
12
13
|
private
|
|
13
14
|
|
|
14
|
-
attr_reader :
|
|
15
|
+
attr_reader :gallery
|
|
15
16
|
|
|
16
17
|
def run_after_hooks
|
|
17
18
|
@attached_to = resource
|
|
18
19
|
link_proposals
|
|
19
|
-
|
|
20
|
+
create_gallery if process_gallery?
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
def run_before_hooks
|
|
23
|
-
return unless
|
|
24
|
+
return unless process_gallery?
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
raise Decidim::Commands::HookError if
|
|
26
|
+
build_gallery
|
|
27
|
+
raise Decidim::Commands::HookError if gallery_invalid?
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def extra_params
|
|
@@ -6,7 +6,8 @@ module Decidim
|
|
|
6
6
|
# This command is executed when the user changes a Project from the admin
|
|
7
7
|
# panel.
|
|
8
8
|
class UpdateProject < Decidim::Commands::UpdateResource
|
|
9
|
-
include ::Decidim::
|
|
9
|
+
include ::Decidim::GalleryMethods
|
|
10
|
+
|
|
10
11
|
fetch_form_attributes :taxonomizations, :title, :description, :budget_amount, :address, :latitude, :longitude
|
|
11
12
|
|
|
12
13
|
def initialize(form, project)
|
|
@@ -18,15 +19,15 @@ module Decidim
|
|
|
18
19
|
|
|
19
20
|
def run_after_hooks
|
|
20
21
|
link_proposals
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
create_gallery if process_gallery?
|
|
23
|
+
photo_cleanup!
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def run_before_hooks
|
|
26
|
-
return unless
|
|
27
|
+
return unless process_gallery?
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
raise Decidim::Commands::HookError if
|
|
29
|
+
build_gallery
|
|
30
|
+
raise Decidim::Commands::HookError if gallery_invalid?
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def attributes
|
|
@@ -31,7 +31,7 @@ module Decidim
|
|
|
31
31
|
return unless order && order.valid?
|
|
32
32
|
|
|
33
33
|
@order.with_lock do
|
|
34
|
-
|
|
34
|
+
send_order_summary_job(@order)
|
|
35
35
|
|
|
36
36
|
Decidim.traceability.update!(
|
|
37
37
|
@order,
|
|
@@ -43,6 +43,12 @@ module Decidim
|
|
|
43
43
|
false
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
|
+
|
|
47
|
+
def send_order_summary_job(order)
|
|
48
|
+
return if order&.user&.email.blank?
|
|
49
|
+
|
|
50
|
+
OrderSummaryMailer.order_summary(order).deliver_later
|
|
51
|
+
end
|
|
46
52
|
end
|
|
47
53
|
end
|
|
48
54
|
end
|
|
@@ -18,6 +18,14 @@ module Decidim
|
|
|
18
18
|
@current_order ||= Order.includes(:projects).find_or_initialize_by(user: current_user, budget:)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def current_order=(order)
|
|
22
|
+
@current_order = order
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def persisted_current_order
|
|
26
|
+
current_order if current_order&.persisted?
|
|
27
|
+
end
|
|
28
|
+
|
|
21
29
|
def can_have_order?
|
|
22
30
|
current_user.present? &&
|
|
23
31
|
voting_open? &&
|
|
@@ -29,16 +37,6 @@ module Decidim
|
|
|
29
37
|
def voted_for?(project)
|
|
30
38
|
current_order && current_order.projects.include?(project)
|
|
31
39
|
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
def current_order=(order)
|
|
36
|
-
@current_order = order
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def persisted_current_order
|
|
40
|
-
current_order if current_order&.persisted?
|
|
41
|
-
end
|
|
42
40
|
end
|
|
43
41
|
end
|
|
44
42
|
end
|
|
@@ -8,8 +8,6 @@ module Decidim
|
|
|
8
8
|
class AttachmentCollectionsController < Admin::ApplicationController
|
|
9
9
|
include Decidim::Admin::Concerns::HasAttachmentCollections
|
|
10
10
|
|
|
11
|
-
protected
|
|
12
|
-
|
|
13
11
|
def after_destroy_path
|
|
14
12
|
project_attachment_collections_path(project, project.component, current_participatory_space)
|
|
15
13
|
end
|
|
@@ -6,6 +6,7 @@ module Decidim
|
|
|
6
6
|
# This controller allows the create or update a budget.
|
|
7
7
|
class BudgetsController < Admin::ApplicationController
|
|
8
8
|
include Decidim::Admin::HasTrashableResources
|
|
9
|
+
|
|
9
10
|
helper_method :budgets, :budget, :finished_orders, :pending_orders,
|
|
10
11
|
:users_with_pending_orders, :users_with_finished_orders
|
|
11
12
|
|
|
@@ -26,7 +27,7 @@ module Decidim
|
|
|
26
27
|
|
|
27
28
|
on(:invalid) do
|
|
28
29
|
flash.now[:alert] = I18n.t("budgets.create.invalid", scope: "decidim.budgets.admin")
|
|
29
|
-
render action: "new", status: :
|
|
30
|
+
render action: "new", status: :unprocessable_content
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
33
|
end
|
|
@@ -48,7 +49,7 @@ module Decidim
|
|
|
48
49
|
|
|
49
50
|
on(:invalid) do
|
|
50
51
|
flash.now[:alert] = I18n.t("budgets.update.invalid", scope: "decidim.budgets.admin")
|
|
51
|
-
render action: "edit", status: :
|
|
52
|
+
render action: "edit", status: :unprocessable_content
|
|
52
53
|
end
|
|
53
54
|
end
|
|
54
55
|
end
|
|
@@ -76,7 +77,7 @@ module Decidim
|
|
|
76
77
|
end
|
|
77
78
|
|
|
78
79
|
def orders
|
|
79
|
-
@orders ||= Order.where(budget: budgets)
|
|
80
|
+
@orders ||= Order.where(budget: budgets)
|
|
80
81
|
end
|
|
81
82
|
|
|
82
83
|
def pending_orders
|
|
@@ -9,11 +9,16 @@ module Decidim
|
|
|
9
9
|
include Decidim::Admin::HasTrashableResources
|
|
10
10
|
include Decidim::Admin::ComponentTaxonomiesHelper
|
|
11
11
|
include Decidim::Budgets::Admin::Filterable
|
|
12
|
+
|
|
12
13
|
helper Decidim::Budgets::Admin::ProjectBulkActionsHelper
|
|
13
14
|
helper Decidim::Budgets::ProjectsHelper
|
|
14
15
|
|
|
15
16
|
helper_method :projects, :finished_orders, :pending_orders, :present, :project_ids
|
|
16
17
|
|
|
18
|
+
def collection
|
|
19
|
+
@collection ||= budget.projects.page(params[:page]).per(15)
|
|
20
|
+
end
|
|
21
|
+
|
|
17
22
|
def new
|
|
18
23
|
enforce_permission_to :create, :project
|
|
19
24
|
@form = form(ProjectForm).from_params(
|
|
@@ -35,7 +40,7 @@ module Decidim
|
|
|
35
40
|
|
|
36
41
|
on(:invalid) do
|
|
37
42
|
flash.now[:alert] = I18n.t("projects.create.invalid", scope: "decidim.budgets.admin")
|
|
38
|
-
render action: "new", status: :
|
|
43
|
+
render action: "new", status: :unprocessable_content
|
|
39
44
|
end
|
|
40
45
|
end
|
|
41
46
|
end
|
|
@@ -58,7 +63,7 @@ module Decidim
|
|
|
58
63
|
|
|
59
64
|
on(:invalid) do
|
|
60
65
|
flash.now[:alert] = I18n.t("projects.update.invalid", scope: "decidim.budgets.admin")
|
|
61
|
-
render action: "edit", status: :
|
|
66
|
+
render action: "edit", status: :unprocessable_content
|
|
62
67
|
end
|
|
63
68
|
end
|
|
64
69
|
end
|
|
@@ -66,7 +71,7 @@ module Decidim
|
|
|
66
71
|
def update_taxonomies
|
|
67
72
|
enforce_permission_to :update, :project_taxonomy
|
|
68
73
|
|
|
69
|
-
UpdateResourcesTaxonomies.call(params[:taxonomies],
|
|
74
|
+
UpdateResourcesTaxonomies.call(params[:taxonomies], Decidim::Budgets::Project.where(id: project_ids), current_organization) do
|
|
70
75
|
on(:invalid_taxonomies) do
|
|
71
76
|
flash[:error] = I18n.t(
|
|
72
77
|
"projects.update_taxonomies.select_a_taxonomy",
|
|
@@ -158,10 +163,6 @@ module Decidim
|
|
|
158
163
|
|
|
159
164
|
private
|
|
160
165
|
|
|
161
|
-
def collection
|
|
162
|
-
@collection ||= budget.projects.page(params[:page]).per(15)
|
|
163
|
-
end
|
|
164
|
-
|
|
165
166
|
def trashable_deleted_resource_type
|
|
166
167
|
:project
|
|
167
168
|
end
|
|
@@ -179,7 +180,7 @@ module Decidim
|
|
|
179
180
|
end
|
|
180
181
|
|
|
181
182
|
def orders
|
|
182
|
-
@orders ||= Order.where(budget:)
|
|
183
|
+
@orders ||= Order.where(budget:)
|
|
183
184
|
end
|
|
184
185
|
|
|
185
186
|
def project_ids
|
|
@@ -189,7 +190,7 @@ module Decidim
|
|
|
189
190
|
def reference_budget
|
|
190
191
|
return unless params[:reference_id]
|
|
191
192
|
|
|
192
|
-
Budget.
|
|
193
|
+
Budget.find(params[:reference_id])
|
|
193
194
|
end
|
|
194
195
|
|
|
195
196
|
def pending_orders
|
|
@@ -203,7 +204,7 @@ module Decidim
|
|
|
203
204
|
def sample_project
|
|
204
205
|
return if project_ids.empty?
|
|
205
206
|
|
|
206
|
-
|
|
207
|
+
Decidim::Budgets::Project.find(project_ids.first)
|
|
207
208
|
end
|
|
208
209
|
|
|
209
210
|
def project
|
|
@@ -24,7 +24,7 @@ module Decidim
|
|
|
24
24
|
|
|
25
25
|
on(:invalid) do
|
|
26
26
|
flash[:alert] = I18n.t("proposals_imports.create.invalid", scope: "decidim.budgets.admin")
|
|
27
|
-
render action: "new", status: :
|
|
27
|
+
render action: "new", status: :unprocessable_content
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -34,7 +34,7 @@ module Decidim
|
|
|
34
34
|
component = current_participatory_space.components.find_by(id: params[:origin_id])
|
|
35
35
|
|
|
36
36
|
if component
|
|
37
|
-
states = Decidim::Proposals::ProposalState
|
|
37
|
+
states = Decidim::Proposals::ProposalState
|
|
38
38
|
.where(component:)
|
|
39
39
|
.map { |s| { token: s.token, title: translated_attribute(s.title) } }
|
|
40
40
|
states << { token: "not_answered", title: I18n.t("decidim.proposals.answers.not_answered") }
|
|
@@ -8,7 +8,7 @@ module Decidim
|
|
|
8
8
|
# Note that it inherits from `Decidim::Components::BaseController`, which
|
|
9
9
|
# override its layout and provide all kinds of useful methods.
|
|
10
10
|
class ApplicationController < Decidim::Components::BaseController
|
|
11
|
-
helper_method :current_workflow, :voting_finished?, :voting_open?, :show_votes_count
|
|
11
|
+
helper_method :current_workflow, :voting_finished?, :voting_open?, :show_votes_count?
|
|
12
12
|
|
|
13
13
|
def current_workflow
|
|
14
14
|
@current_workflow ||= Decidim::Budgets.workflows[workflow_name].new(current_component, current_user)
|
|
@@ -9,13 +9,9 @@ module Decidim
|
|
|
9
9
|
include Decidim::Budgets::Orderable
|
|
10
10
|
include Decidim::TranslatableAttributes
|
|
11
11
|
|
|
12
|
-
def index
|
|
13
|
-
enforce_permission_to :read, :budget
|
|
14
|
-
end
|
|
12
|
+
def index; end
|
|
15
13
|
|
|
16
14
|
def show
|
|
17
|
-
enforce_permission_to(:read, :budget, budget:)
|
|
18
|
-
|
|
19
15
|
raise ActionController::RoutingError, "Not Found" unless budget
|
|
20
16
|
|
|
21
17
|
redirect_to budget_projects_path(budget)
|
|
@@ -22,12 +22,12 @@ module Decidim
|
|
|
22
22
|
AddLineItem.call(persisted_current_order, project, current_user) do
|
|
23
23
|
on(:ok) do |order|
|
|
24
24
|
self.current_order = order
|
|
25
|
-
format.html {
|
|
25
|
+
format.html { redirect_back_or_to(budget_path(budget)) }
|
|
26
26
|
format.js { render "update_budget" }
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
on(:invalid) do
|
|
30
|
-
format.js { render "update_budget", status: :
|
|
30
|
+
format.js { render "update_budget", status: :unprocessable_content }
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -35,17 +35,15 @@ module Decidim
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def destroy
|
|
38
|
-
enforce_permission_to :vote, :project, project:, budget:, workflow: current_workflow
|
|
39
|
-
|
|
40
38
|
respond_to do |format|
|
|
41
39
|
RemoveLineItem.call(current_order, project) do
|
|
42
40
|
on(:ok) do |_order|
|
|
43
|
-
format.html {
|
|
41
|
+
format.html { redirect_back_or_to(budget_path(budget)) }
|
|
44
42
|
format.js { render "update_budget" }
|
|
45
43
|
end
|
|
46
44
|
|
|
47
45
|
on(:invalid) do
|
|
48
|
-
format.js { render "update_budget", status: :
|
|
46
|
+
format.js { render "update_budget", status: :unprocessable_content }
|
|
49
47
|
end
|
|
50
48
|
end
|
|
51
49
|
end
|
|
@@ -26,8 +26,6 @@ module Decidim
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def destroy
|
|
29
|
-
enforce_permission_to :destroy, :order, order: current_order
|
|
30
|
-
|
|
31
29
|
CancelOrder.call(current_order) do
|
|
32
30
|
on(:ok) do
|
|
33
31
|
flash[:notice] = I18n.t("orders.destroy.success", scope: "decidim")
|
|
@@ -42,8 +40,6 @@ module Decidim
|
|
|
42
40
|
end
|
|
43
41
|
|
|
44
42
|
def status
|
|
45
|
-
enforce_permission_to :read, :order, order: current_order
|
|
46
|
-
|
|
47
43
|
redirect_to redirect_path unless current_order.persisted?
|
|
48
44
|
end
|
|
49
45
|
|
|
@@ -6,24 +6,21 @@ module Decidim
|
|
|
6
6
|
class ProjectsController < Decidim::Budgets::ApplicationController
|
|
7
7
|
include FilterResource
|
|
8
8
|
include NeedsCurrentOrder
|
|
9
|
+
include Decidim::AttachmentsHelper
|
|
9
10
|
include Decidim::Budgets::Orderable
|
|
10
11
|
include Decidim::IconHelper
|
|
11
12
|
|
|
12
|
-
helper_method :projects, :project, :budget, :all_geocoded_projects, :
|
|
13
|
+
helper_method :projects, :project, :budget, :all_geocoded_projects, :resource_added?, :tab_panel_items
|
|
13
14
|
|
|
14
15
|
before_action :set_focus_mode_if_voting_open
|
|
15
16
|
|
|
16
17
|
def index
|
|
17
|
-
enforce_permission_to :read, :project
|
|
18
|
-
|
|
19
18
|
raise ActionController::RoutingError, "Not Found" unless budget
|
|
20
19
|
end
|
|
21
20
|
|
|
22
21
|
def show
|
|
23
22
|
raise ActionController::RoutingError, "Not Found" unless budget
|
|
24
23
|
raise ActionController::RoutingError, "Not Found" unless project
|
|
25
|
-
|
|
26
|
-
enforce_permission_to :read, :project, project:
|
|
27
24
|
end
|
|
28
25
|
|
|
29
26
|
private
|
|
@@ -68,16 +65,8 @@ module Decidim
|
|
|
68
65
|
voting_finished? && budget.projects.selected.any?
|
|
69
66
|
end
|
|
70
67
|
|
|
71
|
-
def
|
|
72
|
-
@
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def panels
|
|
76
|
-
@panels ||= items.map { |item| item.slice(:id, :method, :args) }
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def items
|
|
80
|
-
@items ||= [
|
|
68
|
+
def tab_panel_items
|
|
69
|
+
@tab_panel_items ||= [
|
|
81
70
|
{
|
|
82
71
|
enabled: ProjectHistoryCell.new(@project).render?,
|
|
83
72
|
id: "included_history",
|
|
@@ -86,24 +75,31 @@ module Decidim
|
|
|
86
75
|
method: :cell,
|
|
87
76
|
args: ["decidim/budgets/project_history", @project]
|
|
88
77
|
},
|
|
89
|
-
|
|
90
|
-
enabled: @project.photos.present?,
|
|
91
|
-
id: "images",
|
|
92
|
-
text: t("decidim.application.photos.photos"),
|
|
93
|
-
icon: resource_type_icon_key("images"),
|
|
94
|
-
method: :cell,
|
|
95
|
-
args: ["decidim/images_panel", @project]
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
enabled: @project.documents.present?,
|
|
99
|
-
id: "documents",
|
|
100
|
-
text: t("decidim.application.documents.documents"),
|
|
101
|
-
icon: resource_type_icon_key("documents"),
|
|
102
|
-
method: :cell,
|
|
103
|
-
args: ["decidim/documents_panel", @project]
|
|
104
|
-
}
|
|
78
|
+
*attachments_tab_panel_items(@project)
|
|
105
79
|
].select { |item| item[:enabled] }
|
|
106
80
|
end
|
|
81
|
+
|
|
82
|
+
def add_breadcrumb_item
|
|
83
|
+
return {} if project.blank?
|
|
84
|
+
|
|
85
|
+
{
|
|
86
|
+
label: translated_attribute(project.title),
|
|
87
|
+
url: Decidim::EngineRouter.main_proxy(current_component).budget_project_url(budget, project),
|
|
88
|
+
active: false,
|
|
89
|
+
resource: project
|
|
90
|
+
}
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def add_parent_breadcrumb_item
|
|
94
|
+
return {} if budget.blank?
|
|
95
|
+
|
|
96
|
+
{
|
|
97
|
+
label: translated_attribute(budget.title),
|
|
98
|
+
url: Decidim::EngineRouter.main_proxy(current_component).budget_projects_url(budget),
|
|
99
|
+
active: false,
|
|
100
|
+
resource: budget
|
|
101
|
+
}
|
|
102
|
+
end
|
|
107
103
|
end
|
|
108
104
|
end
|
|
109
105
|
end
|
|
@@ -22,7 +22,7 @@ module Decidim
|
|
|
22
22
|
attribute :attachment, AttachmentForm
|
|
23
23
|
attribute :selected, Boolean
|
|
24
24
|
|
|
25
|
-
attachments_attribute :
|
|
25
|
+
attachments_attribute :photos
|
|
26
26
|
|
|
27
27
|
validates :title, translatable_presence: true
|
|
28
28
|
validates :description, translatable_presence: true
|
|
@@ -36,8 +36,6 @@ module Decidim
|
|
|
36
36
|
def map_model(model)
|
|
37
37
|
self.proposal_ids = model.linked_resources(:proposals, "included_proposals").pluck(:id)
|
|
38
38
|
self.selected = model.selected?
|
|
39
|
-
self.attachments = model.attachments.ids
|
|
40
|
-
self.add_attachments = model.attachments.map { |att| { id: att.id, title: att.title } }
|
|
41
39
|
end
|
|
42
40
|
|
|
43
41
|
def participatory_space_manifest
|
|
@@ -76,7 +74,7 @@ module Decidim
|
|
|
76
74
|
# an error, the attachment is lost, so we need a way to inform the user of
|
|
77
75
|
# this problem.
|
|
78
76
|
def notify_missing_attachment_if_errored
|
|
79
|
-
errors.add(:
|
|
77
|
+
errors.add(:add_photos, :needs_to_be_reattached) if errors.any? && add_photos.present?
|
|
80
78
|
end
|
|
81
79
|
end
|
|
82
80
|
end
|
|
@@ -14,7 +14,6 @@ module Decidim
|
|
|
14
14
|
|
|
15
15
|
validates :origin_component_id, :origin_component, :current_component, presence: true
|
|
16
16
|
validates :default_budget, presence: true, numericality: { greater_than: 0 }
|
|
17
|
-
validate :valid_states
|
|
18
17
|
|
|
19
18
|
def states
|
|
20
19
|
super.compact_blank
|
|
@@ -37,18 +36,6 @@ module Decidim
|
|
|
37
36
|
def budget
|
|
38
37
|
@budget ||= context[:budget]
|
|
39
38
|
end
|
|
40
|
-
|
|
41
|
-
private
|
|
42
|
-
|
|
43
|
-
def valid_states
|
|
44
|
-
return unless origin_component
|
|
45
|
-
return if states.empty?
|
|
46
|
-
|
|
47
|
-
valid_tokens = Decidim::Proposals::ProposalState.where(component: origin_component).pluck(:token) + ["not_answered"]
|
|
48
|
-
return if states.all? { |state| valid_tokens.include?(state) }
|
|
49
|
-
|
|
50
|
-
errors.add(:states, :invalid)
|
|
51
|
-
end
|
|
52
39
|
end
|
|
53
40
|
end
|
|
54
41
|
end
|
|
@@ -117,9 +117,16 @@ module Decidim
|
|
|
117
117
|
def filter_sections
|
|
118
118
|
@filter_sections ||= begin
|
|
119
119
|
items = []
|
|
120
|
-
|
|
120
|
+
if voting_finished?
|
|
121
|
+
items.append(method: :with_any_status,
|
|
122
|
+
name: "[with_any_status]",
|
|
123
|
+
collection: filter_status_values,
|
|
124
|
+
label: t("decidim.budgets.projects.filters.status"),
|
|
125
|
+
id: "status")
|
|
126
|
+
end
|
|
121
127
|
current_component.available_taxonomy_filters.each do |taxonomy_filter|
|
|
122
|
-
items.append(method:
|
|
128
|
+
items.append(method: :with_any_taxonomies,
|
|
129
|
+
name: "[with_any_taxonomies][#{taxonomy_filter.root_taxonomy_id}]",
|
|
123
130
|
collection: filter_taxonomy_values_for(taxonomy_filter),
|
|
124
131
|
label: decidim_sanitize_translated(taxonomy_filter.name),
|
|
125
132
|
id: "taxonomy-#{taxonomy_filter.root_taxonomy_id}")
|
|
@@ -134,14 +134,14 @@ module Decidim
|
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
ransacker :confirmed_orders_count do
|
|
137
|
-
query =
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
query = <<~SQL.squish
|
|
138
|
+
(
|
|
139
|
+
SELECT COUNT(decidim_budgets_line_items.decidim_order_id)
|
|
140
|
+
FROM decidim_budgets_line_items
|
|
141
|
+
LEFT JOIN decidim_budgets_orders ON decidim_budgets_orders.id = decidim_budgets_line_items.decidim_order_id
|
|
142
|
+
WHERE decidim_budgets_orders.checked_out_at IS NOT NULL
|
|
143
|
+
AND decidim_budgets_projects.id = decidim_budgets_line_items.decidim_project_id
|
|
144
|
+
)
|
|
145
145
|
SQL
|
|
146
146
|
Arel.sql(query)
|
|
147
147
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.budget {
|
|
2
2
|
&-list__map {
|
|
3
|
-
@apply lg:-ml-16 -mt-6 lg:-mt-
|
|
3
|
+
@apply lg:-ml-16 -mt-6 lg:-mt-12 mb-6 aspect-square lg:aspect-[21/9] [&>*]:h-full [&+*]:mt-6 lg:[&+*]:mt-12;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
&-summary {
|