decidim-budgets 0.21.0 → 0.23.2
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 +38 -3
- data/app/assets/images/decidim/budgets/icon.svg +1 -11
- data/app/assets/javascripts/decidim/budgets/projects.js.es6 +26 -4
- data/app/assets/stylesheets/decidim/budgets/budget/_budget-list.scss +152 -24
- data/app/cells/decidim/budgets/base_cell.rb +22 -0
- data/app/cells/decidim/budgets/budget_cell.rb +21 -0
- data/app/cells/decidim/budgets/budget_information_modal/show.erb +28 -0
- data/app/cells/decidim/budgets/budget_information_modal_cell.rb +22 -0
- data/app/cells/decidim/budgets/budget_list_item/show.erb +22 -0
- data/app/cells/decidim/budgets/budget_list_item_cell.rb +40 -0
- data/app/cells/decidim/budgets/budget_m/data.erb +12 -0
- data/app/cells/decidim/budgets/budget_m/footer.erb +5 -0
- data/app/cells/decidim/budgets/budget_m_cell.rb +16 -0
- data/app/cells/decidim/budgets/budgets_header/show.erb +7 -0
- data/app/cells/decidim/budgets/budgets_header_cell.rb +14 -0
- data/app/cells/decidim/budgets/budgets_list/card_list.erb +7 -0
- data/app/cells/decidim/budgets/budgets_list/highlighted.erb +11 -0
- data/app/cells/decidim/budgets/budgets_list/show.erb +20 -0
- data/app/cells/decidim/budgets/budgets_list/voted.erb +43 -0
- data/app/cells/decidim/budgets/budgets_list_cell.rb +39 -0
- data/app/cells/decidim/budgets/limit_announcement_cell.rb +52 -0
- data/app/cells/decidim/budgets/project_list_item/project_data.erb +19 -0
- data/app/cells/decidim/budgets/project_list_item/project_data_vote_button.erb +15 -0
- data/app/cells/decidim/budgets/project_list_item/project_image.erb +5 -0
- data/app/cells/decidim/budgets/project_list_item/project_text.erb +23 -0
- data/app/cells/decidim/budgets/project_list_item/show.erb +5 -0
- data/app/cells/decidim/budgets/project_list_item_cell.rb +66 -0
- data/app/cells/decidim/budgets/project_m/data.erb +3 -3
- data/app/cells/decidim/budgets/project_m/footer.erb +1 -1
- data/app/cells/decidim/budgets/project_m_cell.rb +4 -0
- data/app/cells/decidim/budgets/project_selected_status_cell.rb +28 -0
- data/app/cells/decidim/budgets/project_tags/show.erb +5 -0
- data/app/cells/decidim/budgets/project_tags_cell.rb +18 -0
- data/app/cells/decidim/budgets/project_voted_hint_cell.rb +33 -0
- data/app/cells/decidim/budgets/project_votes_count_cell.rb +44 -0
- data/app/commands/decidim/budgets/add_line_item.rb +7 -10
- data/app/commands/decidim/budgets/admin/create_budget.rb +48 -0
- data/app/commands/decidim/budgets/admin/create_project.rb +26 -11
- data/app/commands/decidim/budgets/admin/destroy_budget.rb +42 -0
- data/app/commands/decidim/budgets/admin/import_proposals_to_budgets.rb +26 -25
- data/app/commands/decidim/budgets/admin/update_budget.rb +48 -0
- data/app/commands/decidim/budgets/admin/update_project.rb +20 -2
- data/app/commands/decidim/budgets/checkout.rb +7 -6
- data/app/commands/decidim/budgets/remove_line_item.rb +3 -2
- data/app/controllers/concerns/decidim/budgets/needs_current_order.rb +18 -2
- data/app/controllers/concerns/decidim/budgets/orderable.rb +57 -0
- data/app/controllers/decidim/budgets/admin/application_controller.rb +10 -2
- data/app/controllers/decidim/budgets/admin/attachment_collections_controller.rb +1 -1
- data/app/controllers/decidim/budgets/admin/attachments_controller.rb +2 -2
- data/app/controllers/decidim/budgets/admin/budgets_controller.rb +82 -0
- data/app/controllers/decidim/budgets/admin/projects_controller.rb +15 -12
- data/app/controllers/decidim/budgets/admin/proposals_imports_controller.rb +10 -2
- data/app/controllers/decidim/budgets/application_controller.rb +23 -0
- data/app/controllers/decidim/budgets/budgets_controller.rb +24 -0
- data/app/controllers/decidim/budgets/line_items_controller.rb +10 -6
- data/app/controllers/decidim/budgets/orders_controller.rb +20 -6
- data/app/controllers/decidim/budgets/projects_controller.rb +24 -19
- data/app/forms/decidim/budgets/admin/budget_form.rb +39 -0
- data/app/forms/decidim/budgets/admin/component_form.rb +44 -0
- data/app/forms/decidim/budgets/admin/project_form.rb +25 -9
- data/app/forms/decidim/budgets/admin/project_import_proposals_form.rb +4 -0
- data/app/helpers/decidim/budgets/admin/application_helper.rb +13 -0
- data/app/helpers/decidim/budgets/application_helper.rb +10 -0
- data/app/helpers/decidim/budgets/projects_helper.rb +13 -0
- data/app/jobs/decidim/budgets/send_order_summary_job.rb +15 -0
- data/app/mailers/decidim/budgets/order_summary_mailer.rb +36 -0
- data/app/models/decidim/budgets/budget.rb +34 -0
- data/app/models/decidim/budgets/line_item.rb +4 -4
- data/app/models/decidim/budgets/order.rb +47 -16
- data/app/models/decidim/budgets/project.rb +37 -4
- data/app/permissions/decidim/budgets/admin/permissions.rb +23 -10
- data/app/permissions/decidim/budgets/permissions.rb +28 -6
- data/app/presenters/decidim/budgets/admin_log/budget_presenter.rb +42 -0
- data/app/queries/decidim/budgets/filtered_projects.rb +9 -1
- data/app/queries/decidim/budgets/metrics/budget_followers_metric_measure.rb +3 -2
- data/app/queries/decidim/budgets/metrics/budget_participants_metric_measure.rb +6 -5
- data/app/serializers/decidim/budgets/data_portability_budgets_order_serializer.rb +3 -2
- data/app/services/decidim/budgets/project_search.rb +12 -24
- data/app/types/decidim/budgets/budget_type.rb +24 -0
- data/app/types/decidim/budgets/budgets_type.rb +6 -6
- data/app/types/decidim/budgets/project_type.rb +2 -1
- data/app/views/decidim/budgets/admin/budgets/_form.html.erb +23 -0
- data/app/views/decidim/budgets/admin/budgets/edit.html.erb +7 -0
- data/app/views/decidim/budgets/admin/budgets/index.html.erb +58 -0
- data/app/views/decidim/budgets/admin/budgets/new.html.erb +7 -0
- data/app/views/decidim/budgets/admin/projects/_form.html.erb +15 -10
- data/app/views/decidim/budgets/admin/projects/edit.html.erb +2 -2
- data/app/views/decidim/budgets/admin/projects/index.html.erb +20 -7
- data/app/views/decidim/budgets/admin/projects/new.html.erb +2 -2
- data/app/views/decidim/budgets/admin/projects/proposals_picker.html.erb +1 -0
- data/app/views/decidim/budgets/admin/proposals_imports/new.html.erb +1 -1
- data/app/views/decidim/budgets/budgets/index.html.erb +5 -0
- data/app/views/decidim/budgets/order_summary_mailer/order_summary.html.erb +22 -0
- data/app/views/decidim/budgets/projects/_budget_confirm.html.erb +3 -3
- data/app/views/decidim/budgets/projects/_budget_summary.html.erb +26 -7
- data/app/views/decidim/budgets/projects/_filters.html.erb +15 -7
- data/app/views/decidim/budgets/projects/_linked_projects.html.erb +2 -2
- data/app/views/decidim/budgets/projects/_order_progress.html.erb +14 -18
- data/app/views/decidim/budgets/projects/_order_selected_projects.html.erb +3 -3
- data/app/views/decidim/budgets/projects/_project.html.erb +1 -57
- data/app/views/decidim/budgets/projects/_project_budget_button.html.erb +36 -7
- data/app/views/decidim/budgets/projects/_projects.html.erb +8 -1
- data/app/views/decidim/budgets/projects/index.html.erb +15 -7
- data/app/views/decidim/budgets/projects/index.js.erb +8 -0
- data/app/views/decidim/budgets/projects/show.html.erb +22 -13
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +2 -16
- data/config/locales/bg-BG.yml +7 -0
- data/config/locales/bg.yml +6 -0
- data/config/locales/ca.yml +125 -11
- data/config/locales/cs.yml +148 -34
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +143 -29
- data/config/locales/el.yml +168 -0
- data/config/locales/en.yml +125 -11
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +125 -11
- data/config/locales/es-PY.yml +125 -11
- data/config/locales/es.yml +125 -11
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +5 -13
- data/config/locales/fi-plain.yml +126 -12
- data/config/locales/fi.yml +136 -22
- data/config/locales/fr-CA.yml +267 -0
- data/config/locales/fr.yml +125 -11
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +70 -15
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +18 -12
- data/config/locales/id-ID.yml +2 -11
- data/config/locales/is-IS.yml +0 -11
- data/config/locales/is.yml +114 -0
- data/config/locales/it.yml +96 -12
- data/config/locales/ja-JP.yml +172 -0
- data/config/locales/ja.yml +262 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +164 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +112 -12
- data/config/locales/no.yml +42 -13
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +175 -61
- data/config/locales/pt-BR.yml +3 -13
- data/config/locales/pt.yml +62 -46
- data/config/locales/ro-RO.yml +172 -0
- data/config/locales/ru.yml +2 -14
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk-SK.yml +180 -0
- data/config/locales/sk.yml +166 -0
- data/config/locales/sl.yml +1 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +27 -0
- data/config/locales/sv.yml +125 -11
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +152 -38
- data/config/locales/uk.yml +2 -14
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +260 -0
- data/config/locales/zh-TW.yml +1 -0
- data/db/migrate/20200617105120_create_decidim_budgets.rb +15 -0
- data/db/migrate/20200629072626_rename_budget_to_budget_ammount.rb +7 -0
- data/db/migrate/20200629134013_add_budget_reference_to_project.rb +7 -0
- data/db/migrate/20200706142609_add_budget_reference_to_order.rb +7 -0
- data/db/migrate/20200714103519_move_budgets_to_own_model.rb +109 -0
- data/db/migrate/20200717140012_add_scope_to_budgets.rb +7 -0
- data/db/migrate/20200728075039_add_selected_at_to_project.rb +7 -0
- data/db/migrate/20200804175222_votes_enabled_to_votes_choices.rb +35 -0
- data/db/migrate/20200827154129_add_commentable_counter_cache_to_projects.rb +9 -0
- data/lib/decidim/budgets.rb +1 -0
- data/lib/decidim/budgets/admin_engine.rb +12 -5
- data/lib/decidim/budgets/component.rb +87 -38
- data/lib/decidim/budgets/engine.rb +8 -6
- data/lib/decidim/budgets/seeds/city.jpeg +0 -0
- data/lib/decidim/budgets/test/factories.rb +71 -9
- data/lib/decidim/budgets/version.rb +1 -1
- data/lib/decidim/budgets/workflows.rb +17 -0
- data/lib/decidim/budgets/workflows/all.rb +20 -0
- data/lib/decidim/budgets/workflows/base.rb +132 -0
- data/lib/decidim/budgets/workflows/one.rb +33 -0
- metadata +123 -19
@@ -12,15 +12,17 @@ module Decidim
|
|
12
12
|
isolate_namespace Decidim::Budgets
|
13
13
|
|
14
14
|
routes do
|
15
|
-
resources :
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
resources :budgets, only: [:index, :show] do
|
16
|
+
resources :projects, only: [:index, :show]
|
17
|
+
resource :order, only: [:destroy] do
|
18
|
+
member do
|
19
|
+
post :checkout
|
20
|
+
end
|
21
|
+
resource :line_item, only: [:create, :destroy]
|
19
22
|
end
|
20
|
-
resource :line_item, only: [:create, :destroy]
|
21
23
|
end
|
22
24
|
|
23
|
-
root to: "
|
25
|
+
root to: "budgets#index"
|
24
26
|
end
|
25
27
|
|
26
28
|
initializer "decidim_budgets.assets" do |app|
|
Binary file
|
@@ -7,30 +7,48 @@ require "decidim/core/test/factories"
|
|
7
7
|
require "decidim/participatory_processes/test/factories"
|
8
8
|
|
9
9
|
FactoryBot.define do
|
10
|
-
factory :
|
10
|
+
factory :budgets_component, parent: :component do
|
11
11
|
name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :budgets).i18n_name }
|
12
12
|
manifest_name { :budgets }
|
13
13
|
participatory_space { create(:participatory_process, :with_steps, organization: organization) }
|
14
14
|
|
15
|
-
trait :
|
15
|
+
trait :with_vote_threshold_percent do
|
16
16
|
transient do
|
17
|
-
|
17
|
+
vote_rule_threshold_percent_enabled { true }
|
18
|
+
vote_rule_minimum_budget_projects_enabled { false }
|
18
19
|
vote_threshold_percent { 70 }
|
19
20
|
end
|
20
21
|
|
21
22
|
settings do
|
22
23
|
{
|
23
|
-
|
24
|
+
vote_rule_threshold_percent_enabled: vote_rule_threshold_percent_enabled,
|
25
|
+
vote_rule_minimum_budget_projects_enabled: vote_rule_minimum_budget_projects_enabled,
|
24
26
|
vote_threshold_percent: vote_threshold_percent
|
25
27
|
}
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
31
|
+
trait :with_minimum_budget_projects do
|
32
|
+
transient do
|
33
|
+
vote_rule_threshold_percent_enabled { false }
|
34
|
+
vote_rule_minimum_budget_projects_enabled { true }
|
35
|
+
vote_minimum_budget_projects_number { 3 }
|
36
|
+
end
|
37
|
+
|
38
|
+
settings do
|
39
|
+
{
|
40
|
+
vote_rule_threshold_percent_enabled: vote_rule_threshold_percent_enabled,
|
41
|
+
vote_rule_minimum_budget_projects_enabled: vote_rule_minimum_budget_projects_enabled,
|
42
|
+
vote_minimum_budget_projects_number: vote_minimum_budget_projects_number
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
29
47
|
trait :with_votes_disabled do
|
30
48
|
step_settings do
|
31
49
|
{
|
32
50
|
participatory_space.active_step.id => {
|
33
|
-
|
51
|
+
votes: :disabled
|
34
52
|
}
|
35
53
|
}
|
36
54
|
end
|
@@ -45,22 +63,66 @@ FactoryBot.define do
|
|
45
63
|
}
|
46
64
|
end
|
47
65
|
end
|
66
|
+
|
67
|
+
trait :with_voting_finished do
|
68
|
+
step_settings do
|
69
|
+
{
|
70
|
+
participatory_space.active_step.id => {
|
71
|
+
votes: :finished,
|
72
|
+
show_votes: true
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
factory :budget, class: "Decidim::Budgets::Budget" do
|
80
|
+
title { generate_localized_title }
|
81
|
+
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
|
82
|
+
total_budget { 100_000_000 }
|
83
|
+
component { create(:budgets_component) }
|
84
|
+
|
85
|
+
trait :with_projects do
|
86
|
+
transient do
|
87
|
+
projects_number { 2 }
|
88
|
+
end
|
89
|
+
|
90
|
+
after(:create) do |budget, evaluator|
|
91
|
+
create_list(:project, evaluator.projects_number, budget: budget)
|
92
|
+
end
|
93
|
+
end
|
48
94
|
end
|
49
95
|
|
50
96
|
factory :project, class: "Decidim::Budgets::Project" do
|
51
97
|
title { generate_localized_title }
|
52
98
|
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
|
53
|
-
|
54
|
-
|
99
|
+
budget_amount { Faker::Number.number(8) }
|
100
|
+
budget { create(:budget) }
|
101
|
+
|
102
|
+
trait :selected do
|
103
|
+
selected_at { Time.current }
|
104
|
+
end
|
55
105
|
end
|
56
106
|
|
57
107
|
factory :order, class: "Decidim::Budgets::Order" do
|
58
|
-
|
108
|
+
budget { create(:budget) }
|
59
109
|
user { create(:user, organization: component.organization) }
|
110
|
+
|
111
|
+
trait :with_projects do
|
112
|
+
transient do
|
113
|
+
projects_number { 2 }
|
114
|
+
end
|
115
|
+
|
116
|
+
after(:create) do |order, evaluator|
|
117
|
+
project_budget = (order.maximum_budget / evaluator.projects_number).to_i
|
118
|
+
order.projects << create_list(:project, evaluator.projects_number, budget_amount: project_budget, budget: order.budget)
|
119
|
+
order.save!
|
120
|
+
end
|
121
|
+
end
|
60
122
|
end
|
61
123
|
|
62
124
|
factory :line_item, class: "Decidim::Budgets::LineItem" do
|
63
125
|
order
|
64
|
-
project { create(:project,
|
126
|
+
project { create(:project, budget: order.budget) }
|
65
127
|
end
|
66
128
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/budgets/workflows/base"
|
4
|
+
require "decidim/budgets/workflows/one"
|
5
|
+
require "decidim/budgets/workflows/all"
|
6
|
+
|
7
|
+
module Decidim
|
8
|
+
module Budgets
|
9
|
+
# Public: Stores the array of available workflows
|
10
|
+
def self.workflows
|
11
|
+
@workflows ||= {
|
12
|
+
one: Workflows::One,
|
13
|
+
all: Workflows::All
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Budgets
|
5
|
+
module Workflows
|
6
|
+
# This Workflow allows users to vote in all budgets.
|
7
|
+
class All < Base
|
8
|
+
# No budget is highlighted for this workflow.
|
9
|
+
def highlighted?(_resource)
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
# Users can vote in all budgets with this workflow.
|
14
|
+
def vote_allowed?(resource, _consider_progress = true)
|
15
|
+
!voted?(resource)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Budgets
|
5
|
+
module Workflows
|
6
|
+
# This is the base Workflow class.
|
7
|
+
class Base
|
8
|
+
def initialize(budgets_component, user)
|
9
|
+
@budgets_component = budgets_component
|
10
|
+
@user = user
|
11
|
+
end
|
12
|
+
|
13
|
+
# Public: Checks if the component has only one budget resource.
|
14
|
+
#
|
15
|
+
# Returns Boolean.
|
16
|
+
def single?
|
17
|
+
budgets.one?
|
18
|
+
end
|
19
|
+
|
20
|
+
# Public: Return the lonenly budget resource of the component
|
21
|
+
#
|
22
|
+
# Returns an ActiveRecord.
|
23
|
+
def single
|
24
|
+
budgets.first if single?
|
25
|
+
end
|
26
|
+
|
27
|
+
# Public: Decides if the given resource should be highlighted.
|
28
|
+
# This method must be overwritten for each Workflow class.
|
29
|
+
# - resource: the budget resource to consider
|
30
|
+
#
|
31
|
+
# Returns Boolean.
|
32
|
+
def highlighted?(_resource)
|
33
|
+
raise StandardError, "Not implemented"
|
34
|
+
end
|
35
|
+
|
36
|
+
# Public: Decides if the given user should be allowed to vote in the given resource.
|
37
|
+
# This method must be overwritten for each Workflow class.
|
38
|
+
# - resource: the budget resource to consider
|
39
|
+
# - consider_progress: should consider user orders in progress?
|
40
|
+
# Using `false` allow UI to offer users to discard votes in progress to start voting in another resource.
|
41
|
+
#
|
42
|
+
# Returns Boolean.
|
43
|
+
def vote_allowed?(_resource, _consider_progress = true)
|
44
|
+
raise StandardError, "Not implemented"
|
45
|
+
end
|
46
|
+
|
47
|
+
attr_accessor :budgets_component, :user
|
48
|
+
|
49
|
+
# Public: Return the list of budget resources that are highlighted for the user.
|
50
|
+
#
|
51
|
+
# Returns Array.
|
52
|
+
def highlighted
|
53
|
+
@highlighted ||= budgets.select { |resource| highlighted?(resource) }
|
54
|
+
end
|
55
|
+
|
56
|
+
# Public: Return the list of budgets where the user is allowed to vote.
|
57
|
+
#
|
58
|
+
# Returns Array.
|
59
|
+
def allowed
|
60
|
+
@allowed ||= budgets.select { |resource| vote_allowed?(resource) }
|
61
|
+
end
|
62
|
+
|
63
|
+
# Public: Return the list of budget resources where the user has voted.
|
64
|
+
#
|
65
|
+
# Returns Array.
|
66
|
+
def voted
|
67
|
+
@voted ||= orders.values.map { |order_info| order_info[:order].budget if order_info[:status] == :voted } .compact
|
68
|
+
end
|
69
|
+
|
70
|
+
# Public: Return the list of budget resources where the user has orders in progress.
|
71
|
+
#
|
72
|
+
# Returns Array.
|
73
|
+
def progress
|
74
|
+
@progress ||= orders.values.map { |order_info| order_info[:order].budget if order_info[:status] == :progress } .compact
|
75
|
+
end
|
76
|
+
|
77
|
+
# Public: Return the list of budget resources where the user could discard their order to vote in other components.
|
78
|
+
#
|
79
|
+
# Returns Array.
|
80
|
+
def discardable
|
81
|
+
progress
|
82
|
+
end
|
83
|
+
|
84
|
+
# Public: Return the status for the given budget resource and the user
|
85
|
+
# - resource: the budget resource to consider
|
86
|
+
#
|
87
|
+
# Returns Boolean.
|
88
|
+
def status(resource)
|
89
|
+
orders.dig(resource.id, :status) || (vote_allowed?(resource) ? :allowed : :not_allowed)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Public: Return if the user can vote in the given budget resource
|
93
|
+
# - resource: the budgets resource to consider
|
94
|
+
#
|
95
|
+
# Returns Boolean.
|
96
|
+
def voted?(resource)
|
97
|
+
orders.dig(resource.id, :status) == :voted
|
98
|
+
end
|
99
|
+
|
100
|
+
# Public: Return if the user has a pending order in the given budget resource
|
101
|
+
# - resource: the budgets resource to consider
|
102
|
+
#
|
103
|
+
# Returns Boolean.
|
104
|
+
def progress?(resource)
|
105
|
+
orders.dig(resource.id, :status) == :progress
|
106
|
+
end
|
107
|
+
|
108
|
+
# Public: Return if the user has reached the voting limit on budgets
|
109
|
+
#
|
110
|
+
# Returns Boolean.
|
111
|
+
def limit_reached?
|
112
|
+
(allowed - progress).none?
|
113
|
+
end
|
114
|
+
|
115
|
+
# Public: Return all the budgets resources that should be taken into account for the budgets component
|
116
|
+
#
|
117
|
+
# Returns an ActiveRecord::Relation.
|
118
|
+
def budgets
|
119
|
+
@budgets ||= Decidim::Budgets::Budget.where(component: budgets_component).order(weight: :asc)
|
120
|
+
end
|
121
|
+
|
122
|
+
protected
|
123
|
+
|
124
|
+
def orders
|
125
|
+
@orders ||= Decidim::Budgets::Order.includes(:projects).where(decidim_user_id: user, decidim_budgets_budget_id: budgets).map do |order|
|
126
|
+
[order.decidim_budgets_budget_id, { order: order, status: order.checked_out? ? :voted : :progress }] if order.projects.any?
|
127
|
+
end.compact.to_h
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Budgets
|
5
|
+
module Workflows
|
6
|
+
# This Workflow allows users to vote in any budget, but only in one.
|
7
|
+
class One < Base
|
8
|
+
# No budget resource is highlighted for this workflow.
|
9
|
+
def highlighted?(_resource)
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
# Users can vote in any budget with this workflow, but only in one.
|
14
|
+
def vote_allowed?(resource, consider_progress = true)
|
15
|
+
return false if voted.any?
|
16
|
+
|
17
|
+
if consider_progress
|
18
|
+
progress?(resource) || progress.none?
|
19
|
+
else
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Public: Returns a list of budgets where the user can discard their order to vote in another.
|
25
|
+
#
|
26
|
+
# Returns Array.
|
27
|
+
def discardable
|
28
|
+
progress + voted
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-budgets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
8
8
|
- Marc Riera Casals
|
9
9
|
- Oriol Gual Oliva
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-02-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: decidim-comments
|
@@ -18,42 +18,48 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.23.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.
|
28
|
+
version: 0.23.2
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: decidim-core
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.
|
35
|
+
version: 0.23.2
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 0.23.2
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: kaminari
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '1.
|
49
|
+
version: '1.2'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.2.1
|
50
53
|
type: :runtime
|
51
54
|
prerelease: false
|
52
55
|
version_requirements: !ruby/object:Gem::Requirement
|
53
56
|
requirements:
|
54
57
|
- - "~>"
|
55
58
|
- !ruby/object:Gem::Version
|
56
|
-
version: '1.
|
59
|
+
version: '1.2'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.2.1
|
57
63
|
- !ruby/object:Gem::Dependency
|
58
64
|
name: searchlight
|
59
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,42 +80,42 @@ dependencies:
|
|
74
80
|
requirements:
|
75
81
|
- - '='
|
76
82
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.
|
83
|
+
version: 0.23.2
|
78
84
|
type: :development
|
79
85
|
prerelease: false
|
80
86
|
version_requirements: !ruby/object:Gem::Requirement
|
81
87
|
requirements:
|
82
88
|
- - '='
|
83
89
|
- !ruby/object:Gem::Version
|
84
|
-
version: 0.
|
90
|
+
version: 0.23.2
|
85
91
|
- !ruby/object:Gem::Dependency
|
86
92
|
name: decidim-dev
|
87
93
|
requirement: !ruby/object:Gem::Requirement
|
88
94
|
requirements:
|
89
95
|
- - '='
|
90
96
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0.
|
97
|
+
version: 0.23.2
|
92
98
|
type: :development
|
93
99
|
prerelease: false
|
94
100
|
version_requirements: !ruby/object:Gem::Requirement
|
95
101
|
requirements:
|
96
102
|
- - '='
|
97
103
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0.
|
104
|
+
version: 0.23.2
|
99
105
|
- !ruby/object:Gem::Dependency
|
100
106
|
name: decidim-proposals
|
101
107
|
requirement: !ruby/object:Gem::Requirement
|
102
108
|
requirements:
|
103
109
|
- - '='
|
104
110
|
- !ruby/object:Gem::Version
|
105
|
-
version: 0.
|
111
|
+
version: 0.23.2
|
106
112
|
type: :development
|
107
113
|
prerelease: false
|
108
114
|
version_requirements: !ruby/object:Gem::Requirement
|
109
115
|
requirements:
|
110
116
|
- - '='
|
111
117
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.
|
118
|
+
version: 0.23.2
|
113
119
|
description: A budgets component for decidim's participatory spaces.
|
114
120
|
email:
|
115
121
|
- josepjaume@gmail.com
|
@@ -129,52 +135,101 @@ files:
|
|
129
135
|
- app/assets/stylesheets/decidim/budgets/budget/_budget-list.scss
|
130
136
|
- app/assets/stylesheets/decidim/budgets/budget/_budget-meter.scss
|
131
137
|
- app/assets/stylesheets/decidim/budgets/budget/_progress.scss
|
138
|
+
- app/cells/decidim/budgets/base_cell.rb
|
139
|
+
- app/cells/decidim/budgets/budget_cell.rb
|
140
|
+
- app/cells/decidim/budgets/budget_information_modal/show.erb
|
141
|
+
- app/cells/decidim/budgets/budget_information_modal_cell.rb
|
142
|
+
- app/cells/decidim/budgets/budget_list_item/show.erb
|
143
|
+
- app/cells/decidim/budgets/budget_list_item_cell.rb
|
144
|
+
- app/cells/decidim/budgets/budget_m/data.erb
|
145
|
+
- app/cells/decidim/budgets/budget_m/footer.erb
|
146
|
+
- app/cells/decidim/budgets/budget_m_cell.rb
|
147
|
+
- app/cells/decidim/budgets/budgets_header/show.erb
|
148
|
+
- app/cells/decidim/budgets/budgets_header_cell.rb
|
149
|
+
- app/cells/decidim/budgets/budgets_list/card_list.erb
|
150
|
+
- app/cells/decidim/budgets/budgets_list/highlighted.erb
|
151
|
+
- app/cells/decidim/budgets/budgets_list/show.erb
|
152
|
+
- app/cells/decidim/budgets/budgets_list/voted.erb
|
153
|
+
- app/cells/decidim/budgets/budgets_list_cell.rb
|
154
|
+
- app/cells/decidim/budgets/limit_announcement_cell.rb
|
132
155
|
- app/cells/decidim/budgets/project_cell.rb
|
156
|
+
- app/cells/decidim/budgets/project_list_item/project_data.erb
|
157
|
+
- app/cells/decidim/budgets/project_list_item/project_data_vote_button.erb
|
158
|
+
- app/cells/decidim/budgets/project_list_item/project_image.erb
|
159
|
+
- app/cells/decidim/budgets/project_list_item/project_text.erb
|
160
|
+
- app/cells/decidim/budgets/project_list_item/show.erb
|
161
|
+
- app/cells/decidim/budgets/project_list_item_cell.rb
|
133
162
|
- app/cells/decidim/budgets/project_m/data.erb
|
134
163
|
- app/cells/decidim/budgets/project_m/footer.erb
|
135
164
|
- app/cells/decidim/budgets/project_m_cell.rb
|
165
|
+
- app/cells/decidim/budgets/project_selected_status_cell.rb
|
166
|
+
- app/cells/decidim/budgets/project_tags/show.erb
|
167
|
+
- app/cells/decidim/budgets/project_tags_cell.rb
|
168
|
+
- app/cells/decidim/budgets/project_voted_hint_cell.rb
|
169
|
+
- app/cells/decidim/budgets/project_votes_count_cell.rb
|
136
170
|
- app/commands/decidim/budgets/add_line_item.rb
|
171
|
+
- app/commands/decidim/budgets/admin/create_budget.rb
|
137
172
|
- app/commands/decidim/budgets/admin/create_project.rb
|
173
|
+
- app/commands/decidim/budgets/admin/destroy_budget.rb
|
138
174
|
- app/commands/decidim/budgets/admin/destroy_project.rb
|
139
175
|
- app/commands/decidim/budgets/admin/import_proposals_to_budgets.rb
|
176
|
+
- app/commands/decidim/budgets/admin/update_budget.rb
|
140
177
|
- app/commands/decidim/budgets/admin/update_project.rb
|
141
178
|
- app/commands/decidim/budgets/cancel_order.rb
|
142
179
|
- app/commands/decidim/budgets/checkout.rb
|
143
180
|
- app/commands/decidim/budgets/remove_line_item.rb
|
144
181
|
- app/controllers/concerns/decidim/budgets/needs_current_order.rb
|
182
|
+
- app/controllers/concerns/decidim/budgets/orderable.rb
|
145
183
|
- app/controllers/decidim/budgets/admin/application_controller.rb
|
146
184
|
- app/controllers/decidim/budgets/admin/attachment_collections_controller.rb
|
147
185
|
- app/controllers/decidim/budgets/admin/attachments_controller.rb
|
186
|
+
- app/controllers/decidim/budgets/admin/budgets_controller.rb
|
148
187
|
- app/controllers/decidim/budgets/admin/projects_controller.rb
|
149
188
|
- app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
|
150
189
|
- app/controllers/decidim/budgets/application_controller.rb
|
190
|
+
- app/controllers/decidim/budgets/budgets_controller.rb
|
151
191
|
- app/controllers/decidim/budgets/line_items_controller.rb
|
152
192
|
- app/controllers/decidim/budgets/orders_controller.rb
|
153
193
|
- app/controllers/decidim/budgets/projects_controller.rb
|
194
|
+
- app/forms/decidim/budgets/admin/budget_form.rb
|
195
|
+
- app/forms/decidim/budgets/admin/component_form.rb
|
154
196
|
- app/forms/decidim/budgets/admin/project_form.rb
|
155
197
|
- app/forms/decidim/budgets/admin/project_import_proposals_form.rb
|
198
|
+
- app/helpers/decidim/budgets/admin/application_helper.rb
|
156
199
|
- app/helpers/decidim/budgets/application_helper.rb
|
157
200
|
- app/helpers/decidim/budgets/projects_helper.rb
|
201
|
+
- app/jobs/decidim/budgets/send_order_summary_job.rb
|
202
|
+
- app/mailers/decidim/budgets/order_summary_mailer.rb
|
158
203
|
- app/models/decidim/budgets/application_record.rb
|
204
|
+
- app/models/decidim/budgets/budget.rb
|
159
205
|
- app/models/decidim/budgets/line_item.rb
|
160
206
|
- app/models/decidim/budgets/order.rb
|
161
207
|
- app/models/decidim/budgets/project.rb
|
162
208
|
- app/permissions/decidim/budgets/admin/permissions.rb
|
163
209
|
- app/permissions/decidim/budgets/permissions.rb
|
210
|
+
- app/presenters/decidim/budgets/admin_log/budget_presenter.rb
|
164
211
|
- app/presenters/decidim/budgets/admin_log/project_presenter.rb
|
165
212
|
- app/queries/decidim/budgets/filtered_projects.rb
|
166
213
|
- app/queries/decidim/budgets/metrics/budget_followers_metric_measure.rb
|
167
214
|
- app/queries/decidim/budgets/metrics/budget_participants_metric_measure.rb
|
168
215
|
- app/serializers/decidim/budgets/data_portability_budgets_order_serializer.rb
|
169
216
|
- app/services/decidim/budgets/project_search.rb
|
217
|
+
- app/types/decidim/budgets/budget_type.rb
|
170
218
|
- app/types/decidim/budgets/budgets_type.rb
|
171
219
|
- app/types/decidim/budgets/project_type.rb
|
220
|
+
- app/views/decidim/budgets/admin/budgets/_form.html.erb
|
221
|
+
- app/views/decidim/budgets/admin/budgets/edit.html.erb
|
222
|
+
- app/views/decidim/budgets/admin/budgets/index.html.erb
|
223
|
+
- app/views/decidim/budgets/admin/budgets/new.html.erb
|
172
224
|
- app/views/decidim/budgets/admin/projects/_form.html.erb
|
173
225
|
- app/views/decidim/budgets/admin/projects/edit.html.erb
|
174
226
|
- app/views/decidim/budgets/admin/projects/index.html.erb
|
175
227
|
- app/views/decidim/budgets/admin/projects/new.html.erb
|
228
|
+
- app/views/decidim/budgets/admin/projects/proposals_picker.html.erb
|
176
229
|
- app/views/decidim/budgets/admin/proposals_imports/new.html.erb
|
230
|
+
- app/views/decidim/budgets/budgets/index.html.erb
|
177
231
|
- app/views/decidim/budgets/line_items/update_budget.js.erb
|
232
|
+
- app/views/decidim/budgets/order_summary_mailer/order_summary.html.erb
|
178
233
|
- app/views/decidim/budgets/projects/_budget_confirm.html.erb
|
179
234
|
- app/views/decidim/budgets/projects/_budget_excess.html.erb
|
180
235
|
- app/views/decidim/budgets/projects/_budget_summary.html.erb
|
@@ -191,38 +246,74 @@ files:
|
|
191
246
|
- app/views/decidim/budgets/projects/index.html.erb
|
192
247
|
- app/views/decidim/budgets/projects/index.js.erb
|
193
248
|
- app/views/decidim/budgets/projects/show.html.erb
|
249
|
+
- config/locales/am-ET.yml
|
194
250
|
- config/locales/ar-SA.yml
|
195
251
|
- config/locales/ar.yml
|
252
|
+
- config/locales/bg-BG.yml
|
253
|
+
- config/locales/bg.yml
|
196
254
|
- config/locales/ca.yml
|
197
255
|
- config/locales/cs-CZ.yml
|
198
256
|
- config/locales/cs.yml
|
257
|
+
- config/locales/da-DK.yml
|
258
|
+
- config/locales/da.yml
|
199
259
|
- config/locales/de.yml
|
200
260
|
- config/locales/el-GR.yml
|
201
261
|
- config/locales/el.yml
|
202
262
|
- config/locales/en.yml
|
203
263
|
- config/locales/eo-UY.yml
|
264
|
+
- config/locales/eo.yml
|
204
265
|
- config/locales/es-MX.yml
|
205
266
|
- config/locales/es-PY.yml
|
206
267
|
- config/locales/es.yml
|
268
|
+
- config/locales/et-EE.yml
|
269
|
+
- config/locales/et.yml
|
207
270
|
- config/locales/eu.yml
|
208
271
|
- config/locales/fi-pl.yml
|
209
272
|
- config/locales/fi-plain.yml
|
210
273
|
- config/locales/fi.yml
|
274
|
+
- config/locales/fr-CA.yml
|
211
275
|
- config/locales/fr.yml
|
276
|
+
- config/locales/ga-IE.yml
|
212
277
|
- config/locales/gl.yml
|
278
|
+
- config/locales/hr-HR.yml
|
279
|
+
- config/locales/hr.yml
|
213
280
|
- config/locales/hu.yml
|
214
281
|
- config/locales/id-ID.yml
|
215
282
|
- config/locales/is-IS.yml
|
283
|
+
- config/locales/is.yml
|
216
284
|
- config/locales/it.yml
|
285
|
+
- config/locales/ja-JP.yml
|
286
|
+
- config/locales/ja.yml
|
287
|
+
- config/locales/ko-KR.yml
|
288
|
+
- config/locales/ko.yml
|
289
|
+
- config/locales/lt-LT.yml
|
290
|
+
- config/locales/lt.yml
|
291
|
+
- config/locales/lv.yml
|
292
|
+
- config/locales/mt-MT.yml
|
293
|
+
- config/locales/mt.yml
|
217
294
|
- config/locales/nl.yml
|
218
295
|
- config/locales/no.yml
|
296
|
+
- config/locales/om-ET.yml
|
219
297
|
- config/locales/pl.yml
|
220
298
|
- config/locales/pt-BR.yml
|
221
299
|
- config/locales/pt.yml
|
300
|
+
- config/locales/ro-RO.yml
|
222
301
|
- config/locales/ru.yml
|
302
|
+
- config/locales/si-LK.yml
|
303
|
+
- config/locales/sk-SK.yml
|
304
|
+
- config/locales/sk.yml
|
305
|
+
- config/locales/sl.yml
|
306
|
+
- config/locales/so-SO.yml
|
307
|
+
- config/locales/sr-CS.yml
|
223
308
|
- config/locales/sv.yml
|
309
|
+
- config/locales/sw-KE.yml
|
310
|
+
- config/locales/ti-ER.yml
|
224
311
|
- config/locales/tr-TR.yml
|
225
312
|
- config/locales/uk.yml
|
313
|
+
- config/locales/vi-VN.yml
|
314
|
+
- config/locales/vi.yml
|
315
|
+
- config/locales/zh-CN.yml
|
316
|
+
- config/locales/zh-TW.yml
|
226
317
|
- db/migrate/20170127114122_create_projects.rb
|
227
318
|
- db/migrate/20170130095615_create_orders.rb
|
228
319
|
- db/migrate/20170130101825_create_line_items.rb
|
@@ -232,6 +323,15 @@ files:
|
|
232
323
|
- db/migrate/20170612101846_migrate_projects_category.rb
|
233
324
|
- db/migrate/20180305133340_rename_features_to_components_at_budgets.rb
|
234
325
|
- db/migrate/20181205141115_use_big_ints_for_budgets.rb
|
326
|
+
- db/migrate/20200617105120_create_decidim_budgets.rb
|
327
|
+
- db/migrate/20200629072626_rename_budget_to_budget_ammount.rb
|
328
|
+
- db/migrate/20200629134013_add_budget_reference_to_project.rb
|
329
|
+
- db/migrate/20200706142609_add_budget_reference_to_order.rb
|
330
|
+
- db/migrate/20200714103519_move_budgets_to_own_model.rb
|
331
|
+
- db/migrate/20200717140012_add_scope_to_budgets.rb
|
332
|
+
- db/migrate/20200728075039_add_selected_at_to_project.rb
|
333
|
+
- db/migrate/20200804175222_votes_enabled_to_votes_choices.rb
|
334
|
+
- db/migrate/20200827154129_add_commentable_counter_cache_to_projects.rb
|
235
335
|
- lib/decidim/budgets.rb
|
236
336
|
- lib/decidim/budgets/admin.rb
|
237
337
|
- lib/decidim/budgets/admin_engine.rb
|
@@ -241,11 +341,15 @@ files:
|
|
241
341
|
- lib/decidim/budgets/seeds/city.jpeg
|
242
342
|
- lib/decidim/budgets/test/factories.rb
|
243
343
|
- lib/decidim/budgets/version.rb
|
344
|
+
- lib/decidim/budgets/workflows.rb
|
345
|
+
- lib/decidim/budgets/workflows/all.rb
|
346
|
+
- lib/decidim/budgets/workflows/base.rb
|
347
|
+
- lib/decidim/budgets/workflows/one.rb
|
244
348
|
homepage: https://github.com/decidim/decidim
|
245
349
|
licenses:
|
246
350
|
- AGPL-3.0
|
247
351
|
metadata: {}
|
248
|
-
post_install_message:
|
352
|
+
post_install_message:
|
249
353
|
rdoc_options: []
|
250
354
|
require_paths:
|
251
355
|
- lib
|
@@ -253,15 +357,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
253
357
|
requirements:
|
254
358
|
- - ">="
|
255
359
|
- !ruby/object:Gem::Version
|
256
|
-
version: '2.
|
360
|
+
version: '2.6'
|
257
361
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
362
|
requirements:
|
259
363
|
- - ">="
|
260
364
|
- !ruby/object:Gem::Version
|
261
365
|
version: '0'
|
262
366
|
requirements: []
|
263
|
-
rubygems_version: 3.
|
264
|
-
signing_key:
|
367
|
+
rubygems_version: 3.0.3
|
368
|
+
signing_key:
|
265
369
|
specification_version: 4
|
266
370
|
summary: Decidim budgets module
|
267
371
|
test_files: []
|