decidim-budgets 0.9.3 → 0.10.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90b4f968329a7f43876f3fdcbdf88806f342de5961a389dc4d8524e6b007a4c5
4
- data.tar.gz: 78482327631965ea3c5e91ca019aacf783775d2814aec6a985d3b048e40f8697
3
+ metadata.gz: 26b0f42475f4913d1bd2e6b08236aa7b13164d9930e2ba11a1223ce23db47f17
4
+ data.tar.gz: 99d67d115391105cfb7bf1d2c14c06afb530386dbbce84dfa048920ff5fd6c11
5
5
  SHA512:
6
- metadata.gz: 014affe9f34987375725e72a48ec3df49b889e45717afaac62111b857bf1cb82e0acd84bfb28ee5b01bf8330275e279236be6a18f3051541b0386f161bcf73d9
7
- data.tar.gz: 1be54f8432b0d7a4efc80e45c428ea6601aa5c1ecb954dd61d97039ba4f4de5f61b4d581aa7f7744c4caeebedd77c6810a4c40adda69bbd44fe82b1a646938b9
6
+ metadata.gz: 63e5247cb648cc220aca7725588e0b3e1441b2813b3baae6d470f8ce2bacf875718c54874847177a9f80b304a143189de8d893e52e1217d17de4f1d989858830
7
+ data.tar.gz: 79e7482532f355825685c77ca2244279c2eaba14b2930dd5ae601507595ab3ce55f8de52194c3c560c89bceb36a9dbc51dab94a3f37599dcc82317082d33098c
@@ -1,8 +1,8 @@
1
1
  $(() => {
2
2
  const checkProgressPosition = () => {
3
3
  let progressFix = document.querySelector("[data-progressbox-fixed]"),
4
- progressRef = document.querySelector("[data-progress-reference]"),
5
- progressVisibleClass = "is-progressbox-visible";
4
+ progressRef = document.querySelector("[data-progress-reference]"),
5
+ progressVisibleClass = "is-progressbox-visible";
6
6
 
7
7
  if (!progressRef) {
8
8
  return;
@@ -34,7 +34,7 @@ module Decidim
34
34
  attr_reader :project, :form
35
35
 
36
36
  def update_project
37
- project.update_attributes!(
37
+ project.update!(
38
38
  scope: form.scope,
39
39
  category: form.category,
40
40
  title: form.title,
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ module Admin
6
+ # Controller that allows managing all the attachment collections for a budget.
7
+ #
8
+ class AttachmentCollectionsController < Admin::ApplicationController
9
+ include Decidim::Admin::Concerns::HasAttachmentCollections
10
+
11
+ def after_destroy_path
12
+ project_attachment_collections_path(project, project.feature, current_participatory_space)
13
+ end
14
+
15
+ def collection_for
16
+ project
17
+ end
18
+
19
+ def project
20
+ @project ||= projects.find(params[:project_id])
21
+ end
22
+
23
+ def authorization_object
24
+ project.feature
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -22,7 +22,8 @@ module Decidim
22
22
 
23
23
  validates :category, presence: true, if: ->(form) { form.decidim_category_id.present? }
24
24
  validates :scope, presence: true, if: ->(form) { form.decidim_scope_id.present? }
25
- validate { errors.add(:decidim_scope_id, :invalid) if current_participatory_space&.scope && !current_participatory_space&.scope&.ancestor_of?(scope) }
25
+
26
+ validate :scope_belongs_to_participatory_space_scope
26
27
 
27
28
  delegate :categories, to: :current_feature
28
29
 
@@ -49,7 +50,7 @@ module Decidim
49
50
  #
50
51
  # Returns a Decidim::Scope
51
52
  def scope
52
- @scope ||= @decidim_scope_id ? current_feature.scopes.find_by(id: @decidim_scope_id) : current_participatory_space&.scope
53
+ @scope ||= @decidim_scope_id ? current_participatory_space.scopes.find_by(id: @decidim_scope_id) : current_participatory_space.scope
53
54
  end
54
55
 
55
56
  # Scope identifier
@@ -58,6 +59,12 @@ module Decidim
58
59
  def decidim_scope_id
59
60
  @decidim_scope_id || scope&.id
60
61
  end
62
+
63
+ private
64
+
65
+ def scope_belongs_to_participatory_space_scope
66
+ errors.add(:decidim_scope_id, :invalid) if current_participatory_space.out_of_scope?(scope)
67
+ end
61
68
  end
62
69
  end
63
70
  end
@@ -63,6 +63,8 @@ module Decidim
63
63
  private
64
64
 
65
65
  def user_belongs_to_organization
66
+ organization = feature&.organization
67
+
66
68
  return if !user || !organization
67
69
  errors.add(:user, :invalid) unless user.organization == organization
68
70
  end
@@ -7,9 +7,10 @@ module Decidim
7
7
  class Project < Budgets::ApplicationRecord
8
8
  include Decidim::Resourceable
9
9
  include Decidim::HasFeature
10
- include Decidim::HasScope
10
+ include Decidim::ScopableFeature
11
11
  include Decidim::HasCategory
12
12
  include Decidim::HasAttachments
13
+ include Decidim::HasAttachmentCollections
13
14
  include Decidim::HasReference
14
15
  include Decidim::Followable
15
16
  include Decidim::Comments::Commentable
@@ -22,7 +22,7 @@ module Decidim
22
22
 
23
23
  # Returns the random projects for the current page.
24
24
  def results
25
- @projects ||= Project.transaction do
25
+ @results ||= Project.transaction do
26
26
  Project.connection.execute("SELECT setseed(#{Project.connection.quote(random_seed)})")
27
27
  super.reorder("RANDOM()").load
28
28
  end
@@ -32,6 +32,10 @@
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, current_feature %>
36
+ <%= icon_link_to "folder", project_attachment_collections_path(project), t("actions.attachment_collections", scope: "decidim.budgets"), class: "action-icon--attachment_collections" %>
37
+ <% end %>
38
+
35
39
  <% if can? :update, current_feature %>
36
40
  <%= icon_link_to "paperclip", project_attachments_path(project), t("actions.attachments", scope: "decidim.budgets"), class: "action-icon--attachments" %>
37
41
  <% end %>
@@ -33,7 +33,7 @@
33
33
  <%= render partial: "decidim/shared/follow_button", locals: { followable: project } %>
34
34
  </div>
35
35
  </div>
36
- <%= feature_reference(project) %>
36
+ <%= resource_reference(project) %>
37
37
  </div>
38
38
  <div class="columns mediumlarge-8 mediumlarge-pull-4">
39
39
  <div class="section">
@@ -11,6 +11,7 @@ ca:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: Col·leccions
14
15
  attachments: Adjunts
15
16
  confirm_destroy: Segur que vols eliminar aquest projecte?
16
17
  destroy: Esborrar
@@ -12,6 +12,7 @@ en:
12
12
  decidim:
13
13
  budgets:
14
14
  actions:
15
+ attachment_collections: Collections
15
16
  attachments: Attachments
16
17
  confirm_destroy: Are you sure you want to delete this project?
17
18
  destroy: Delete
@@ -11,6 +11,7 @@ es:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: Colecciones
14
15
  attachments: Archivos adjuntos
15
16
  confirm_destroy: '¿Estás seguro de que deseas eliminar este proyecto?'
16
17
  destroy: Borrar
@@ -11,6 +11,7 @@ eu:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: Bilduma
14
15
  attachments: Fitxategi erantsiak
15
16
  confirm_destroy: Ziur zaude proiektu hau ezabatu nahi duzula?
16
17
  destroy: Ezabatu
@@ -11,6 +11,7 @@ fi:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: kokoelmat
14
15
  attachments: Liitteet
15
16
  confirm_destroy: Haluatko varmasti poistaa tämän projektin?
16
17
  destroy: Poista
@@ -11,6 +11,7 @@ fr:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: Collections
14
15
  attachments: Pièces jointes
15
16
  confirm_destroy: Êtes-vous certain de vouloir supprimer ce projet?
16
17
  destroy: Supprimer
@@ -11,6 +11,7 @@ gl:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: Coleccións
14
15
  attachments: Anexos
15
16
  confirm_destroy: Estás seguro de que queres eliminar este proxecto?
16
17
  destroy: Eliminar
@@ -11,6 +11,7 @@ it:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: collezioni
14
15
  attachments: Allegati
15
16
  confirm_destroy: Sei certo di voler cancellare questo progetto?
16
17
  destroy: Cancella
@@ -11,6 +11,7 @@ nl:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: collecties
14
15
  attachments: Bijlagen
15
16
  confirm_destroy: Weet u zeker dat u dit project wilt verwijderen?
16
17
  destroy: Verwijderen
@@ -11,6 +11,7 @@ pl:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: Kolekcje
14
15
  attachments: Załączniki
15
16
  confirm_destroy: Czy na pewno chcesz usunąć ten projekt?
16
17
  destroy: Kasować
@@ -66,11 +67,6 @@ pl:
66
67
  title: Ukończono budżet budżetowy
67
68
  description: Jakie projekty myślisz, powinniśmy przeznaczyć budżet? Przyznaj co najmniej %{minimum_budget} projekty, które chcesz i głosuj zgodnie z Twoimi preferencjami, aby określić budżet.
68
69
  title: Ty decydujesz budżet
69
- count:
70
- projects_count:
71
- one: 1 projekt
72
- few: "%{count} projektów"
73
- other: "%{count} projektów"
74
70
  filters:
75
71
  category: Kategoria
76
72
  category_prompt: Wybierz kategorię
@@ -84,17 +80,9 @@ pl:
84
80
  vote: Głosować
85
81
  order_selected_projects:
86
82
  remove: Usunąć
87
- selected_projects:
88
- one: Wybrany projekt
89
- few: Wybranych projektów
90
- other: Wybranych projektów
91
83
  view: Widok
92
84
  project:
93
85
  add: Dodaj
94
- count:
95
- one: 1
96
- few: "%{count} obsługuje"
97
- other: "%{count} obsługuje"
98
86
  remove: Usunąć
99
87
  project_budget_button:
100
88
  add: Dodaj
@@ -11,6 +11,7 @@ pt-BR:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: Coleções
14
15
  attachments: Anexos
15
16
  confirm_destroy: Tem certeza de que deseja excluir esse projeto?
16
17
  destroy: Excluir
@@ -11,6 +11,7 @@ pt:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: Coleções
14
15
  attachments: Anexos
15
16
  confirm_destroy: Tem certeza de que deseja excluir esse projeto?
16
17
  destroy: Excluir
@@ -11,6 +11,7 @@ sv:
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: samlingar
14
15
  attachments: bilagor
15
16
  confirm_destroy: Är du säker på att du vill radera detta projekt?
16
17
  destroy: Radera
@@ -7,10 +7,11 @@ uk:
7
7
  decidim_scope_id: Терен
8
8
  description: Опис
9
9
  proposal_ids: Супутні пропозиції
10
- title: Назва
10
+ title: Заголовок
11
11
  decidim:
12
12
  budgets:
13
13
  actions:
14
+ attachment_collections: Збірки
14
15
  attachments: Вкладені файли
15
16
  confirm_destroy: Ви дійсно бажаєте видалити цей проект?
16
17
  destroy: Видалити
@@ -44,7 +45,7 @@ uk:
44
45
  models:
45
46
  project:
46
47
  fields:
47
- title: Назва
48
+ title: Заголовок
48
49
  projects:
49
50
  budget_confirm:
50
51
  are_you_sure: Чи ви згодні? Підтвердивши свій голос, ви не зможете його потім змінити.
@@ -12,6 +12,7 @@ module Decidim
12
12
 
13
13
  routes do
14
14
  resources :projects do
15
+ resources :attachment_collections
15
16
  resources :attachments
16
17
  end
17
18
 
@@ -68,6 +68,20 @@ Decidim.register_feature(:budgets) do |feature|
68
68
  end,
69
69
  budget: Faker::Number.number(8)
70
70
  )
71
+
72
+ attachment_collection = Decidim::AttachmentCollection.create!(
73
+ name: Decidim::Faker::Localized.word,
74
+ description: Decidim::Faker::Localized.sentence(5),
75
+ collection_for: project
76
+ )
77
+
78
+ Decidim::Attachment.create!(
79
+ title: Decidim::Faker::Localized.sentence(2),
80
+ description: Decidim::Faker::Localized.sentence(5),
81
+ file: File.new(File.join(__dir__, "seeds", "Exampledocument.pdf")),
82
+ attachment_collection: attachment_collection,
83
+ attached_to: project
84
+ )
71
85
  Decidim::Attachment.create!(
72
86
  title: Decidim::Faker::Localized.sentence(2),
73
87
  description: Decidim::Faker::Localized.sentence(5),
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-budgets version.
5
5
  module Budgets
6
6
  def self.version
7
- "0.9.3"
7
+ "0.10.0"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-budgets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-02-27 00:00:00.000000000 Z
13
+ date: 2018-03-27 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.9.3
21
+ version: 0.10.0
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.9.3
28
+ version: 0.10.0
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.9.3
35
+ version: 0.10.0
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.9.3
42
+ version: 0.10.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: kaminari
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -74,42 +74,42 @@ dependencies:
74
74
  requirements:
75
75
  - - '='
76
76
  - !ruby/object:Gem::Version
77
- version: 0.9.3
77
+ version: 0.10.0
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - '='
83
83
  - !ruby/object:Gem::Version
84
- version: 0.9.3
84
+ version: 0.10.0
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: decidim-dev
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - '='
90
90
  - !ruby/object:Gem::Version
91
- version: 0.9.3
91
+ version: 0.10.0
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - '='
97
97
  - !ruby/object:Gem::Version
98
- version: 0.9.3
98
+ version: 0.10.0
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: decidim-proposals
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - '='
104
104
  - !ruby/object:Gem::Version
105
- version: 0.9.3
105
+ version: 0.10.0
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - '='
111
111
  - !ruby/object:Gem::Version
112
- version: 0.9.3
112
+ version: 0.10.0
113
113
  description: A budgets component for decidim's participatory spaces.
114
114
  email:
115
115
  - josepjaume@gmail.com
@@ -137,6 +137,7 @@ files:
137
137
  - app/commands/decidim/budgets/remove_line_item.rb
138
138
  - app/controllers/concerns/decidim/budgets/needs_current_order.rb
139
139
  - app/controllers/decidim/budgets/admin/application_controller.rb
140
+ - app/controllers/decidim/budgets/admin/attachment_collections_controller.rb
140
141
  - app/controllers/decidim/budgets/admin/attachments_controller.rb
141
142
  - app/controllers/decidim/budgets/admin/projects_controller.rb
142
143
  - app/controllers/decidim/budgets/application_controller.rb
@@ -224,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
225
  version: '0'
225
226
  requirements: []
226
227
  rubyforge_project:
227
- rubygems_version: 2.7.3
228
+ rubygems_version: 2.7.6
228
229
  signing_key:
229
230
  specification_version: 4
230
231
  summary: Decidim budgets module