decidim-proposals 0.25.0 → 0.26.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/proposals/collaborative_draft_m_cell.rb +1 -1
  3. data/app/cells/decidim/proposals/cost_report_cell.rb +3 -3
  4. data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +1 -1
  5. data/app/cells/decidim/proposals/proposal_m_cell.rb +4 -5
  6. data/app/cells/decidim/proposals/proposals_picker_cell.rb +7 -5
  7. data/app/commands/decidim/proposals/update_proposal.rb +3 -2
  8. data/app/controllers/concerns/decidim/proposals/orderable.rb +21 -8
  9. data/app/controllers/decidim/proposals/admin/proposals_merges_controller.rb +4 -1
  10. data/app/controllers/decidim/proposals/admin/proposals_splits_controller.rb +4 -1
  11. data/app/controllers/decidim/proposals/proposals_controller.rb +6 -3
  12. data/app/events/decidim/proposals/proposal_mentioned_event.rb +8 -0
  13. data/app/events/decidim/proposals/publish_proposal_event.rb +26 -0
  14. data/app/forms/decidim/proposals/admin/proposals_file_import_form.rb +31 -0
  15. data/app/forms/decidim/proposals/admin/proposals_fork_form.rb +8 -3
  16. data/app/helpers/decidim/proposals/application_helper.rb +1 -6
  17. data/app/helpers/decidim/proposals/map_helper.rb +1 -1
  18. data/app/helpers/decidim/proposals/proposals_helper.rb +1 -1
  19. data/app/models/decidim/proposals/proposal.rb +4 -3
  20. data/app/packs/src/decidim/proposals/add_proposal.js +8 -2
  21. data/app/packs/src/decidim/proposals/admin/proposals_picker.js +15 -0
  22. data/app/presenters/decidim/proposals/proposal_presenter.rb +2 -48
  23. data/app/queries/decidim/proposals/similar_proposals.rb +1 -1
  24. data/app/services/decidim/proposals/proposal_search.rb +9 -4
  25. data/app/views/decidim/proposals/admin/imports/_proposals_fields.html.erb +11 -0
  26. data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +7 -2
  27. data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +1 -1
  28. data/app/views/decidim/proposals/collaborative_drafts/_filters_small_view.html.erb +3 -3
  29. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +2 -2
  30. data/app/views/decidim/proposals/proposals/_filters.html.erb +2 -0
  31. data/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +3 -3
  32. data/app/views/decidim/proposals/proposals/_proposals.html.erb +18 -0
  33. data/app/views/decidim/proposals/proposals/index.html.erb +0 -5
  34. data/app/views/decidim/proposals/proposals/participatory_texts/_index.html.erb +2 -2
  35. data/config/brakeman.ignore +88 -0
  36. data/config/locales/ar.yml +0 -5
  37. data/config/locales/bg.yml +0 -2
  38. data/config/locales/ca.yml +58 -7
  39. data/config/locales/cs.yml +60 -5
  40. data/config/locales/de.yml +0 -5
  41. data/config/locales/el.yml +0 -5
  42. data/config/locales/en.yml +57 -6
  43. data/config/locales/es-MX.yml +56 -5
  44. data/config/locales/es-PY.yml +56 -5
  45. data/config/locales/es.yml +56 -5
  46. data/config/locales/eu.yml +41 -6
  47. data/config/locales/fi-plain.yml +56 -5
  48. data/config/locales/fi.yml +56 -5
  49. data/config/locales/fr-CA.yml +56 -5
  50. data/config/locales/fr.yml +59 -8
  51. data/config/locales/gl.yml +55 -6
  52. data/config/locales/hu.yml +0 -5
  53. data/config/locales/id-ID.yml +0 -4
  54. data/config/locales/is-IS.yml +0 -2
  55. data/config/locales/it.yml +13 -5
  56. data/config/locales/ja.yml +79 -30
  57. data/config/locales/lv.yml +0 -5
  58. data/config/locales/nl.yml +57 -5
  59. data/config/locales/no.yml +0 -5
  60. data/config/locales/pl.yml +7 -12
  61. data/config/locales/pt-BR.yml +1 -6
  62. data/config/locales/pt.yml +37 -5
  63. data/config/locales/ro-RO.yml +467 -382
  64. data/config/locales/ru.yml +0 -2
  65. data/config/locales/sk.yml +0 -5
  66. data/config/locales/sr-CS.yml +0 -1
  67. data/config/locales/sv.yml +54 -5
  68. data/config/locales/tr-TR.yml +0 -5
  69. data/config/locales/uk.yml +0 -2
  70. data/config/locales/val-ES.yml +1 -0
  71. data/config/locales/zh-CN.yml +0 -5
  72. data/lib/decidim/proposals/component.rb +37 -4
  73. data/lib/decidim/proposals/engine.rb +4 -0
  74. data/lib/decidim/proposals/import/proposal_answer_creator.rb +95 -0
  75. data/lib/decidim/proposals/import/proposal_creator.rb +124 -0
  76. data/lib/decidim/proposals/import/proposals_answers_verifier.rb +29 -0
  77. data/lib/decidim/proposals/import/proposals_verifier.rb +16 -0
  78. data/lib/decidim/proposals/import.rb +12 -0
  79. data/lib/decidim/proposals/proposal_serializer.rb +6 -3
  80. data/lib/decidim/proposals/test/factories.rb +1 -9
  81. data/lib/decidim/proposals/version.rb +1 -1
  82. data/lib/decidim/proposals.rb +1 -1
  83. metadata +35 -27
  84. data/lib/decidim/proposals/proposal_creator.rb +0 -98
