decidim-budgets 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +23 -0
  3. data/Rakefile +2 -0
  4. data/app/assets/config/decidim_budgets_manifest.js +1 -0
  5. data/app/assets/images/decidim/budgets/icon.svg +4 -0
  6. data/app/assets/javascripts/decidim/budgets/projects.js.es6 +28 -0
  7. data/app/assets/stylesheets/decidim/budgets/_budgets.scss +1 -0
  8. data/app/assets/stylesheets/decidim/budgets/budget/_budget-list.scss +32 -0
  9. data/app/assets/stylesheets/decidim/budgets/budget/_budget-meter.scss +78 -0
  10. data/app/assets/stylesheets/decidim/budgets/budget/_progress.scss +17 -0
  11. data/app/commands/decidim/budgets/add_line_item.rb +43 -0
  12. data/app/commands/decidim/budgets/admin/create_project.rb +52 -0
  13. data/app/commands/decidim/budgets/admin/update_project.rb +56 -0
  14. data/app/commands/decidim/budgets/cancel_order.rb +36 -0
  15. data/app/commands/decidim/budgets/checkout.rb +34 -0
  16. data/app/commands/decidim/budgets/remove_line_item.rb +35 -0
  17. data/app/controllers/concerns/decidim/budgets/needs_current_order.rb +27 -0
  18. data/app/controllers/decidim/budgets/admin/application_controller.rb +14 -0
  19. data/app/controllers/decidim/budgets/admin/projects_controller.rb +69 -0
  20. data/app/controllers/decidim/budgets/application_controller.rb +13 -0
  21. data/app/controllers/decidim/budgets/line_items_controller.rb +43 -0
  22. data/app/controllers/decidim/budgets/orders_controller.rb +38 -0
  23. data/app/controllers/decidim/budgets/projects_controller.rb +44 -0
  24. data/app/forms/decidim/budgets/admin/project_form.rb +44 -0
  25. data/app/helpers/decidim/budgets/application_helper.rb +12 -0
  26. data/app/helpers/decidim/budgets/projects_helper.rb +29 -0
  27. data/app/models/decidim/budgets/application_record.rb +9 -0
  28. data/app/models/decidim/budgets/line_item.rb +20 -0
  29. data/app/models/decidim/budgets/order.rb +52 -0
  30. data/app/models/decidim/budgets/project.rb +15 -0
  31. data/app/services/decidim/budgets/project_search.rb +58 -0
  32. data/app/views/decidim/budgets/admin/projects/_form.html.erb +31 -0
  33. data/app/views/decidim/budgets/admin/projects/edit.html.erb +9 -0
  34. data/app/views/decidim/budgets/admin/projects/index.html.erb +27 -0
  35. data/app/views/decidim/budgets/admin/projects/new.html.erb +9 -0
  36. data/app/views/decidim/budgets/line_items/update_budget.js.erb +21 -0
  37. data/app/views/decidim/budgets/projects/_budget_confirm.html.erb +30 -0
  38. data/app/views/decidim/budgets/projects/_budget_excess.html.erb +14 -0
  39. data/app/views/decidim/budgets/projects/_budget_summary.html.erb +46 -0
  40. data/app/views/decidim/budgets/projects/_count.html.erb +1 -0
  41. data/app/views/decidim/budgets/projects/_filters.html.erb +24 -0
  42. data/app/views/decidim/budgets/projects/_linked_projects.html.erb +12 -0
  43. data/app/views/decidim/budgets/projects/_order_progress.html.erb +34 -0
  44. data/app/views/decidim/budgets/projects/_order_selected_projects.html.erb +25 -0
  45. data/app/views/decidim/budgets/projects/_order_total_budget.html.erb +1 -0
  46. data/app/views/decidim/budgets/projects/_project.html.erb +40 -0
  47. data/app/views/decidim/budgets/projects/_project_budget_button.html.erb +9 -0
  48. data/app/views/decidim/budgets/projects/_projects.html.erb +8 -0
  49. data/app/views/decidim/budgets/projects/_tags.html.erb +10 -0
  50. data/app/views/decidim/budgets/projects/index.html.erb +26 -0
  51. data/app/views/decidim/budgets/projects/index.js.erb +2 -0
  52. data/app/views/decidim/budgets/projects/show.html.erb +48 -0
  53. data/config/i18n-tasks.yml +4 -0
  54. data/config/locales/ca.yml +84 -0
  55. data/config/locales/en.yml +95 -0
  56. data/config/locales/es.yml +84 -0
  57. data/db/migrate/20170127114122_create_projects.rb +15 -0
  58. data/db/migrate/20170130095615_create_orders.rb +13 -0
  59. data/db/migrate/20170130101825_create_line_items.rb +10 -0
  60. data/lib/decidim/budgets/admin.rb +9 -0
  61. data/lib/decidim/budgets/admin_engine.rb +22 -0
  62. data/lib/decidim/budgets/feature.rb +59 -0
  63. data/lib/decidim/budgets/list_engine.rb +30 -0
  64. data/lib/decidim/budgets/test/factories.rb +43 -0
  65. data/lib/decidim/budgets.rb +11 -0
  66. metadata +210 -0
