decidim-budgets 0.22.0 → 0.23.3
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/stylesheets/decidim/budgets/budget/_budget-list.scss +5 -0
- 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 +17 -3
- data/app/cells/decidim/budgets/project_list_item/project_data_vote_button.erb +2 -2
- data/app/cells/decidim/budgets/project_list_item/project_text.erb +11 -5
- data/app/cells/decidim/budgets/project_list_item/show.erb +3 -3
- data/app/cells/decidim/budgets/project_list_item_cell.rb +8 -28
- data/app/cells/decidim/budgets/project_m/data.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 +12 -7
- 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 +8 -1
- data/app/commands/decidim/budgets/checkout.rb +6 -6
- data/app/commands/decidim/budgets/remove_line_item.rb +3 -2
- data/app/controllers/concerns/decidim/budgets/needs_current_order.rb +14 -2
- data/app/controllers/concerns/decidim/budgets/orderable.rb +3 -7
- 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 +7 -7
- 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 +9 -5
- data/app/controllers/decidim/budgets/orders_controller.rb +20 -6
- data/app/controllers/decidim/budgets/projects_controller.rb +19 -18
- data/app/forms/decidim/budgets/admin/budget_form.rb +39 -0
- data/app/forms/decidim/budgets/admin/project_form.rb +14 -10
- 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 +0 -4
- data/app/mailers/decidim/budgets/order_summary_mailer.rb +5 -3
- 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 +23 -19
- data/app/models/decidim/budgets/project.rb +34 -5
- 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 +12 -4
- 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/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 +1 -0
- data/app/views/decidim/budgets/projects/_budget_confirm.html.erb +3 -3
- data/app/views/decidim/budgets/projects/_budget_summary.html.erb +19 -6
- data/app/views/decidim/budgets/projects/_filters.html.erb +6 -2
- data/app/views/decidim/budgets/projects/_linked_projects.html.erb +1 -1
- data/app/views/decidim/budgets/projects/_order_progress.html.erb +10 -6
- data/app/views/decidim/budgets/projects/_order_selected_projects.html.erb +3 -3
- data/app/views/decidim/budgets/projects/_project_budget_button.html.erb +36 -7
- data/app/views/decidim/budgets/projects/index.html.erb +12 -4
- 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 -11
- data/config/locales/bg.yml +6 -0
- data/config/locales/ca.yml +102 -10
- data/config/locales/cs.yml +108 -16
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +120 -28
- data/config/locales/el.yml +3 -9
- data/config/locales/en.yml +101 -9
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +101 -9
- data/config/locales/es-PY.yml +101 -9
- data/config/locales/es.yml +102 -10
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +5 -8
- data/config/locales/fi-plain.yml +102 -10
- data/config/locales/fi.yml +103 -11
- data/config/locales/fr-CA.yml +101 -9
- data/config/locales/fr.yml +101 -9
- data/config/locales/gl.yml +70 -10
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +2 -7
- data/config/locales/id-ID.yml +2 -6
- data/config/locales/is-IS.yml +0 -6
- data/config/locales/is.yml +114 -0
- data/config/locales/it.yml +71 -9
- data/config/locales/ja-JP.yml +1 -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.yml +1 -0
- data/config/locales/{lv-LV.yml → lv.yml} +2 -10
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +88 -10
- data/config/locales/no.yml +25 -9
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +114 -22
- data/config/locales/pt-BR.yml +2 -7
- data/config/locales/pt.yml +3 -9
- data/config/locales/ro-RO.yml +3 -10
- data/config/locales/ru.yml +2 -9
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +2 -11
- data/config/locales/sl.yml +0 -4
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +0 -2
- data/config/locales/sv.yml +101 -9
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +153 -34
- data/config/locales/uk.yml +2 -9
- 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 +10 -5
- data/lib/decidim/budgets/component.rb +83 -38
- data/lib/decidim/budgets/engine.rb +8 -6
- data/lib/decidim/budgets/test/factories.rb +42 -13
- 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 +89 -20
- data/app/cells/decidim/budgets/project_list_item/project_data_number.erb +0 -3
- data/app/cells/decidim/budgets/project_list_item/project_data_votes.erb +0 -7
@@ -7,14 +7,13 @@ 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
|
-
total_budget { 100_000_000 }
|
18
17
|
vote_rule_threshold_percent_enabled { true }
|
19
18
|
vote_rule_minimum_budget_projects_enabled { false }
|
20
19
|
vote_threshold_percent { 70 }
|
@@ -22,7 +21,6 @@ FactoryBot.define do
|
|
22
21
|
|
23
22
|
settings do
|
24
23
|
{
|
25
|
-
total_budget: total_budget,
|
26
24
|
vote_rule_threshold_percent_enabled: vote_rule_threshold_percent_enabled,
|
27
25
|
vote_rule_minimum_budget_projects_enabled: vote_rule_minimum_budget_projects_enabled,
|
28
26
|
vote_threshold_percent: vote_threshold_percent
|
@@ -30,9 +28,8 @@ FactoryBot.define do
|
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
|
-
trait :
|
31
|
+
trait :with_minimum_budget_projects do
|
34
32
|
transient do
|
35
|
-
total_budget { 100_000_000 }
|
36
33
|
vote_rule_threshold_percent_enabled { false }
|
37
34
|
vote_rule_minimum_budget_projects_enabled { true }
|
38
35
|
vote_minimum_budget_projects_number { 3 }
|
@@ -40,7 +37,6 @@ FactoryBot.define do
|
|
40
37
|
|
41
38
|
settings do
|
42
39
|
{
|
43
|
-
total_budget: total_budget,
|
44
40
|
vote_rule_threshold_percent_enabled: vote_rule_threshold_percent_enabled,
|
45
41
|
vote_rule_minimum_budget_projects_enabled: vote_rule_minimum_budget_projects_enabled,
|
46
42
|
vote_minimum_budget_projects_number: vote_minimum_budget_projects_number
|
@@ -52,7 +48,7 @@ FactoryBot.define do
|
|
52
48
|
step_settings do
|
53
49
|
{
|
54
50
|
participatory_space.active_step.id => {
|
55
|
-
|
51
|
+
votes: :disabled
|
56
52
|
}
|
57
53
|
}
|
58
54
|
end
|
@@ -72,7 +68,7 @@ FactoryBot.define do
|
|
72
68
|
step_settings do
|
73
69
|
{
|
74
70
|
participatory_space.active_step.id => {
|
75
|
-
|
71
|
+
votes: :finished,
|
76
72
|
show_votes: true
|
77
73
|
}
|
78
74
|
}
|
@@ -80,20 +76,53 @@ FactoryBot.define do
|
|
80
76
|
end
|
81
77
|
end
|
82
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
|
94
|
+
end
|
95
|
+
|
83
96
|
factory :project, class: "Decidim::Budgets::Project" do
|
84
97
|
title { generate_localized_title }
|
85
98
|
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
|
86
|
-
|
87
|
-
|
99
|
+
budget_amount { Faker::Number.number(8) }
|
100
|
+
budget { create(:budget) }
|
101
|
+
|
102
|
+
trait :selected do
|
103
|
+
selected_at { Time.current }
|
104
|
+
end
|
88
105
|
end
|
89
106
|
|
90
107
|
factory :order, class: "Decidim::Budgets::Order" do
|
91
|
-
|
108
|
+
budget { create(:budget) }
|
92
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
|
93
122
|
end
|
94
123
|
|
95
124
|
factory :line_item, class: "Decidim::Budgets::LineItem" do
|
96
125
|
order
|
97
|
-
project { create(:project,
|
126
|
+
project { create(:project, budget: order.budget) }
|
98
127
|
end
|
99
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.3
|
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-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: decidim-comments
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.23.3
|
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.3
|
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.3
|
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.3
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: kaminari
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,42 +80,42 @@ dependencies:
|
|
80
80
|
requirements:
|
81
81
|
- - '='
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0.
|
83
|
+
version: 0.23.3
|
84
84
|
type: :development
|
85
85
|
prerelease: false
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - '='
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.
|
90
|
+
version: 0.23.3
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: decidim-dev
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - '='
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.
|
97
|
+
version: 0.23.3
|
98
98
|
type: :development
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - '='
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.
|
104
|
+
version: 0.23.3
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: decidim-proposals
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - '='
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: 0.
|
111
|
+
version: 0.23.3
|
112
112
|
type: :development
|
113
113
|
prerelease: false
|
114
114
|
version_requirements: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - '='
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.
|
118
|
+
version: 0.23.3
|
119
119
|
description: A budgets component for decidim's participatory spaces.
|
120
120
|
email:
|
121
121
|
- josepjaume@gmail.com
|
@@ -135,11 +135,26 @@ files:
|
|
135
135
|
- app/assets/stylesheets/decidim/budgets/budget/_budget-list.scss
|
136
136
|
- app/assets/stylesheets/decidim/budgets/budget/_budget-meter.scss
|
137
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
|
138
155
|
- app/cells/decidim/budgets/project_cell.rb
|
139
156
|
- app/cells/decidim/budgets/project_list_item/project_data.erb
|
140
|
-
- app/cells/decidim/budgets/project_list_item/project_data_number.erb
|
141
157
|
- app/cells/decidim/budgets/project_list_item/project_data_vote_button.erb
|
142
|
-
- app/cells/decidim/budgets/project_list_item/project_data_votes.erb
|
143
158
|
- app/cells/decidim/budgets/project_list_item/project_image.erb
|
144
159
|
- app/cells/decidim/budgets/project_list_item/project_text.erb
|
145
160
|
- app/cells/decidim/budgets/project_list_item/show.erb
|
@@ -147,10 +162,18 @@ files:
|
|
147
162
|
- app/cells/decidim/budgets/project_m/data.erb
|
148
163
|
- app/cells/decidim/budgets/project_m/footer.erb
|
149
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
|
150
170
|
- app/commands/decidim/budgets/add_line_item.rb
|
171
|
+
- app/commands/decidim/budgets/admin/create_budget.rb
|
151
172
|
- app/commands/decidim/budgets/admin/create_project.rb
|
173
|
+
- app/commands/decidim/budgets/admin/destroy_budget.rb
|
152
174
|
- app/commands/decidim/budgets/admin/destroy_project.rb
|
153
175
|
- app/commands/decidim/budgets/admin/import_proposals_to_budgets.rb
|
176
|
+
- app/commands/decidim/budgets/admin/update_budget.rb
|
154
177
|
- app/commands/decidim/budgets/admin/update_project.rb
|
155
178
|
- app/commands/decidim/budgets/cancel_order.rb
|
156
179
|
- app/commands/decidim/budgets/checkout.rb
|
@@ -160,39 +183,51 @@ files:
|
|
160
183
|
- app/controllers/decidim/budgets/admin/application_controller.rb
|
161
184
|
- app/controllers/decidim/budgets/admin/attachment_collections_controller.rb
|
162
185
|
- app/controllers/decidim/budgets/admin/attachments_controller.rb
|
186
|
+
- app/controllers/decidim/budgets/admin/budgets_controller.rb
|
163
187
|
- app/controllers/decidim/budgets/admin/projects_controller.rb
|
164
188
|
- app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
|
165
189
|
- app/controllers/decidim/budgets/application_controller.rb
|
190
|
+
- app/controllers/decidim/budgets/budgets_controller.rb
|
166
191
|
- app/controllers/decidim/budgets/line_items_controller.rb
|
167
192
|
- app/controllers/decidim/budgets/orders_controller.rb
|
168
193
|
- app/controllers/decidim/budgets/projects_controller.rb
|
194
|
+
- app/forms/decidim/budgets/admin/budget_form.rb
|
169
195
|
- app/forms/decidim/budgets/admin/component_form.rb
|
170
196
|
- app/forms/decidim/budgets/admin/project_form.rb
|
171
197
|
- app/forms/decidim/budgets/admin/project_import_proposals_form.rb
|
198
|
+
- app/helpers/decidim/budgets/admin/application_helper.rb
|
172
199
|
- app/helpers/decidim/budgets/application_helper.rb
|
173
200
|
- app/helpers/decidim/budgets/projects_helper.rb
|
174
201
|
- app/jobs/decidim/budgets/send_order_summary_job.rb
|
175
202
|
- app/mailers/decidim/budgets/order_summary_mailer.rb
|
176
203
|
- app/models/decidim/budgets/application_record.rb
|
204
|
+
- app/models/decidim/budgets/budget.rb
|
177
205
|
- app/models/decidim/budgets/line_item.rb
|
178
206
|
- app/models/decidim/budgets/order.rb
|
179
207
|
- app/models/decidim/budgets/project.rb
|
180
208
|
- app/permissions/decidim/budgets/admin/permissions.rb
|
181
209
|
- app/permissions/decidim/budgets/permissions.rb
|
210
|
+
- app/presenters/decidim/budgets/admin_log/budget_presenter.rb
|
182
211
|
- app/presenters/decidim/budgets/admin_log/project_presenter.rb
|
183
212
|
- app/queries/decidim/budgets/filtered_projects.rb
|
184
213
|
- app/queries/decidim/budgets/metrics/budget_followers_metric_measure.rb
|
185
214
|
- app/queries/decidim/budgets/metrics/budget_participants_metric_measure.rb
|
186
215
|
- app/serializers/decidim/budgets/data_portability_budgets_order_serializer.rb
|
187
216
|
- app/services/decidim/budgets/project_search.rb
|
217
|
+
- app/types/decidim/budgets/budget_type.rb
|
188
218
|
- app/types/decidim/budgets/budgets_type.rb
|
189
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
|
190
224
|
- app/views/decidim/budgets/admin/projects/_form.html.erb
|
191
225
|
- app/views/decidim/budgets/admin/projects/edit.html.erb
|
192
226
|
- app/views/decidim/budgets/admin/projects/index.html.erb
|
193
227
|
- app/views/decidim/budgets/admin/projects/new.html.erb
|
194
228
|
- app/views/decidim/budgets/admin/projects/proposals_picker.html.erb
|
195
229
|
- app/views/decidim/budgets/admin/proposals_imports/new.html.erb
|
230
|
+
- app/views/decidim/budgets/budgets/index.html.erb
|
196
231
|
- app/views/decidim/budgets/line_items/update_budget.js.erb
|
197
232
|
- app/views/decidim/budgets/order_summary_mailer/order_summary.html.erb
|
198
233
|
- app/views/decidim/budgets/projects/_budget_confirm.html.erb
|
@@ -211,22 +246,27 @@ files:
|
|
211
246
|
- app/views/decidim/budgets/projects/index.html.erb
|
212
247
|
- app/views/decidim/budgets/projects/index.js.erb
|
213
248
|
- app/views/decidim/budgets/projects/show.html.erb
|
249
|
+
- config/locales/am-ET.yml
|
214
250
|
- config/locales/ar-SA.yml
|
215
251
|
- config/locales/ar.yml
|
216
252
|
- config/locales/bg-BG.yml
|
253
|
+
- config/locales/bg.yml
|
217
254
|
- config/locales/ca.yml
|
218
255
|
- config/locales/cs-CZ.yml
|
219
256
|
- config/locales/cs.yml
|
220
257
|
- config/locales/da-DK.yml
|
258
|
+
- config/locales/da.yml
|
221
259
|
- config/locales/de.yml
|
222
260
|
- config/locales/el-GR.yml
|
223
261
|
- config/locales/el.yml
|
224
262
|
- config/locales/en.yml
|
225
263
|
- config/locales/eo-UY.yml
|
264
|
+
- config/locales/eo.yml
|
226
265
|
- config/locales/es-MX.yml
|
227
266
|
- config/locales/es-PY.yml
|
228
267
|
- config/locales/es.yml
|
229
268
|
- config/locales/et-EE.yml
|
269
|
+
- config/locales/et.yml
|
230
270
|
- config/locales/eu.yml
|
231
271
|
- config/locales/fi-pl.yml
|
232
272
|
- config/locales/fi-plain.yml
|
@@ -236,28 +276,44 @@ files:
|
|
236
276
|
- config/locales/ga-IE.yml
|
237
277
|
- config/locales/gl.yml
|
238
278
|
- config/locales/hr-HR.yml
|
279
|
+
- config/locales/hr.yml
|
239
280
|
- config/locales/hu.yml
|
240
281
|
- config/locales/id-ID.yml
|
241
282
|
- config/locales/is-IS.yml
|
283
|
+
- config/locales/is.yml
|
242
284
|
- config/locales/it.yml
|
243
285
|
- config/locales/ja-JP.yml
|
286
|
+
- config/locales/ja.yml
|
287
|
+
- config/locales/ko-KR.yml
|
288
|
+
- config/locales/ko.yml
|
244
289
|
- config/locales/lt-LT.yml
|
245
|
-
- config/locales/
|
290
|
+
- config/locales/lt.yml
|
291
|
+
- config/locales/lv.yml
|
246
292
|
- config/locales/mt-MT.yml
|
293
|
+
- config/locales/mt.yml
|
247
294
|
- config/locales/nl.yml
|
248
295
|
- config/locales/no.yml
|
296
|
+
- config/locales/om-ET.yml
|
249
297
|
- config/locales/pl.yml
|
250
298
|
- config/locales/pt-BR.yml
|
251
299
|
- config/locales/pt.yml
|
252
300
|
- config/locales/ro-RO.yml
|
253
301
|
- config/locales/ru.yml
|
302
|
+
- config/locales/si-LK.yml
|
254
303
|
- config/locales/sk-SK.yml
|
255
304
|
- config/locales/sk.yml
|
256
305
|
- config/locales/sl.yml
|
306
|
+
- config/locales/so-SO.yml
|
257
307
|
- config/locales/sr-CS.yml
|
258
308
|
- config/locales/sv.yml
|
309
|
+
- config/locales/sw-KE.yml
|
310
|
+
- config/locales/ti-ER.yml
|
259
311
|
- config/locales/tr-TR.yml
|
260
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
|
261
317
|
- db/migrate/20170127114122_create_projects.rb
|
262
318
|
- db/migrate/20170130095615_create_orders.rb
|
263
319
|
- db/migrate/20170130101825_create_line_items.rb
|
@@ -267,6 +323,15 @@ files:
|
|
267
323
|
- db/migrate/20170612101846_migrate_projects_category.rb
|
268
324
|
- db/migrate/20180305133340_rename_features_to_components_at_budgets.rb
|
269
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
|
270
335
|
- lib/decidim/budgets.rb
|
271
336
|
- lib/decidim/budgets/admin.rb
|
272
337
|
- lib/decidim/budgets/admin_engine.rb
|
@@ -276,11 +341,15 @@ files:
|
|
276
341
|
- lib/decidim/budgets/seeds/city.jpeg
|
277
342
|
- lib/decidim/budgets/test/factories.rb
|
278
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
|
279
348
|
homepage: https://github.com/decidim/decidim
|
280
349
|
licenses:
|
281
350
|
- AGPL-3.0
|
282
351
|
metadata: {}
|
283
|
-
post_install_message:
|
352
|
+
post_install_message:
|
284
353
|
rdoc_options: []
|
285
354
|
require_paths:
|
286
355
|
- lib
|
@@ -288,15 +357,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
288
357
|
requirements:
|
289
358
|
- - ">="
|
290
359
|
- !ruby/object:Gem::Version
|
291
|
-
version: '2.
|
360
|
+
version: '2.6'
|
292
361
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
293
362
|
requirements:
|
294
363
|
- - ">="
|
295
364
|
- !ruby/object:Gem::Version
|
296
365
|
version: '0'
|
297
366
|
requirements: []
|
298
|
-
rubygems_version: 3.
|
299
|
-
signing_key:
|
367
|
+
rubygems_version: 3.0.3
|
368
|
+
signing_key:
|
300
369
|
specification_version: 4
|
301
370
|
summary: Decidim budgets module
|
302
371
|
test_files: []
|