decidim-budgets 0.10.1 → 0.11.0.pre1
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 +1 -1
- data/app/assets/javascripts/decidim/budgets/projects.js.es6 +10 -10
- data/app/commands/decidim/budgets/add_line_item.rb +4 -4
- data/app/commands/decidim/budgets/admin/create_project.rb +4 -2
- data/app/commands/decidim/budgets/admin/destroy_project.rb +42 -0
- data/app/commands/decidim/budgets/admin/update_project.rb +3 -1
- data/app/commands/decidim/budgets/checkout.rb +3 -3
- data/app/controllers/concerns/decidim/budgets/needs_current_order.rb +1 -1
- data/app/controllers/decidim/budgets/admin/application_controller.rb +3 -3
- data/app/controllers/decidim/budgets/admin/attachment_collections_controller.rb +2 -2
- data/app/controllers/decidim/budgets/admin/attachments_controller.rb +1 -1
- data/app/controllers/decidim/budgets/admin/projects_controller.rb +8 -7
- data/app/controllers/decidim/budgets/application_controller.rb +2 -2
- data/app/controllers/decidim/budgets/line_items_controller.rb +1 -1
- data/app/controllers/decidim/budgets/orders_controller.rb +1 -1
- data/app/controllers/decidim/budgets/projects_controller.rb +2 -2
- data/app/forms/decidim/budgets/admin/project_form.rb +2 -2
- data/app/models/decidim/budgets/line_item.rb +3 -3
- data/app/models/decidim/budgets/order.rb +10 -10
- data/app/models/decidim/budgets/project.rb +11 -5
- data/app/presenters/decidim/budgets/admin_log/project_presenter.rb +42 -0
- data/app/queries/decidim/budgets/filtered_projects.rb +9 -9
- data/app/services/decidim/budgets/project_search.rb +2 -2
- data/app/views/decidim/budgets/admin/projects/_form.html.erb +6 -7
- data/app/views/decidim/budgets/admin/projects/edit.html.erb +2 -2
- data/app/views/decidim/budgets/admin/projects/index.html.erb +5 -5
- data/app/views/decidim/budgets/admin/projects/new.html.erb +2 -3
- data/app/views/decidim/budgets/projects/_budget_confirm.html.erb +6 -6
- data/app/views/decidim/budgets/projects/_budget_excess.html.erb +4 -4
- data/app/views/decidim/budgets/projects/_budget_summary.html.erb +11 -11
- data/app/views/decidim/budgets/projects/_filters.html.erb +4 -4
- data/app/views/decidim/budgets/projects/_filters_small_view.html.erb +1 -1
- data/app/views/decidim/budgets/projects/_order_progress.html.erb +6 -6
- data/app/views/decidim/budgets/projects/_order_selected_projects.html.erb +3 -3
- data/app/views/decidim/budgets/projects/_project.html.erb +6 -6
- data/app/views/decidim/budgets/projects/_project_budget_button.html.erb +3 -3
- data/app/views/decidim/budgets/projects/_projects.html.erb +1 -1
- data/app/views/decidim/budgets/projects/index.html.erb +3 -3
- data/app/views/decidim/budgets/projects/show.html.erb +4 -4
- data/config/locales/ca.yml +7 -1
- data/config/locales/en.yml +7 -1
- data/config/locales/es.yml +8 -2
- data/config/locales/eu.yml +9 -3
- data/config/locales/fi.yml +9 -3
- data/config/locales/fr.yml +8 -2
- data/config/locales/gl.yml +7 -1
- data/config/locales/it.yml +8 -2
- data/config/locales/nl.yml +11 -5
- data/config/locales/pl.yml +7 -1
- data/config/locales/pt-BR.yml +7 -1
- data/config/locales/pt.yml +7 -1
- data/config/locales/ru.yml +0 -7
- data/config/locales/sv.yml +7 -1
- data/config/locales/uk.yml +0 -7
- data/db/migrate/20170215132708_add_reference_to_projects.rb +5 -1
- data/db/migrate/20180305133340_rename_features_to_components_at_budgets.rb +17 -0
- data/lib/decidim/budgets/{feature.rb → component.rb} +23 -22
- data/lib/decidim/budgets/test/factories.rb +6 -6
- data/lib/decidim/budgets/version.rb +1 -1
- data/lib/decidim/budgets.rb +1 -1
- metadata +18 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cd0751b67b4aabebe67fe6bf0987e8ecd3b0e850990747c829a79394f6d3ffb
|
4
|
+
data.tar.gz: '09bef5af8fd5d261512113760f32f1c224bf3b1738c385f23840b27c82a403e2'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 192158943da4f666a91adf4d5254a8076f1aeec3a8919509f827f89480c858dc3e652e42a4de77ed838b3af02162df69daae873ef2af610d875f63a7c10e8cae
|
7
|
+
data.tar.gz: 37b2f1864b2e96720ed8e17da6ce41677b70b644e67649ae7a83a1cd399ca0b0125471bc296b20b900d32342b32de6d4bed81f120cd85237614e77933fe6a7d3
|
data/README.md
CHANGED
@@ -2,27 +2,27 @@
|
|
2
2
|
// = require_self
|
3
3
|
|
4
4
|
$(() => {
|
5
|
-
const $projects = $(
|
6
|
-
const $budgetSummaryTotal = $(
|
7
|
-
const $budgetExceedModal = $(
|
5
|
+
const $projects = $("#projects, #project");
|
6
|
+
const $budgetSummaryTotal = $(".budget-summary__total");
|
7
|
+
const $budgetExceedModal = $("#budget-excess");
|
8
8
|
|
9
|
-
const totalBudget = parseInt($budgetSummaryTotal.attr(
|
9
|
+
const totalBudget = parseInt($budgetSummaryTotal.attr("data-total-budget"), 10);
|
10
10
|
|
11
11
|
const cancelEvent = (event) => {
|
12
12
|
event.stopPropagation();
|
13
13
|
event.preventDefault();
|
14
14
|
};
|
15
15
|
|
16
|
-
$projects.on(
|
17
|
-
const currentBudget = parseInt($(
|
16
|
+
$projects.on("click", ".budget--list__action", (event) => {
|
17
|
+
const currentBudget = parseInt($(".budget-summary__progressbox").attr("data-current-budget"), 10);
|
18
18
|
const $currentTarget = $(event.currentTarget);
|
19
|
-
const projectBudget = parseInt($currentTarget.attr(
|
19
|
+
const projectBudget = parseInt($currentTarget.attr("data-budget"), 10);
|
20
20
|
|
21
|
-
if ($currentTarget.attr(
|
21
|
+
if ($currentTarget.attr("disabled")) {
|
22
22
|
cancelEvent(event);
|
23
23
|
|
24
|
-
} else if ($currentTarget.attr(
|
25
|
-
$budgetExceedModal.foundation(
|
24
|
+
} else if ($currentTarget.attr("data-add") && ((currentBudget + projectBudget) > totalBudget)) {
|
25
|
+
$budgetExceedModal.foundation("toggle");
|
26
26
|
cancelEvent(event);
|
27
27
|
}
|
28
28
|
});
|
@@ -32,7 +32,7 @@ module Decidim
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def order
|
35
|
-
@order ||= Order.create!(user: @current_user,
|
35
|
+
@order ||= Order.create!(user: @current_user, component: @project.component)
|
36
36
|
end
|
37
37
|
|
38
38
|
def add_line_item
|
@@ -42,12 +42,12 @@ module Decidim
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
@project.
|
45
|
+
def component
|
46
|
+
@project.component
|
47
47
|
end
|
48
48
|
|
49
49
|
def votes_disabled?
|
50
|
-
!
|
50
|
+
!component.current_settings.votes_enabled?
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -29,10 +29,12 @@ module Decidim
|
|
29
29
|
attr_reader :project
|
30
30
|
|
31
31
|
def create_project
|
32
|
-
@project =
|
32
|
+
@project = Decidim.traceability.create!(
|
33
|
+
Project,
|
34
|
+
@form.current_user,
|
33
35
|
scope: @form.scope,
|
34
36
|
category: @form.category,
|
35
|
-
|
37
|
+
component: @form.current_component,
|
36
38
|
title: @form.title,
|
37
39
|
description: @form.description,
|
38
40
|
budget: @form.budget
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Budgets
|
5
|
+
module Admin
|
6
|
+
# This command is executed when the user deletes a Project from the admin
|
7
|
+
# panel.
|
8
|
+
class DestroyProject < Rectify::Command
|
9
|
+
# Initializes an UpdateProject Command.
|
10
|
+
#
|
11
|
+
# project - The current instance of the project to be destroyed.
|
12
|
+
# current_user - the user that performs the action
|
13
|
+
def initialize(project, current_user)
|
14
|
+
@project = project
|
15
|
+
@current_user = current_user
|
16
|
+
end
|
17
|
+
|
18
|
+
# Performs the action.
|
19
|
+
#
|
20
|
+
# Broadcasts :ok if successful, :invalid otherwise.
|
21
|
+
def call
|
22
|
+
destroy_project
|
23
|
+
broadcast(:ok)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :project, :current_user
|
29
|
+
|
30
|
+
def destroy_project
|
31
|
+
Decidim.traceability.perform_action!(
|
32
|
+
:delete,
|
33
|
+
project,
|
34
|
+
current_user
|
35
|
+
) do
|
36
|
+
project.destroy!
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -7,10 +7,10 @@ module Decidim
|
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# order - The current order for the user.
|
10
|
-
#
|
11
|
-
def initialize(order,
|
10
|
+
# component - The current component.
|
11
|
+
def initialize(order, component)
|
12
12
|
@order = order
|
13
|
-
@
|
13
|
+
@component = component
|
14
14
|
end
|
15
15
|
|
16
16
|
# Executes the command. Broadcasts these events:
|
@@ -15,7 +15,7 @@ module Decidim
|
|
15
15
|
#
|
16
16
|
# Returns an Order.
|
17
17
|
def current_order
|
18
|
-
@current_order ||= Order.includes(:projects).find_by(user: current_user,
|
18
|
+
@current_order ||= Order.includes(:projects).find_by(user: current_user, component: current_component)
|
19
19
|
end
|
20
20
|
|
21
21
|
def current_order=(order)
|
@@ -6,13 +6,13 @@ module Decidim
|
|
6
6
|
# This controller is the abstract class from which all other controllers of
|
7
7
|
# this engine inherit.
|
8
8
|
#
|
9
|
-
# Note that it inherits from `Decidim::
|
9
|
+
# Note that it inherits from `Decidim::Components::BaseController`, which
|
10
10
|
# override its layout and provide all kinds of useful methods.
|
11
|
-
class ApplicationController < Decidim::Admin::
|
11
|
+
class ApplicationController < Decidim::Admin::Components::BaseController
|
12
12
|
helper_method :projects, :project
|
13
13
|
|
14
14
|
def projects
|
15
|
-
@projects ||= Project.where(
|
15
|
+
@projects ||= Project.where(component: current_component)
|
16
16
|
end
|
17
17
|
|
18
18
|
def project
|
@@ -9,7 +9,7 @@ module Decidim
|
|
9
9
|
include Decidim::Admin::Concerns::HasAttachmentCollections
|
10
10
|
|
11
11
|
def after_destroy_path
|
12
|
-
project_attachment_collections_path(project, project.
|
12
|
+
project_attachment_collections_path(project, project.component, current_participatory_space)
|
13
13
|
end
|
14
14
|
|
15
15
|
def collection_for
|
@@ -21,7 +21,7 @@ module Decidim
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def authorization_object
|
24
|
-
project.
|
24
|
+
project.component
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -48,21 +48,22 @@ module Decidim
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def destroy
|
51
|
-
project
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
DestroyProject.call(project, current_user) do
|
52
|
+
on(:ok) do
|
53
|
+
flash[:notice] = I18n.t("projects.destroy.success", scope: "decidim.budgets.admin")
|
54
|
+
redirect_to projects_path
|
55
|
+
end
|
56
|
+
end
|
56
57
|
end
|
57
58
|
|
58
59
|
private
|
59
60
|
|
60
61
|
def projects
|
61
|
-
@projects ||= Project.where(
|
62
|
+
@projects ||= Project.where(component: current_component).page(params[:page]).per(15)
|
62
63
|
end
|
63
64
|
|
64
65
|
def orders
|
65
|
-
@orders ||= Order.where(
|
66
|
+
@orders ||= Order.where(component: current_component)
|
66
67
|
end
|
67
68
|
|
68
69
|
def pending_orders
|
@@ -5,9 +5,9 @@ module Decidim
|
|
5
5
|
# This controller is the abstract class from which all other controllers of
|
6
6
|
# this engine inherit.
|
7
7
|
#
|
8
|
-
# Note that it inherits from `Decidim::
|
8
|
+
# Note that it inherits from `Decidim::Components::BaseController`, which
|
9
9
|
# override its layout and provide all kinds of useful methods.
|
10
|
-
class ApplicationController < Decidim::
|
10
|
+
class ApplicationController < Decidim::Components::BaseController
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -9,7 +9,7 @@ module Decidim
|
|
9
9
|
def checkout
|
10
10
|
authorize_action! "vote"
|
11
11
|
|
12
|
-
Checkout.call(current_order,
|
12
|
+
Checkout.call(current_order, current_component) do
|
13
13
|
on(:ok) do
|
14
14
|
flash[:notice] = I18n.t("orders.checkout.success", scope: "decidim")
|
15
15
|
redirect_to projects_path
|
@@ -12,7 +12,7 @@ module Decidim
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def projects
|
15
|
-
@projects ||= search.results.page(params[:page]).per(
|
15
|
+
@projects ||= search.results.page(params[:page]).per(current_component.settings.projects_per_page)
|
16
16
|
end
|
17
17
|
|
18
18
|
def random_seed
|
@@ -37,7 +37,7 @@ module Decidim
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def context_params
|
40
|
-
{
|
40
|
+
{ component: current_component, organization: current_organization }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -25,7 +25,7 @@ module Decidim
|
|
25
25
|
|
26
26
|
validate :scope_belongs_to_participatory_space_scope
|
27
27
|
|
28
|
-
delegate :categories, to: :
|
28
|
+
delegate :categories, to: :current_component
|
29
29
|
|
30
30
|
def map_model(model)
|
31
31
|
self.proposal_ids = model.linked_resources(:proposals, "included_proposals").pluck(:id)
|
@@ -36,7 +36,7 @@ module Decidim
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def proposals
|
39
|
-
@proposals ||= Decidim.find_resource_manifest(:proposals).try(:resource_scope,
|
39
|
+
@proposals ||= Decidim.find_resource_manifest(:proposals).try(:resource_scope, current_component)&.order(title: :asc)&.pluck(:title, :id)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Finds the Category from the decidim_category_id.
|
@@ -9,11 +9,11 @@ module Decidim
|
|
9
9
|
belongs_to :project, class_name: "Decidim::Budgets::Project", foreign_key: "decidim_project_id"
|
10
10
|
|
11
11
|
validates :order, uniqueness: { scope: :project }
|
12
|
-
validate :
|
12
|
+
validate :same_component
|
13
13
|
|
14
|
-
def
|
14
|
+
def same_component
|
15
15
|
return unless order && project
|
16
|
-
errors.add(:order, :invalid) unless order.
|
16
|
+
errors.add(:order, :invalid) unless order.component == project.component
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -3,18 +3,18 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Budgets
|
5
5
|
# The data store for a Order in the Decidim::Budgets component. It is unique for each
|
6
|
-
# user and
|
6
|
+
# user and component and contains a collection of projects
|
7
7
|
class Order < Budgets::ApplicationRecord
|
8
|
-
include Decidim::
|
8
|
+
include Decidim::HasComponent
|
9
9
|
|
10
|
-
|
10
|
+
component_manifest_name "budgets"
|
11
11
|
|
12
12
|
belongs_to :user, class_name: "Decidim::User", foreign_key: "decidim_user_id"
|
13
13
|
|
14
14
|
has_many :line_items, class_name: "Decidim::Budgets::LineItem", foreign_key: "decidim_order_id", dependent: :destroy
|
15
15
|
has_many :projects, through: :line_items, class_name: "Decidim::Budgets::Project", foreign_key: "decidim_project_id"
|
16
16
|
|
17
|
-
validates :user, uniqueness: { scope: :
|
17
|
+
validates :user, uniqueness: { scope: :component }
|
18
18
|
validate :user_belongs_to_organization
|
19
19
|
|
20
20
|
validates :total_budget, numericality: {
|
@@ -45,25 +45,25 @@ module Decidim
|
|
45
45
|
|
46
46
|
# Public: Returns the order budget percent from the settings total budget
|
47
47
|
def budget_percent
|
48
|
-
(total_budget.to_f /
|
48
|
+
(total_budget.to_f / component.settings.total_budget.to_f) * 100
|
49
49
|
end
|
50
50
|
|
51
51
|
# Public: Returns the required minimum budget to checkout
|
52
52
|
def minimum_budget
|
53
|
-
return 0 unless
|
54
|
-
|
53
|
+
return 0 unless component
|
54
|
+
component.settings.total_budget.to_f * (component.settings.vote_threshold_percent.to_f / 100)
|
55
55
|
end
|
56
56
|
|
57
57
|
# Public: Returns the required maximum budget to checkout
|
58
58
|
def maximum_budget
|
59
|
-
return 0 unless
|
60
|
-
|
59
|
+
return 0 unless component
|
60
|
+
component.settings.total_budget.to_f
|
61
61
|
end
|
62
62
|
|
63
63
|
private
|
64
64
|
|
65
65
|
def user_belongs_to_organization
|
66
|
-
organization =
|
66
|
+
organization = component&.organization
|
67
67
|
|
68
68
|
return if !user || !organization
|
69
69
|
errors.add(:user, :invalid) unless user.organization == organization
|
@@ -6,27 +6,33 @@ module Decidim
|
|
6
6
|
# title, description and any other useful information to render a custom project.
|
7
7
|
class Project < Budgets::ApplicationRecord
|
8
8
|
include Decidim::Resourceable
|
9
|
-
include Decidim::
|
10
|
-
include Decidim::
|
9
|
+
include Decidim::HasComponent
|
10
|
+
include Decidim::ScopableComponent
|
11
11
|
include Decidim::HasCategory
|
12
12
|
include Decidim::HasAttachments
|
13
13
|
include Decidim::HasAttachmentCollections
|
14
14
|
include Decidim::HasReference
|
15
15
|
include Decidim::Followable
|
16
16
|
include Decidim::Comments::Commentable
|
17
|
+
include Decidim::Traceable
|
18
|
+
include Decidim::Loggable
|
17
19
|
|
18
|
-
|
20
|
+
component_manifest_name "budgets"
|
19
21
|
has_many :line_items, class_name: "Decidim::Budgets::LineItem", foreign_key: "decidim_project_id", dependent: :destroy
|
20
22
|
has_many :orders, through: :line_items, foreign_key: "decidim_project_id", class_name: "Decidim::Budgets::Order"
|
21
23
|
|
24
|
+
def self.log_presenter_class_for(_log)
|
25
|
+
Decidim::Budgets::AdminLog::ProjectPresenter
|
26
|
+
end
|
27
|
+
|
22
28
|
# Public: Overrides the `commentable?` Commentable concern method.
|
23
29
|
def commentable?
|
24
|
-
|
30
|
+
component.settings.comments_enabled?
|
25
31
|
end
|
26
32
|
|
27
33
|
# Public: Overrides the `accepts_new_comments?` Commentable concern method.
|
28
34
|
def accepts_new_comments?
|
29
|
-
commentable? && !
|
35
|
+
commentable? && !component.current_settings.comments_blocked
|
30
36
|
end
|
31
37
|
|
32
38
|
# Public: Overrides the `comments_have_votes?` Commentable concern method.
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Budgets
|
5
|
+
module AdminLog
|
6
|
+
# This class holds the logic to present a `Decidim::Budgets::Project``
|
7
|
+
# for the `AdminLog` log.
|
8
|
+
#
|
9
|
+
# Usage should be automatic and you shouldn't need to call this class
|
10
|
+
# directly, but here's an example:
|
11
|
+
#
|
12
|
+
# action_log = Decidim::ActionLog.last
|
13
|
+
# view_helpers # => this comes from the views
|
14
|
+
# ProjectPresenter.new(action_log, view_helpers).present
|
15
|
+
class ProjectPresenter < Decidim::Log::BasePresenter
|
16
|
+
private
|
17
|
+
|
18
|
+
def action_string
|
19
|
+
case action
|
20
|
+
when "create", "delete", "update"
|
21
|
+
"decidim.budgets.admin_log.project.#{action}"
|
22
|
+
else
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def diff_fields_mapping
|
28
|
+
{
|
29
|
+
budget: :currency,
|
30
|
+
description: :i18n,
|
31
|
+
title: :i18n,
|
32
|
+
decidim_scope_id: :scope
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def i18n_labels_scope
|
37
|
+
"activemodel.attributes.project"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -2,32 +2,32 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Budgets
|
5
|
-
# A class used to find projects filtered by
|
5
|
+
# A class used to find projects filtered by components and a date range
|
6
6
|
class FilteredProjects < Rectify::Query
|
7
7
|
# Syntactic sugar to initialize the class and return the queried objects.
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# components - An array of Decidim::Component
|
10
10
|
# start_at - A date to filter resources created after it
|
11
11
|
# end_at - A date to filter resources created before it.
|
12
|
-
def self.for(
|
13
|
-
new(
|
12
|
+
def self.for(components, start_at = nil, end_at = nil)
|
13
|
+
new(components, start_at, end_at).query
|
14
14
|
end
|
15
15
|
|
16
16
|
# Initializes the class.
|
17
17
|
#
|
18
|
-
#
|
18
|
+
# components - An array of Decidim::Component
|
19
19
|
# start_at - A date to filter resources created after it
|
20
20
|
# end_at - A date to filter resources created before it.
|
21
|
-
def initialize(
|
22
|
-
@
|
21
|
+
def initialize(components, start_at = nil, end_at = nil)
|
22
|
+
@components = components
|
23
23
|
@start_at = start_at
|
24
24
|
@end_at = end_at
|
25
25
|
end
|
26
26
|
|
27
|
-
# Finds the Projects scoped to an array of
|
27
|
+
# Finds the Projects scoped to an array of components and filtered
|
28
28
|
# by a range of dates.
|
29
29
|
def query
|
30
|
-
projects = Decidim::Budgets::Project.where(
|
30
|
+
projects = Decidim::Budgets::Project.where(component: @components)
|
31
31
|
projects = projects.where("created_at >= ?", @start_at) if @start_at.present?
|
32
32
|
projects = projects.where("created_at <= ?", @end_at) if @end_at.present?
|
33
33
|
projects
|
@@ -3,11 +3,11 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Budgets
|
5
5
|
# This class handles search and filtering of projects. Needs a
|
6
|
-
# `
|
6
|
+
# `current_component` param with a `Decidim::Component` in order to
|
7
7
|
# find the projects.
|
8
8
|
class ProjectSearch < ResourceSearch
|
9
9
|
# Public: Initializes the service.
|
10
|
-
#
|
10
|
+
# component - A Decidim::Component to get the projects from.
|
11
11
|
def initialize(options = {})
|
12
12
|
super(Project.all, options)
|
13
13
|
@random_seed = options[:random_seed].to_f
|
@@ -4,25 +4,25 @@
|
|
4
4
|
</div>
|
5
5
|
|
6
6
|
<div class="card-section">
|
7
|
-
<div class="row column"
|
7
|
+
<div class="row column">
|
8
8
|
<%= form.translated :text_field, :title, autofocus: true %>
|
9
9
|
</div>
|
10
10
|
|
11
|
-
<div class="row column"
|
11
|
+
<div class="row column">
|
12
12
|
<%= form.translated :editor, :description %>
|
13
13
|
</div>
|
14
14
|
|
15
|
-
<div class="row column"
|
15
|
+
<div class="row column">
|
16
16
|
<%= form.number_field :budget %>
|
17
17
|
</div>
|
18
18
|
|
19
19
|
<% if current_participatory_space.has_subscopes? %>
|
20
|
-
<div class="row column"
|
20
|
+
<div class="row column">
|
21
21
|
<%= scopes_picker_field form, :decidim_scope_id %>
|
22
22
|
</div>
|
23
23
|
<% end %>
|
24
24
|
|
25
|
-
<div class="row column"
|
25
|
+
<div class="row column">
|
26
26
|
<%= form.categories_select :decidim_category_id, current_participatory_space.categories, include_blank: true, disable_parents: false %>
|
27
27
|
</div>
|
28
28
|
|
@@ -31,8 +31,7 @@
|
|
31
31
|
<%= form.select :proposal_ids,
|
32
32
|
@form.proposals,
|
33
33
|
{},
|
34
|
-
{ multiple: true, class: "chosen-select" }
|
35
|
-
%>
|
34
|
+
{ multiple: true, class: "chosen-select" } %>
|
36
35
|
<% end %>
|
37
36
|
</div>
|
38
37
|
</div>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%=
|
2
|
-
<%= render partial:
|
1
|
+
<%= decidim_form_for(@form, html: { class: "form edit_project" }) do |f| %>
|
2
|
+
<%= render partial: "form", object: f, locals: { title: t(".title") } %>
|
3
3
|
|
4
4
|
<div class="button--double form-general-submit">
|
5
5
|
<%= f.submit t(".update") %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<div class="card-divider">
|
3
3
|
<h2 class="card-title">
|
4
4
|
<%= t(".title") %>
|
5
|
-
<%= link_to t("actions.new", scope: "decidim.budgets", name: t("models.project.name", scope: "decidim.budgets.admin")), new_project_path, class:
|
5
|
+
<%= link_to t("actions.new", scope: "decidim.budgets", name: t("models.project.name", scope: "decidim.budgets.admin")), new_project_path, class: "button tiny button--title" if can? :manage, current_component %>
|
6
6
|
</h2>
|
7
7
|
</div>
|
8
8
|
|
@@ -28,19 +28,19 @@
|
|
28
28
|
<td class="table-list__actions">
|
29
29
|
<%= icon_link_to "eye", resource_locator(project).path, t("actions.preview", scope: "decidim.budgets"), target: :blank, class: "action-icon--preview" %>
|
30
30
|
|
31
|
-
<% if can? :update,
|
31
|
+
<% if can? :update, current_component %>
|
32
32
|
<%= icon_link_to "pencil", edit_project_path(project), t("actions.edit", scope: "decidim.budgets"), class: "action-icon--edit" %>
|
33
33
|
<% end %>
|
34
34
|
|
35
|
-
<% if can? :update,
|
35
|
+
<% if can? :update, current_component %>
|
36
36
|
<%= icon_link_to "folder", project_attachment_collections_path(project), t("actions.attachment_collections", scope: "decidim.budgets"), class: "action-icon--attachment_collections" %>
|
37
37
|
<% end %>
|
38
38
|
|
39
|
-
<% if can? :update,
|
39
|
+
<% if can? :update, current_component %>
|
40
40
|
<%= icon_link_to "paperclip", project_attachments_path(project), t("actions.attachments", scope: "decidim.budgets"), class: "action-icon--attachments" %>
|
41
41
|
<% end %>
|
42
42
|
|
43
|
-
<% if can? :destroy,
|
43
|
+
<% if can? :destroy, current_component %>
|
44
44
|
<%= icon_link_to "circle-x", project_path(project), t("actions.destroy", scope: "decidim.budgets"), method: :delete, class: "action-icon--remove", data: { confirm: t("actions.confirm_destroy", scope: "decidim.budgets") } %>
|
45
45
|
<% end %>
|
46
46
|
</td>
|
@@ -1,8 +1,7 @@
|
|
1
|
-
<%=
|
2
|
-
<%= render partial:
|
1
|
+
<%= decidim_form_for(@form, html: { class: "form new_project" }) do |f| %>
|
2
|
+
<%= render partial: "form", object: f, locals: { title: t(".title") } %>
|
3
3
|
|
4
4
|
<div class="button--double form-general-submit">
|
5
5
|
<%= f.submit t(".create") %>
|
6
6
|
</div>
|
7
7
|
<% end %>
|
8
|
-
|