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
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Budgets
|
5
|
+
# This cell renders information when current user can't create more budgets orders.
|
6
|
+
class LimitAnnouncementCell < BaseCell
|
7
|
+
alias budget model
|
8
|
+
delegate :voted?, :vote_allowed?, :discardable, :limit_reached?, to: :current_workflow
|
9
|
+
delegate :voting_open?, to: :controller
|
10
|
+
|
11
|
+
def show
|
12
|
+
cell("decidim/announcement", announcement_args) if announce?
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def announce?
|
18
|
+
return unless voting_open?
|
19
|
+
return unless current_user
|
20
|
+
return if vote_allowed?(budget)
|
21
|
+
return if voted?(budget)
|
22
|
+
|
23
|
+
discardable.any? || !vote_allowed?(budget, false)
|
24
|
+
end
|
25
|
+
|
26
|
+
def announcement_args
|
27
|
+
{
|
28
|
+
callout_class: "warning",
|
29
|
+
announcement: announcement_message
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def announcement_message
|
34
|
+
if discardable.any?
|
35
|
+
t(:limit_reached, scope: i18n_scope,
|
36
|
+
links: budgets_link_list(discardable),
|
37
|
+
landing_path: budgets_path)
|
38
|
+
else
|
39
|
+
t(:cant_vote, scope: i18n_scope, landing_path: budgets_path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def should_discard_to_vote?
|
44
|
+
limit_reached? && discardable.any?
|
45
|
+
end
|
46
|
+
|
47
|
+
def i18n_scope
|
48
|
+
"decidim.budgets.limit_announcement"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,5 +1,19 @@
|
|
1
1
|
<div class="budget-list__data <%= data_class %>">
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
<% if voting_finished? %>
|
3
|
+
<div class="budget-list__data__votes">
|
4
|
+
<%= cell("decidim/budgets/project_votes_count", model) %>
|
5
|
+
|
6
|
+
<%= cell("decidim/budgets/project_voted_hint", model, class: "display-block margin-top-1") %>
|
7
|
+
</div>
|
8
|
+
<% else %>
|
9
|
+
<span class="budget-list__data__number budget-list__number show-for-medium">
|
10
|
+
<%= budget_to_currency(model.budget_amount) %>
|
11
|
+
|
12
|
+
<%= cell("decidim/budgets/project_votes_count", model, layout: :one_line, class: "display-inline-block") %>
|
13
|
+
|
14
|
+
<%= cell("decidim/budgets/project_voted_hint", model, class: "display-block margin-top-1") if current_order_checked_out? && resource_added? %>
|
15
|
+
</span>
|
16
|
+
|
17
|
+
<%= render :project_data_vote_button if !current_order_checked_out? && voting_open? %>
|
18
|
+
<% end %>
|
5
19
|
</div>
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<%= action_authorized_button_to "vote",
|
2
|
-
|
2
|
+
budget_order_line_item_path(model.budget, project_id: model),
|
3
3
|
method: vote_button_method,
|
4
4
|
remote: true,
|
5
5
|
class: "button tiny budget-list__action #{vote_button_class}",
|
6
6
|
data: {
|
7
7
|
add: !resource_added?,
|
8
8
|
disable: true,
|
9
|
-
budget: model.
|
9
|
+
budget: model.budget_amount,
|
10
10
|
"redirect-url": resource_path
|
11
11
|
},
|
12
12
|
disabled: vote_button_disabled?,
|
@@ -1,17 +1,23 @@
|
|
1
|
-
<div class="budget-list__text">
|
1
|
+
<div class="budget-list__text card__text">
|
2
2
|
<div>
|
3
3
|
<%= link_to resource_path, class: "card__link" do %>
|
4
4
|
<h5 class="card__title budget-list__title">
|
5
|
+
<%= cell("decidim/budgets/project_selected_status", model) %>
|
6
|
+
|
5
7
|
<%= resource_title %>
|
6
8
|
</h5>
|
7
9
|
<% end %>
|
8
10
|
|
9
11
|
<div class="show-for-medium">
|
10
|
-
<%= cell "decidim/
|
12
|
+
<%= cell "decidim/budgets/project_tags", model, context: { extra_classes: ["tags--project"] } %>
|
11
13
|
</div>
|
12
14
|
|
13
|
-
<
|
14
|
-
<%=
|
15
|
-
|
15
|
+
<div class="budget-list__data__number budget-list__number hide-for-medium">
|
16
|
+
<%= cell("decidim/budgets/project_votes_count",
|
17
|
+
model,
|
18
|
+
layout: :one_line) %>
|
19
|
+
|
20
|
+
<%= cell("decidim/budgets/project_voted_hint", model, class: "margin-left-1") if current_order_checked_out? && resource_added? %>
|
21
|
+
</div>
|
16
22
|
</div>
|
17
23
|
</div>
|
@@ -11,36 +11,13 @@ module Decidim
|
|
11
11
|
include Decidim::Budgets::ProjectsHelper
|
12
12
|
include Decidim::Budgets::Engine.routes.url_helpers
|
13
13
|
|
14
|
-
delegate :current_user, :current_settings, :current_order, :current_component,
|
15
|
-
|
16
|
-
def project_image
|
17
|
-
render
|
18
|
-
end
|
19
|
-
|
20
|
-
def project_text
|
21
|
-
render
|
22
|
-
end
|
23
|
-
|
24
|
-
def project_data
|
25
|
-
render
|
26
|
-
end
|
27
|
-
|
28
|
-
def project_data_number
|
29
|
-
render
|
30
|
-
end
|
31
|
-
|
32
|
-
def project_data_votes
|
33
|
-
render
|
34
|
-
end
|
35
|
-
|
36
|
-
def project_data_vote_button
|
37
|
-
render
|
38
|
-
end
|
14
|
+
delegate :current_user, :current_settings, :current_order, :current_component,
|
15
|
+
:current_participatory_space, :can_have_order?, :voting_open?, :voting_finished?, to: :parent_controller
|
39
16
|
|
40
17
|
private
|
41
18
|
|
42
19
|
def resource_path
|
43
|
-
resource_locator(model).path
|
20
|
+
resource_locator([model.budget, model]).path(filter_link_params)
|
44
21
|
end
|
45
22
|
|
46
23
|
def resource_title
|
@@ -52,11 +29,14 @@ module Decidim
|
|
52
29
|
end
|
53
30
|
|
54
31
|
def data_class
|
55
|
-
|
32
|
+
[].tap do |list|
|
33
|
+
list << "budget-list__data--added" if can_have_order? && resource_added?
|
34
|
+
list << "show-for-medium" if voting_finished? || (current_order_checked_out? && !resource_added?)
|
35
|
+
end.join(" ")
|
56
36
|
end
|
57
37
|
|
58
38
|
def vote_button_disabled?
|
59
|
-
|
39
|
+
current_user && !can_have_order?
|
60
40
|
end
|
61
41
|
|
62
42
|
def vote_button_class
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Budgets
|
5
|
+
# This cell renders the selected status if the project has been selected
|
6
|
+
class ProjectSelectedStatusCell < Decidim::ViewModel
|
7
|
+
delegate :voting_finished?, to: :controller
|
8
|
+
|
9
|
+
def show
|
10
|
+
if voting_finished? && model.selected?
|
11
|
+
content_tag :span, class: css_class do
|
12
|
+
t("decidim.budgets.projects.project.selected")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def css_class
|
20
|
+
if options[:as_label] == true
|
21
|
+
"success label project-status"
|
22
|
+
else
|
23
|
+
"success card__text--status"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Budgets
|
5
|
+
# This cell overrides *_path methods from Decidim::TagsCell for project tags
|
6
|
+
class ProjectTagsCell < Decidim::TagsCell
|
7
|
+
private
|
8
|
+
|
9
|
+
def category_path
|
10
|
+
resource_locator([model.budget, model]).index(filter: { category_id: [model.category.id.to_s] })
|
11
|
+
end
|
12
|
+
|
13
|
+
def scope_path
|
14
|
+
resource_locator([model.budget, model]).index(filter: { scope_id: [model.scope.id] })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Budgets
|
5
|
+
# This cell renders a checkmark with a text.
|
6
|
+
class ProjectVotedHintCell < BaseCell
|
7
|
+
include Decidim::IconHelper
|
8
|
+
|
9
|
+
delegate :voted_for?, :current_order, to: :controller
|
10
|
+
|
11
|
+
def show
|
12
|
+
return unless voted_for?(model)
|
13
|
+
|
14
|
+
content_tag :span, safe_join(hint), class: css_class
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def hint
|
20
|
+
contents = []
|
21
|
+
contents << icon("check", role: "img")
|
22
|
+
contents << " "
|
23
|
+
contents << t("decidim.budgets.projects.project.you_voted")
|
24
|
+
end
|
25
|
+
|
26
|
+
def css_class
|
27
|
+
css = ["text-sm", "text-success"]
|
28
|
+
css << options[:class] if options[:class]
|
29
|
+
css.join(" ")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Budgets
|
5
|
+
# This cell renders the vote count.
|
6
|
+
# Two possible layouts: One or two lines
|
7
|
+
class ProjectVotesCountCell < Decidim::ViewModel
|
8
|
+
include Decidim::IconHelper
|
9
|
+
delegate :show_votes_count?, to: :controller
|
10
|
+
|
11
|
+
def show
|
12
|
+
return unless show_votes_count?
|
13
|
+
|
14
|
+
content_tag :span, content, class: css_class
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def content
|
20
|
+
if options[:layout] == :one_line
|
21
|
+
safe_join([model.confirmed_orders_count, " ", label(t("decidim.budgets.projects.project.votes",
|
22
|
+
count: model.confirmed_orders_count))])
|
23
|
+
else
|
24
|
+
safe_join([number, label(t("decidim.budgets.projects.project.votes",
|
25
|
+
count: model.confirmed_orders_count))])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def number
|
30
|
+
content_tag :div, model.confirmed_orders_count, class: "text-large"
|
31
|
+
end
|
32
|
+
|
33
|
+
def label(i18n_string)
|
34
|
+
content_tag :span, i18n_string, class: "text-uppercase text-small"
|
35
|
+
end
|
36
|
+
|
37
|
+
def css_class
|
38
|
+
css = ["project-votes"]
|
39
|
+
css << options[:class] if options[:class]
|
40
|
+
css.join(" ")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -23,7 +23,7 @@ module Decidim
|
|
23
23
|
# Returns nothing.
|
24
24
|
def call
|
25
25
|
transaction do
|
26
|
-
return broadcast(:invalid) if
|
26
|
+
return broadcast(:invalid) if voting_not_enabled? || order.checked_out?
|
27
27
|
|
28
28
|
add_line_item
|
29
29
|
broadcast(:ok, order)
|
@@ -32,23 +32,20 @@ module Decidim
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
+
attr_reader :current_user, :project
|
36
|
+
|
35
37
|
def order
|
36
|
-
@order ||= Order.create!(user:
|
38
|
+
@order ||= Order.create!(user: current_user, budget: project.budget)
|
37
39
|
end
|
38
40
|
|
39
41
|
def add_line_item
|
40
42
|
order.with_lock do
|
41
|
-
order.projects <<
|
42
|
-
order.save!
|
43
|
+
order.projects << project
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
|
-
def
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
def votes_disabled?
|
51
|
-
!component.current_settings.votes_enabled?
|
47
|
+
def voting_not_enabled?
|
48
|
+
project.component.current_settings.votes != "enabled"
|
52
49
|
end
|
53
50
|
end
|
54
51
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Budgets
|
5
|
+
module Admin
|
6
|
+
# This command is executed when the user creates an Budget
|
7
|
+
# from the admin panel.
|
8
|
+
class CreateBudget < Rectify::Command
|
9
|
+
def initialize(form)
|
10
|
+
@form = form
|
11
|
+
end
|
12
|
+
|
13
|
+
# Creates the budget if valid.
|
14
|
+
#
|
15
|
+
# Broadcasts :ok if successful, :invalid otherwise.
|
16
|
+
def call
|
17
|
+
return broadcast(:invalid) if form.invalid?
|
18
|
+
|
19
|
+
create_budget!
|
20
|
+
|
21
|
+
broadcast(:ok, budget)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :form, :budget
|
27
|
+
|
28
|
+
def create_budget!
|
29
|
+
attributes = {
|
30
|
+
component: form.current_component,
|
31
|
+
scope: form.scope,
|
32
|
+
title: form.title,
|
33
|
+
weight: form.weight,
|
34
|
+
description: form.description,
|
35
|
+
total_budget: form.total_budget
|
36
|
+
}
|
37
|
+
|
38
|
+
@budget = Decidim.traceability.create!(
|
39
|
+
Budget,
|
40
|
+
form.current_user,
|
41
|
+
attributes,
|
42
|
+
visibility: "all"
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -25,7 +25,7 @@ module Decidim
|
|
25
25
|
end
|
26
26
|
|
27
27
|
transaction do
|
28
|
-
create_project
|
28
|
+
create_project!
|
29
29
|
link_proposals
|
30
30
|
create_gallery if process_gallery?
|
31
31
|
end
|
@@ -37,16 +37,21 @@ module Decidim
|
|
37
37
|
|
38
38
|
attr_reader :form, :project, :gallery
|
39
39
|
|
40
|
-
def create_project
|
41
|
-
|
42
|
-
|
43
|
-
form.current_user,
|
40
|
+
def create_project!
|
41
|
+
attributes = {
|
42
|
+
budget: form.budget,
|
44
43
|
scope: form.scope,
|
45
44
|
category: form.category,
|
46
|
-
component: form.current_component,
|
47
45
|
title: form.title,
|
48
46
|
description: form.description,
|
49
|
-
|
47
|
+
budget_amount: form.budget_amount
|
48
|
+
}
|
49
|
+
|
50
|
+
@project = Decidim.traceability.create!(
|
51
|
+
Project,
|
52
|
+
form.current_user,
|
53
|
+
attributes,
|
54
|
+
visibility: "all"
|
50
55
|
)
|
51
56
|
@attached_to = @project
|
52
57
|
end
|