@@ -33,17 +33,20 @@ module Decidim
33
33
  component: { id: component.id },
34
34
  title: proposal.title,
35
35
  body: proposal.body,
36
+ address: proposal.address,
37
+ latitude: proposal.latitude,
38
+ longitude: proposal.longitude,
36
39
  state: proposal.state.to_s,
37
40
  reference: proposal.reference,
38
41
  answer: ensure_translatable(proposal.answer),
39
42
  supports: proposal.proposal_votes_count,
40
43
  endorsements: {
41
- total_count: proposal.endorsements.count,
44
+ total_count: proposal.endorsements.size,
42
45
  user_endorsements: user_endorsements
43
46
  },
44
47
  comments: proposal.comments_count,
45
- attachments: proposal.attachments.count,
46
- followers: proposal.followers.count,
48
+ attachments: proposal.attachments.size,
49
+ followers: proposal.follows.size,
47
50
  published_at: proposal.published_at,
48
51
  url: url,
49
52
  meeting_urls: meetings,
@@ -214,14 +214,6 @@ FactoryBot.define do
214
214
  end
215
215
  end
216
216
 
217
- trait :with_card_image_allowed do
218
- settings do
219
- {
220
- allow_card_image: true
221
- }
222
- end
223
- end
224
-
225
217
  trait :with_extra_hashtags do
226
218
  transient do
227
219
  automatic_hashtags { "AutoHashtag AnotherAutoHashtag" }
@@ -297,7 +289,7 @@ FactoryBot.define do
297
289
  proposal.body = Decidim::ContentProcessor.parse_with_processor(:hashtag, proposal.body, current_organization: proposal.organization).rewrite
298
290
 
299
291
  if proposal.component
300
- users = evaluator.users || [create(:user, organization: proposal.component.participatory_space.organization)]
292
+ users = evaluator.users || [create(:user, :confirmed, organization: proposal.component.participatory_space.organization)]
301
293
  users.each_with_index do |user, idx|
302
294
  user_group = evaluator.user_groups[idx]
303
295
  proposal.coauthorships.build(author: user, user_group: user_group)
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds decidim-proposals version.
5
5
  module Proposals
6
6
  def self.version
7
- "0.25.0"
7
+ "0.26.0.rc2"
8
8
  end
9
9
  end
10
10
  end
@@ -4,6 +4,7 @@ require "decidim/proposals/admin"
4
4
  require "decidim/proposals/api"
5
5
  require "decidim/proposals/engine"
6
6
  require "decidim/proposals/admin_engine"
7
+ require "decidim/proposals/import"
7
8
  require "decidim/proposals/component"
8
9
 
9
10
  module Decidim
@@ -11,7 +12,6 @@ module Decidim
11
12
  # allows users to create proposals in a participatory process.
12
13
  module Proposals
13
14
  autoload :ProposalSerializer, "decidim/proposals/proposal_serializer"
14
- autoload :ProposalCreator, "decidim/proposals/proposal_creator"
15
15
  autoload :CommentableProposal, "decidim/proposals/commentable_proposal"
16
16
  autoload :CommentableCollaborativeDraft, "decidim/proposals/commentable_collaborative_draft"
17
17
  autoload :MarkdownToProposals, "decidim/proposals/markdown_to_proposals"
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-proposals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.26.0.rc2
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: 2021-10-07 00:00:00.000000000 Z
13
+ date: 2022-02-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-comments
@@ -18,42 +18,42 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.25.0
21
+ version: 0.26.0.rc2
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.25.0
28
+ version: 0.26.0.rc2
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.25.0
35
+ version: 0.26.0.rc2
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.25.0
42
+ version: 0.26.0.rc2
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: doc2text
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 0.4.3
49
+ version: 0.4.4
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 0.4.3
56
+ version: 0.4.4
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: redcarpet
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -80,84 +80,84 @@ dependencies:
80
80
  requirements:
81
81
  - - '='
82
82
  - !ruby/object:Gem::Version
83
- version: 0.25.0
83
+ version: 0.26.0.rc2
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.25.0
90
+ version: 0.26.0.rc2
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: decidim-assemblies
93
93
  requirement: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - '='
96
96
  - !ruby/object:Gem::Version
97
- version: 0.25.0
97
+ version: 0.26.0.rc2
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.25.0
104
+ version: 0.26.0.rc2
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: decidim-budgets
107
107
  requirement: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - '='
110
110
  - !ruby/object:Gem::Version
111
- version: 0.25.0
111
+ version: 0.26.0.rc2
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.25.0
118
+ version: 0.26.0.rc2
119
119
  - !ruby/object:Gem::Dependency
120
120
  name: decidim-dev
121
121
  requirement: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - '='
124
124
  - !ruby/object:Gem::Version
125
- version: 0.25.0
125
+ version: 0.26.0.rc2
126
126
  type: :development
127
127
  prerelease: false
128
128
  version_requirements: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - '='
131
131
  - !ruby/object:Gem::Version
132
- version: 0.25.0
132
+ version: 0.26.0.rc2
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: decidim-meetings
135
135
  requirement: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - '='
138
138
  - !ruby/object:Gem::Version
139
- version: 0.25.0
139
+ version: 0.26.0.rc2
140
140
  type: :development
141
141
  prerelease: false
142
142
  version_requirements: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - '='
145
145
  - !ruby/object:Gem::Version
146
- version: 0.25.0
146
+ version: 0.26.0.rc2
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: decidim-participatory_processes
149
149
  requirement: !ruby/object:Gem::Requirement
150
150
  requirements:
151
151
  - - '='
152
152
  - !ruby/object:Gem::Version
153
- version: 0.25.0
153
+ version: 0.26.0.rc2
154
154
  type: :development
155
155
  prerelease: false
156
156
  version_requirements: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - '='
159
159
  - !ruby/object:Gem::Version
160
- version: 0.25.0
160
+ version: 0.26.0.rc2
161
161
  description: A proposals component for decidim's participatory spaces.
162
162
  email:
163
163
  - josepjaume@gmail.com
@@ -289,6 +289,7 @@ files:
289
289
  - app/forms/decidim/proposals/admin/proposal_base_form.rb
290
290
  - app/forms/decidim/proposals/admin/proposal_form.rb
291
291
  - app/forms/decidim/proposals/admin/proposal_note_form.rb
292
+ - app/forms/decidim/proposals/admin/proposals_file_import_form.rb
292
293
  - app/forms/decidim/proposals/admin/proposals_fork_form.rb
293
294
  - app/forms/decidim/proposals/admin/proposals_import_form.rb
294
295
  - app/forms/decidim/proposals/admin/proposals_merge_form.rb
@@ -365,6 +366,7 @@ files:
365
366
  - app/services/decidim/proposals/proposal_builder.rb
366
367
  - app/services/decidim/proposals/proposal_search.rb
367
368
  - app/validators/proposal_length_validator.rb
369
+ - app/views/decidim/proposals/admin/imports/_proposals_fields.html.erb
368
370
  - app/views/decidim/proposals/admin/participatory_texts/_article-preview.html.erb
369
371
  - app/views/decidim/proposals/admin/participatory_texts/_bulk-actions.html.erb
370
372
  - app/views/decidim/proposals/admin/participatory_texts/index.html.erb
@@ -444,6 +446,7 @@ files:
444
446
  - app/views/decidim/proposals/versions/index.html.erb
445
447
  - app/views/decidim/proposals/versions/show.html.erb
446
448
  - config/assets.rb
449
+ - config/brakeman.ignore
447
450
  - config/locales/am-ET.yml
448
451
  - config/locales/ar-SA.yml
449
452
  - config/locales/ar.yml
@@ -510,6 +513,7 @@ files:
510
513
  - config/locales/ti-ER.yml
511
514
  - config/locales/tr-TR.yml
512
515
  - config/locales/uk.yml
516
+ - config/locales/val-ES.yml
513
517
  - config/locales/vi-VN.yml
514
518
  - config/locales/vi.yml
515
519
  - config/locales/zh-CN.yml
@@ -584,10 +588,14 @@ files:
584
588
  - lib/decidim/proposals/component.rb