@@ -0,0 +1,8 @@
1
+ <div class="card card--list budget-list">
2
+ <% projects.each do |project| %>
3
+ <div id="project-<%= project.id %>-item" class="card--list__item">
4
+ <%= render partial: 'project', locals: { project: project } %>
5
+ </div>
6
+ <% end %>
7
+ </div>
8
+ <%= decidim_paginate projects, random_seed: random_seed %>
@@ -0,0 +1,10 @@
1
+ <% if project.category.present? || project.scope.present? %>
2
+ <ul class="tags tags--project" >
3
+ <% if project.category.present? %>
4
+ <li><%= link_to translated_attribute(project.category.name), decidim_budgets.projects_path(filter: { category_id: project.category.id }) %></li>
5
+ <% end %>
6
+ <% if project.scope.present? %>
7
+ <li><%= link_to project.scope.name, decidim_budgets.projects_path(filter: { scope_id: [project.scope.id] }) %></li>
8
+ <% end %>
9
+ </ul>
10
+ <% end %>
@@ -0,0 +1,26 @@
1
+ <% content_for(:title, t(".title")) %>
2
+
3
+ <% if current_user.present? %>
4
+ <div class="row column">
5
+ <%= render partial: "budget_summary", locals: { include_heading: true } %>
6
+ </div>
7
+ <% end %>
8
+ <div class="row columns">
9
+ <h2 class="section-heading">
10
+ <%= render partial: "count" %>
11
+ </h2>
12
+ </div>
13
+ <div class="row">
14
+ <div class="columns mediumlarge-4 large-3">
15
+ <div class="card card--secondary show-for-mediumlarge" >
16
+ <%= render partial: "filters" %>
17
+ </div>
18
+ </div>
19
+ <div id="projects" class="columns mediumlarge-8 large-9">
20
+ <%= render partial: "projects" %>
21
+ </div>
22
+ </div>
23
+
24
+ <%= javascript_include_tag("decidim/filters") %>
25
+ <%= javascript_include_tag("decidim/budgets/projects") %>
26
+ <%= render partial: "decidim/shared/login_modal" %>
@@ -0,0 +1,2 @@
1
+ var $projects = $('#projects');
2
+ $projects.html('<%= j(render partial: "projects") %>');
@@ -0,0 +1,48 @@
1
+ <% content_for(:title, translated_attribute(project.title)) %>
2
+
3
+ <div class="row column view-header">
4
+ <% if current_user.present? %>
5
+ <%= render partial: "budget_summary", locals: { include_heading: false } %>
6
+ <% end %>
7
+ <%= link_to projects_path, class: "muted-link" do %>
8
+ <%= icon "chevron-left", class: "icon--small" %>
9
+ <%= t('.view_all_projects') %>
10
+ <% end %>
11
+ <h2 class="heading2"><%= translated_attribute project.title %></h2>
12
+ </div>
13
+ <div class="row">
14
+ <div id="project" class="columns section view-side mediumlarge-4 mediumlarge-push-8
15
+ large-3 large-push-9">
16
+ <div class="card extra">
17
+ <div class="card__content">
18
+ <div class="m-bottom">
19
+ <span class="definition-data__title"><%= t('.budget') %></span>
20
+ <span class="definition-data__number"><%= budget_to_currency project.budget %></span>
21
+ </div>
22
+ <div id="project-<%= project.id %>-budget-button">
23
+ <%= render partial: 'project_budget_button', locals: { project: project } %>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ <div class="columns mediumlarge-8 mediumlarge-pull-4">
29
+ <div class="section">
30
+ <%== translated_attribute project.short_description %>
31
+ <%= render partial: "tags", locals: { project: project } %>
32
+ </div>
33
+ <div class="section">
34
+ <h3 class="section-heading"><%= t(".project_description") %></h3>
35
+ <%== translated_attribute project.description %>
36
+ </div>
37
+ <%= linked_resources_for project, :proposals, "included_proposals" %>
38
+ </div>
39
+ </div>
40
+
41
+ <%= content_for :expanded do %>
42
+ <% if feature_settings.comments_always_enabled || current_settings.comments_enabled %>
43
+ <%= comments_for project, votable: true %>
44
+ <% end %>
45
+ <% end %>
46
+
47
+ <%= javascript_include_tag("decidim/budgets/projects") %>
48
+ <%= render partial: "decidim/shared/login_modal" %>
@@ -0,0 +1,4 @@
1
+ base_locale: en
2
+ locales: [en]
3
+ ignore_unused:
4
+ - "decidim.features.budgets.name"
@@ -0,0 +1,84 @@
1
+ ca:
2
+ decidim:
3
+ budgets:
4
+ actions:
5
+ confirm_destroy: Estàs segur que vols eliminar aquest projecte?
6
+ destroy: Esborrar
7
+ edit: Editar
8
+ new: Nou %{name}
9
+ title: Accions
10
+ admin:
11
+ models:
12
+ project:
13
+ name: Projecte
14
+ projects:
15
+ create:
16
+ invalid: Hi ha hagut un problema creant aquest projecte
17
+ success: Projecte creat correctament
18
+ edit:
19
+ title: Editar projecte
20
+ update: Actualitzar projecte
21
+ index:
22
+ title: Projectes
23
+ new:
24
+ create: Crear projecte
25
+ title: Nou resultat
26
+ update:
27
+ invalid: Hi ha hagut un problema actualitzant aquest projecte
28
+ success: Projecte actualitzat correctament
29
+ models:
30
+ project:
31
+ fields:
32
+ title: Títol
33
+ projects:
34
+ budget_confirm:
35
+ are_you_sure: Estàs d'acord? Un cop hagis confirmat el teu vot, no podràs canviar-lo.
36
+ cancel: Cancel·lar
37
+ confirm: Confirmar
38
+ description: Aquests són els projectes que has seleccionat per formar part del pressupost.
39
+ title: Confirmar vot
40
+ budget_excess:
41
+ close: Tancar
42
+ description: Aquest projecte sobrepassa el pressupost màxim i no es pot afegir. Si ho desitges, pots eliminar un projecte ja seleccionat per afegir aquest o votart amb les seves preferències.
43
+ ok: D'acord
44
+ title: Pressupost superat
45
+ budget_summary:
46
+ assigned: 'Assignat:'
47
+ cancel_order: eliminar el teu vot i començar de nou
48
+ checked_out:
49
+ description: Ja has votat pel pressupost. Si ha canviat d'idea, pots %{cancel_link}.
50
+ title: Vot pels pressupostos completat
51
+ description: "En quins projectes creus que hem de destinar el pressupost? Has d'assignar com a mínim %{minimum_budget} als projectes que desitges i votar amb les teves preferències per definir el pressupost."
52
+ title: Tu decideixes el pressupost
53
+ count:
54
+ projects_count:
55
+ one: 1 projecte
56
+ other: "%{count} projectes"
57
+ filters:
58
+ category: Categoria
59
+ scopes: Àmbits
60
+ search: Cerca
61
+ index:
62
+ title: Títol
63
+ order_progress:
64
+ vote: Votar
65
+ order_selected_projects:
66
+ remove: Esborrar
67
+ selected_projects:
68
+ one: projecte seleccionat
69
+ other: projectes seleccionats
70
+ view: Veure
71
+ project:
72
+ add: Afegir
73
+ remove: Esborrar
74
+ project_budget_button:
75
+ add: Afegir
76
+ added: Afegit
77
+ show:
78
+ budget: Pressupost
79
+ project_description: Descripció del projecte
80
+ view_all_projects: Veure tots els projectes
81
+ features:
82
+ budgets:
83
+ name: Pressupostos
84
+ total_budget: Pressupost total
@@ -0,0 +1,95 @@
1
+ ---
2
+ en:
3
+ decidim:
4
+ budgets:
5
+ actions:
6
+ confirm_destroy: Are you sure you want to delete this project?
7
+ destroy: Delete
8
+ edit: Edit
9
+ new: New %{name}
10
+ title: Actions
11
+ admin:
12
+ models:
13
+ project:
14
+ name: Project
15
+ projects:
16
+ create:
17
+ invalid: There's been a problem creating this project
18
+ success: Project successfully created
19
+ destroy:
20
+ success: Project successfully destroyed
21
+ edit:
22
+ title: Edit project
23
+ update: Update project
24
+ index:
25
+ title: Projects
26
+ new:
27
+ create: Create project
28
+ title: New result
29
+ update:
30
+ invalid: There's been a problem updating this project
31
+ success: Project successfully updated
32
+ models:
33
+ project:
34
+ fields:
35
+ title: Title
36
+ projects:
37
+ budget_confirm:
38
+ are_you_sure: Do you agree? Once you have confirmed your vote, you can not change it.
39
+ cancel: Cancel
40
+ confirm: Confirm
41
+ description: These are the projects you have chosen to be part of the budget.
42
+ title: Confirm vote
43
+ budget_excess:
44
+ close: Close
45
+ description: This project exceeds the maximum budget and can not be added. If you want, you can delete a project you have already selected to add, or make your vote with your preferences.
46
+ ok: OK
47
+ title: Maximum budget exceeded
48
+ budget_summary:
49
+ are_you_sure: Are you sure you want to cancel your vote?
50
+ assigned: 'Assigned:'
51
+ cancel_order: delete your vote and start over
52
+ checked_out:
53
+ description: You've already voted for the budget. If you've changed your mind, you can %{cancel_link}.
54
+ title: Budget vote completed
55
+ description: "What projects do you think we should allocate budget for? Assign at least %{minimum_budget} to the projects you want and vote with your preferences to define the budget."
56
+ title: You decide the budget
57
+ count:
58
+ projects_count:
59
+ one: 1 project
60
+ other: "%{count} projects"
61
+ filters:
62
+ category: Category
63
+ scopes: Scopes
64
+ search: Search
65
+ index:
66
+ title: Title
67
+ order_progress:
68
+ vote: Vote
69
+ order_selected_projects:
70
+ remove: Remove
71
+ selected_projects:
72
+ one: project selected
73
+ other: projects selected
74
+ view: View
75
+ project:
76
+ add: Add
77
+ remove: Remove
78
+ project_budget_button:
79
+ add: Add
80
+ added: Added
81
+ show:
82
+ budget: Budget
83
+ project_description: Project description
84
+ view_all_projects: View all projects
85
+ features:
86
+ budgets:
87
+ name: Budgets
88
+ orders:
89
+ checkout:
90
+ error: An error ocurred while processing your vote
91
+ success: Your vote has been accepted successfully
92
+ destroy:
93
+ error: An error ocurred while canceling your vote
94
+ success: Your vote has been canceled successfully
95
+ total_budget: Total budget
@@ -0,0 +1,84 @@
1
+ es:
2
+ decidim:
3
+ budgets:
4
+ actions:
5
+ confirm_destroy: '¿Estás seguro de que deseas eliminar este proyecto?'
6
+ destroy: Borrar
7
+ edit: Editar
8
+ new: Nuevo %{name}
9
+ title: Acciones
10
+ admin:
11
+ models:
12
+ project:
13
+ name: Proyecto
14
+ projects:
15
+ create:
16
+ invalid: Ha habido un problema al crear este proyecto
17
+ success: Proyecto creado con éxito
18
+ edit:
19
+ title: Editar proyecto
20
+ update: Actualizar proyecto
21
+ index:
22
+ title: Proyectos
23
+ new:
24
+ create: Crear proyecto
25
+ title: Nuevo resultado
26
+ update:
27
+ invalid: Ha habido un problema al actualizar este proyecto
28
+ success: Proyecto actualizado correctamente
29
+ models:
30
+ project:
31
+ fields:
32
+ title: Título
33
+ projects:
34
+ budget_confirm:
35
+ are_you_sure: '¿Estás de acuerdo? Una vez que hayas confirmado tu voto, no puedes cambiarlo.'
36
+ cancel: Cancelar
37
+ confirm: Confirmar
38
+ description: Estos son los proyectos que has elegido para formar parte del presupuesto.
39
+ title: Confirmar voto
40
+ budget_excess:
41
+ close: Cerrar
42
+ description: Este proyecto sobrepasa el presupuesto máximo y no se puede añadir. Si lo deseas, puede eliminar un proyecto que ya hayas seleccionado o votar con tus preferencias.
43
+ ok: De acuerdo
44
+ title: Presupuesto excedido
45
+ budget_summary:
46
+ assigned: 'Asignado:'
47
+ cancel_order: eliminar tu voto y empezar de nuevo
48
+ checked_out:
49
+ description: Ya has votado para el presupuesto. Si has cambiado de idea, puedes %{cancel_link}.
50
+ title: Voto enviado correctamente
51
+ description: "¿Qué proyectos crees que deberíamos asignar el presupuesto? Asigna por lo menos %{minimum_budget} a los proyectos que desees y vota para definir el presupuesto."
52
+ title: Tú decides el presupuesto
53
+ count:
54
+ projects_count:
55
+ one: 1 proyecto
56
+ other: "%{count} proyectos"
57
+ filters:
58
+ category: Categoría
59
+ scopes: Ámbitos
60
+ search: Buscar
61
+ index:
62
+ title: Título
63
+ order_progress:
64
+ vote: Votar
65
+ order_selected_projects:
66
+ remove: Eliminar
67
+ selected_projects:
68
+ one: proyecto seleccionado
69
+ other: proyectos seleccionados
70
+ view: Ver
71
+ project:
72
+ add: Añadir
73
+ remove: Eliminar
74
+ project_budget_button:
75
+ add: Añadir
76
+ added: Añadido
77
+ show:
78
+ budget: Presupuesto
79
+ project_description: Descripción del proyecto
80
+ view_all_projects: Ver todos los proyectos
81
+ features:
82
+ budgets:
83
+ name: Presupuestos
84
+ total_budget: Presupuesto total
@@ -0,0 +1,15 @@
1
+ class CreateProjects < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :decidim_budgets_projects do |t|
4
+ t.jsonb :title
5
+ t.jsonb :description
6
+ t.jsonb :short_description
7
+ t.integer :budget, null: false
8
+ t.references :decidim_feature, index: true
9
+ t.references :decidim_scope, index: true
10
+ t.references :decidim_category, index: true
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ class CreateOrders < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :decidim_budgets_orders do |t|
4
+ t.references :decidim_user, index: true
5
+ t.references :decidim_feature, index: true
6
+ t.datetime :checked_out_at
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :decidim_budgets_orders, [:decidim_user_id, :decidim_feature_id], unique: true, name: "decidim_budgets_order_user_feature_unique"
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ class CreateLineItems < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :decidim_budgets_line_items do |t|
4
+ t.references :decidim_order, index: true
5
+ t.references :decidim_project, index: true
6
+ end
7
+
8
+ add_index :decidim_budgets_line_items, [:decidim_order_id, :decidim_project_id], unique: true, name: "decidim_budgets_line_items_order_project_unique"
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Budgets
4
+ # This module contains all the domain logic associated to Decidim's Budgets
5
+ # component admin panel.
6
+ module Admin
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Budgets
4
+ # This is the engine that runs on the public interface of `decidim-budgets`.
5
+ # It mostly handles rendering the created projects associated to a participatory
6
+ # process.
7
+ class AdminEngine < ::Rails::Engine
8
+ isolate_namespace Decidim::Budgets::Admin
9
+
10
+ paths["db/migrate"] = nil
11
+
12
+ routes do
13
+ resources :projects
14
+ root to: "projects#index"
15
+ end
16
+
17
+ def load_seed
18
+ nil
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "decidim/features/namer"
4
+
5
+ Decidim.register_feature(:budgets) do |feature|
6
+ feature.engine = Decidim::Budgets::ListEngine
7
+ feature.admin_engine = Decidim::Budgets::AdminEngine
8
+ feature.icon = "decidim/budgets/icon.svg"
9
+ feature.stylesheet = "decidim/budgets/budgets"
10
+
11
+ feature.on(:before_destroy) do |instance|
12
+ raise StandardError, "Can't remove this feature" if Decidim::Budgets::Project.where(feature: instance).any?
13
+ end
14
+
15
+ feature.register_resource do |resource|
16
+ resource.model_class_name = "Decidim::Budgets::Project"
17
+ resource.template = "decidim/budgets/projects/linked_projects"
18
+ end
19
+
20
+ feature.settings(:global) do |settings|
21
+ settings.attribute :total_budget, type: :integer, default: 100_000_000
22
+ settings.attribute :vote_threshold_percent, type: :integer, default: 70
23
+ settings.attribute :comments_always_enabled, type: :boolean, default: true
24
+ end
25
+
26
+ feature.settings(:step) do |settings|
27
+ settings.attribute :comments_enabled, type: :boolean, default: true
28
+ end
29
+
30
+ feature.seeds do
31
+ Decidim::ParticipatoryProcess.all.each do |process|
32
+ next unless process.steps.any?
33
+
34
+ feature = Decidim::Feature.create!(
35
+ name: Decidim::Features::Namer.new(process.organization.available_locales, :budgets).i18n_name,
36
+ manifest_name: :budgets,
37
+ participatory_process: process
38
+ )
39
+
40
+ 3.times do
41
+ project = Decidim::Budgets::Project.create!(
42
+ feature: feature,
43
+ scope: process.organization.scopes.sample,
44
+ category: process.categories.sample,
45
+ title: Decidim::Faker::Localized.sentence(2),
46
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
47
+ Decidim::Faker::Localized.paragraph(3)
48
+ end,
49
+ short_description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
50
+ Decidim::Faker::Localized.paragraph(3)
51
+ end,
52
+ budget: Faker::Number.number(8)
53
+ )
54
+
55
+ Decidim::Comments::Seed.comments_for(project)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ require "searchlight"
3
+ require "kaminari"
4
+
5
+ module Decidim
6
+ module Budgets
7
+ # This is the engine that runs on the public interface of `decidim-budgets`.
8
+ # It mostly handles rendering the created projects associated to a participatory
9
+ # process.
10
+ class ListEngine < ::Rails::Engine
11
+ isolate_namespace Decidim::Budgets
12
+
13
+ routes do
14
+ resources :projects, only: [:index, :show]
15
+ resource :order, only: [:destroy] do
16
+ member do
17
+ post :checkout
18
+ end
19
+ resource :line_item, only: [:create, :destroy]
20
+ end
21
+
22
+ root to: "projects#index"
23
+ end
24
+
25
+ initializer "decidim_budgets.assets" do |app|
26
+ app.config.assets.precompile += %w(decidim_budgets_manifest.js)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ require "decidim/faker/localized"
3
+ require "decidim/dev"
4
+
5
+ FactoryGirl.define do
6
+ factory :budget_feature, class: Decidim::Feature do
7
+ name { Decidim::Features::Namer.new(participatory_process.organization.available_locales, :budgets).i18n_name }
8
+ manifest_name :budgets
9
+ participatory_process
10
+
11
+ trait :with_total_budget_and_vote_threshold_percent do
12
+ transient do
13
+ total_budget 100_000_000
14
+ vote_threshold_percent 70
15
+ end
16
+
17
+ settings do
18
+ {
19
+ total_budget: total_budget,
20
+ vote_threshold_percent: vote_threshold_percent
21
+ }
22
+ end
23
+ end
24
+ end
25
+
26
+ factory :project, class: Decidim::Budgets::Project do
27
+ title { Decidim::Faker::Localized.sentence(3) }
28
+ description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { Decidim::Faker::Localized.sentence(4) } }
29
+ short_description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { Decidim::Faker::Localized.sentence(4) } }
30
+ budget { Faker::Number.number(8) }
31
+ feature { create(:budget_feature) }
32
+ end
33
+
34
+ factory :order, class: Decidim::Budgets::Order do
35
+ feature { create(:budget_feature) }
36
+ user { create(:user, organization: feature.organization) }
37
+ end
38
+
39
+ factory :line_item, class: Decidim::Budgets::LineItem do
40
+ order
41
+ project { create(:project, feature: order.feature) }
42
+ end
43
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+ require "decidim/budgets/admin"
3
+ require "decidim/budgets/list_engine"
4
+ require "decidim/budgets/admin_engine"
5
+ require "decidim/budgets/feature"
6
+
7
+ module Decidim
8
+ # Base module for this engine.
9
+ module Budgets
10
+ end
11
+ end