585
589
  - lib/decidim/proposals/doc_to_markdown.rb
586
590
  - lib/decidim/proposals/engine.rb
591
+ - lib/decidim/proposals/import.rb
592
+ - lib/decidim/proposals/import/proposal_answer_creator.rb
593
+ - lib/decidim/proposals/import/proposal_creator.rb
594
+ - lib/decidim/proposals/import/proposals_answers_verifier.rb
595
+ - lib/decidim/proposals/import/proposals_verifier.rb
587
596
  - lib/decidim/proposals/markdown_to_proposals.rb
588
597
  - lib/decidim/proposals/odt_to_markdown.rb
589
598
  - lib/decidim/proposals/participatory_text_section.rb
590
- - lib/decidim/proposals/proposal_creator.rb
591
599
  - lib/decidim/proposals/proposal_serializer.rb
592
600
  - lib/decidim/proposals/test/capybara_proposals_picker.rb
593
601
  - lib/decidim/proposals/test/factories.rb
@@ -597,7 +605,7 @@ homepage: https://github.com/decidim/decidim
597
605
  licenses:
598
606
  - AGPL-3.0
599
607
  metadata: {}
600
- post_install_message:
608
+ post_install_message:
601
609
  rdoc_options: []
602
610
  require_paths:
603
611
  - lib
@@ -608,12 +616,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
608
616
  version: '2.7'
609
617
  required_rubygems_version: !ruby/object:Gem::Requirement
610
618
  requirements:
611
- - - ">="
619
+ - - ">"
612
620
  - !ruby/object:Gem::Version
613
- version: '0'
621
+ version: 1.3.1
614
622
  requirements: []
615
- rubygems_version: 3.1.2
616
- signing_key:
623
+ rubygems_version: 3.1.6
624
+ signing_key:
617
625
  specification_version: 4
618
626
  summary: Decidim proposals module
619
627
  test_files: []
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Proposals
5
- # This class is responsible for creating the imported proposals
6
- # and must be included in proposals component's import manifest.
7
- class ProposalCreator < Decidim::Admin::Import::Creator
8
- # Retuns the resource class to be created with the provided data.
9
- def self.resource_klass
10
- Decidim::Proposals::Proposal
11
- end
12
-
13
- # Produces a proposal from parsed data
14
- #
15
- # Returns a proposal
16
- def produce
17
- resource.add_coauthor(context[:current_user], user_group: context[:user_group])
18
-
19
- resource
20
- end
21
-
22
- # Saves the proposal
23
- def finish!
24
- super # resource.save!
25
- notify(resource)
26
- publish(resource)
27
- end
28
-
29
- private
30
-
31
- attr_reader :context
32
-
33
- def resource
34
- @resource ||= Decidim::Proposals::Proposal.new(
35
- category: category,
36
- scope: scope,
37
- title: title,
38
- body: body,
39
- component: component,
40
- published_at: Time.current
41
- )
42
- end
43
-
44
- def category
45
- id = data.has_key?(:category) ? data[:category]["id"] : data[:"category/id"].to_i
46
- Decidim::Category.find_by(id: id)
47
- end
48
-
49
- def scope
50
- id = data.has_key?(:scope) ? data[:scope]["id"] : data[:"scope/id"].to_i
51
- Decidim::Scope.find_by(id: id)
52
- end
53
-
54
- def title
55
- locale_hasher("title", available_locales)
56
- end
57
-
58
- def body
59
- locale_hasher("body", available_locales)
60
- end
61
-
62
- def available_locales
63
- @available_locales ||= component.participatory_space.organization.available_locales
64
- end
65
-
66
- def component
67
- context[:current_component]
68
- end
69
-
70
- def notify(proposal)
71
- return if proposal.coauthorships.empty?
72
-
73
- Decidim::EventsManager.publish(
74
- event: "decidim.events.proposals.proposal_published",
75
- event_class: Decidim::Proposals::PublishProposalEvent,
76
- resource: proposal,
77
- followers: coauthors_followers(proposal)
78
- )
79
- end
80
-
81
- def publish(proposal)
82
- Decidim::EventsManager.publish(
83
- event: "decidim.events.proposals.proposal_published",
84
- event_class: Decidim::Proposals::PublishProposalEvent,
85
- resource: proposal,
86
- followers: proposal.participatory_space.followers - coauthors_followers(proposal),
87
- extra: {
88
- participatory_space: true
89
- }
90
- )
91
- end
92
-
93
- def coauthors_followers(proposal)
94
- @coauthors_followers ||= proposal.authors.flat_map(&:followers)
95
- end
96
- end
97
- end
98
- end