decidim-proposals 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +6 -0
  3. data/app/assets/javascripts/decidim/proposals/admin/proposals_form.js.es6 +3 -0
  4. data/app/cells/decidim/proposals/collaborative_draft_cell.rb +1 -1
  5. data/app/cells/decidim/proposals/participatory_text_proposal/buttons.erb +2 -2
  6. data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +1 -1
  7. data/app/cells/decidim/proposals/proposal_cell.rb +1 -1
  8. data/app/cells/decidim/proposals/proposal_m_cell.rb +2 -2
  9. data/app/commands/decidim/proposals/admin/create_proposal.rb +4 -2
  10. data/app/commands/decidim/proposals/admin/publish_participatory_text.rb +6 -1
  11. data/app/commands/decidim/proposals/admin/update_participatory_text.rb +10 -2
  12. data/app/commands/decidim/proposals/admin/update_proposal.rb +4 -2
  13. data/app/commands/decidim/proposals/create_proposal.rb +6 -2
  14. data/app/commands/decidim/proposals/publish_collaborative_draft.rb +2 -2
  15. data/app/commands/decidim/proposals/update_proposal.rb +25 -9
  16. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +2 -2
  17. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +1 -10
  18. data/app/controllers/decidim/proposals/proposals_controller.rb +3 -17
  19. data/app/controllers/decidim/proposals/{proposal_widgets_controller.rb → widgets_controller.rb} +2 -2
  20. data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +3 -1
  21. data/app/forms/decidim/proposals/admin/participatory_text_proposal_form.rb +8 -1
  22. data/app/forms/decidim/proposals/admin/proposal_base_form.rb +20 -13
  23. data/app/forms/decidim/proposals/admin/proposal_form.rb +9 -2
  24. data/app/forms/decidim/proposals/proposal_form.rb +21 -12
  25. data/app/helpers/decidim/proposals/admin/proposals_helper.rb +2 -0
  26. data/app/helpers/decidim/proposals/application_helper.rb +13 -8
  27. data/app/helpers/decidim/proposals/proposals_helper.rb +1 -1
  28. data/app/models/decidim/proposals/collaborative_draft.rb +2 -2
  29. data/app/models/decidim/proposals/participatory_text.rb +3 -0
  30. data/app/models/decidim/proposals/proposal.rb +13 -40
  31. data/app/presenters/decidim/proposals/admin_log/value_types/proposal_title_body_presenter.rb +6 -1
  32. data/app/presenters/decidim/proposals/official_author_presenter.rb +1 -29
  33. data/app/presenters/decidim/proposals/proposal_presenter.rb +43 -6
  34. data/app/queries/decidim/proposals/similar_proposals.rb +4 -4
  35. data/app/services/decidim/proposals/collaborative_draft_search.rb +6 -16
  36. data/app/services/decidim/proposals/diff_renderer.rb +15 -5
  37. data/app/services/decidim/proposals/proposal_builder.rb +8 -2
  38. data/app/services/decidim/proposals/proposal_search.rb +7 -58
  39. data/app/types/decidim/proposals/proposal_type.rb +2 -2
  40. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +6 -6
  41. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +2 -11
  42. data/app/views/decidim/proposals/admin/proposals/index.html.erb +2 -2
  43. data/app/views/decidim/proposals/admin/proposals/show.html.erb +1 -1
  44. data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +5 -5
  45. data/app/views/decidim/proposals/collaborative_drafts/_filters.html.erb +1 -1
  46. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -1
  47. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +46 -18
  48. data/app/views/decidim/proposals/proposals/_filters.html.erb +1 -1
  49. data/app/views/decidim/proposals/proposals/index.html.erb +0 -2
  50. data/app/views/decidim/proposals/proposals/show.html.erb +3 -3
  51. data/config/locales/am-ET.yml +1 -0
  52. data/config/locales/bg.yml +237 -0
  53. data/config/locales/ca.yml +12 -4
  54. data/config/locales/cs.yml +9 -1
  55. data/config/locales/da.yml +1 -0
  56. data/config/locales/de.yml +3 -0
  57. data/config/locales/en.yml +8 -0
  58. data/config/locales/eo.yml +1 -0
  59. data/config/locales/es-MX.yml +8 -0
  60. data/config/locales/es-PY.yml +8 -0
  61. data/config/locales/es.yml +22 -14
  62. data/config/locales/et.yml +1 -0
  63. data/config/locales/eu.yml +0 -15
  64. data/config/locales/fi-plain.yml +8 -0
  65. data/config/locales/fi.yml +9 -1
  66. data/config/locales/fr-CA.yml +30 -0
  67. data/config/locales/fr.yml +36 -6
  68. data/config/locales/gl.yml +0 -15
  69. data/config/locales/hr.yml +1 -0
  70. data/config/locales/id-ID.yml +0 -15
  71. data/config/locales/is.yml +274 -0
  72. data/config/locales/it.yml +6 -0
  73. data/config/locales/ja-JP.yml +5 -26
  74. data/config/locales/ja.yml +889 -0
  75. data/config/locales/ko-KR.yml +1 -0
  76. data/config/locales/ko.yml +1 -0
  77. data/config/locales/lt.yml +1 -0
  78. data/config/locales/{lv-LV.yml → lv.yml} +0 -0
  79. data/config/locales/mt.yml +1 -0
  80. data/config/locales/nl.yml +9 -1
  81. data/config/locales/om-ET.yml +1 -0
  82. data/config/locales/pl.yml +377 -374
  83. data/config/locales/pt-BR.yml +0 -15
  84. data/config/locales/pt.yml +1 -0
  85. data/config/locales/ro-RO.yml +1 -0
  86. data/config/locales/so-SO.yml +1 -0
  87. data/config/locales/sv.yml +49 -26
  88. data/config/locales/ti-ER.yml +1 -0
  89. data/config/locales/tr-TR.yml +0 -15
  90. data/config/locales/vi-VN.yml +1 -0
  91. data/config/locales/vi.yml +1 -0
  92. data/config/locales/zh-CN.yml +885 -0
  93. data/config/locales/zh-TW.yml +1 -0
  94. data/db/migrate/20200120215928_move_proposal_endorsements_to_core_endorsements.rb +2 -0
  95. data/db/migrate/20200120230130_drop_proposal_endorsements.rb +8 -0
  96. data/db/migrate/20200708091228_move_proposals_fields_to_i18n.rb +80 -0
  97. data/db/migrate/20200827154156_add_commentable_counter_cache_to_proposals.rb +12 -0
  98. data/db/migrate/20200915151348_fix_proposals_data_to_ensure_title_and_body_are_hashes.rb +37 -0
  99. data/db/migrate/20201002085508_fix_proposals_data.rb +37 -0
  100. data/lib/decidim/content_renderers/proposal_renderer.rb +3 -1
  101. data/lib/decidim/proposals/component.rb +9 -6
  102. data/lib/decidim/proposals/engine.rb +1 -1
  103. data/lib/decidim/proposals/markdown_to_proposals.rb +2 -2
  104. data/lib/decidim/proposals/proposal_serializer.rb +3 -3
  105. data/lib/decidim/proposals/test/capybara_proposals_picker.rb +2 -2
  106. data/lib/decidim/proposals/test/factories.rb +44 -18
  107. data/lib/decidim/proposals/version.rb +1 -1
  108. metadata +46 -22
@@ -0,0 +1 @@
1
+ zh-TW:
@@ -5,9 +5,11 @@ class MoveProposalEndorsementsToCoreEndorsements < ActiveRecord::Migration[5.2]
5
5
  class ProposalEndorsement < ApplicationRecord
6
6
  self.table_name = :decidim_proposals_proposal_endorsements
7
7
  end
8
+
8
9
  class Endorsement < ApplicationRecord
9
10
  self.table_name = :decidim_endorsements
10
11
  end
12
+
11
13
  # Move ProposalEndorsements to Endorsements
12
14
  def up
13
15
  non_duplicated_group_endorsements = ProposalEndorsement.select(
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DropProposalEndorsements < ActiveRecord::Migration[5.2]
4
+ def change
5
+ drop_table :decidim_proposals_proposal_endorsements, if_exists: true, force: :restrict
6
+ remove_column :decidim_proposals_proposals, :proposal_endorsements_count
7
+ end
8
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ class MoveProposalsFieldsToI18n < ActiveRecord::Migration[5.2]
4
+ def up
5
+ add_column :decidim_proposals_proposals, :new_title, :jsonb
6
+ add_column :decidim_proposals_proposals, :new_body, :jsonb
7
+
8
+ reset_column_information
9
+
10
+ PaperTrail.request(enabled: false) do
11
+ Decidim::Proposals::Proposal.find_each do |proposal|
12
+ author = proposal.coauthorships.first.author
13
+
14
+ locale = author.try(:locale).presence || author.try(:default_locale).presence || author.try(:organization).try(:default_locale).presence
15
+
16
+ proposal.new_title = {
17
+ locale => proposal.title
18
+ }
19
+ proposal.new_body = {
20
+ locale => proposal.body
21
+ }
22
+
23
+ proposal.save!
24
+ end
25
+ end
26
+
27
+ remove_indexs
28
+
29
+ remove_column :decidim_proposals_proposals, :title
30
+ rename_column :decidim_proposals_proposals, :new_title, :title
31
+ remove_column :decidim_proposals_proposals, :body
32
+ rename_column :decidim_proposals_proposals, :new_body, :body
33
+
34
+ create_indexs
35
+
36
+ reset_column_information
37
+ end
38
+
39
+ def down
40
+ add_column :decidim_proposals_proposals, :new_title, :string
41
+ add_column :decidim_proposals_proposals, :new_body, :string
42
+
43
+ reset_column_information
44
+
45
+ Decidim::Proposals::Proposal.find_each do |proposal|
46
+ proposal.new_title = proposal.title.values.first
47
+ proposal.new_body = proposal.body.values.first
48
+
49
+ proposal.save!
50
+ end
51
+
52
+ remove_indexs
53
+
54
+ remove_column :decidim_proposals_proposals, :title
55
+ rename_column :decidim_proposals_proposals, :new_title, :title
56
+ remove_column :decidim_proposals_proposals, :body
57
+ rename_column :decidim_proposals_proposals, :new_body, :body
58
+
59
+ create_indexs
60
+
61
+ reset_column_information
62
+ end
63
+
64
+ def reset_column_information
65
+ Decidim::User.reset_column_information
66
+ Decidim::Coauthorship.reset_column_information
67
+ Decidim::Proposals::Proposal.reset_column_information
68
+ Decidim::Organization.reset_column_information
69
+ end
70
+
71
+ def remove_indexs
72
+ remove_index :decidim_proposals_proposals, name: "decidim_proposals_proposal_title_search"
73
+ remove_index :decidim_proposals_proposals, name: "decidim_proposals_proposal_body_search"
74
+ end
75
+
76
+ def create_indexs
77
+ execute "CREATE INDEX decidim_proposals_proposal_title_search ON decidim_proposals_proposals(md5(title::text))"
78
+ execute "CREATE INDEX decidim_proposals_proposal_body_search ON decidim_proposals_proposals(md5(body::text))"
79
+ end
80
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddCommentableCounterCacheToProposals < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :decidim_proposals_proposals, :comments_count, :integer, null: false, default: 0, index: true
6
+ add_column :decidim_proposals_collaborative_drafts, :comments_count, :integer, null: false, default: 0, index: true
7
+ Decidim::Proposals::Proposal.reset_column_information
8
+ Decidim::Proposals::Proposal.find_each(&:update_comments_count)
9
+ Decidim::Proposals::CollaborativeDraft.reset_column_information
10
+ Decidim::Proposals::CollaborativeDraft.find_each(&:update_comments_count)
11
+ end
12
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FixProposalsDataToEnsureTitleAndBodyAreHashes < ActiveRecord::Migration[5.2]
4
+ def up
5
+ reset_column_information
6
+
7
+ PaperTrail.request(enabled: false) do
8
+ Decidim::Proposals::Proposal.find_each do |proposal|
9
+ next if proposal.title.is_a?(Hash) && proposal.body.is_a?(Hash)
10
+
11
+ author = proposal.coauthorships.first.author
12
+
13
+ locale = author.try(:locale).presence || author.try(:default_locale).presence || author.try(:organization).try(:default_locale).presence
14
+
15
+ proposal.title = {
16
+ locale => proposal.title
17
+ }
18
+ proposal.body = {
19
+ locale => proposal.body
20
+ }
21
+
22
+ proposal.save!
23
+ end
24
+ end
25
+
26
+ reset_column_information
27
+ end
28
+
29
+ def down; end
30
+
31
+ def reset_column_information
32
+ Decidim::User.reset_column_information
33
+ Decidim::Coauthorship.reset_column_information
34
+ Decidim::Proposals::Proposal.reset_column_information
35
+ Decidim::Organization.reset_column_information
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FixProposalsData < ActiveRecord::Migration[5.2]
4
+ def up
5
+ reset_column_information
6
+
7
+ PaperTrail.request(enabled: false) do
8
+ Decidim::Proposals::Proposal.find_each do |proposal|
9
+ next if proposal.title.is_a?(Hash) && proposal.body.is_a?(Hash)
10
+
11
+ author = proposal.coauthorships.first.author
12
+
13
+ locale = author.try(:locale).presence || author.try(:default_locale).presence || author.try(:organization).try(:default_locale).presence
14
+
15
+ proposal.title = {
16
+ locale => proposal.title
17
+ }
18
+ proposal.body = {
19
+ locale => proposal.body
20
+ }
21
+
22
+ proposal.save!
23
+ end
24
+ end
25
+
26
+ reset_column_information
27
+ end
28
+
29
+ def down; end
30
+
31
+ def reset_column_information
32
+ Decidim::User.reset_column_information
33
+ Decidim::Coauthorship.reset_column_information
34
+ Decidim::Proposals::Proposal.reset_column_information
35
+ Decidim::Organization.reset_column_information
36
+ end
37
+ end
@@ -17,7 +17,9 @@ module Decidim
17
17
  # invalid Decidim::Proposals::Proposal are replaced with '???' string.
18
18
  #
19
19
  # @return [String] the content ready to display (contains HTML)
20
- def render
20
+ def render(_options = nil)
21
+ return content unless content.respond_to?(:gsub)
22
+
21
23
  content.gsub(GLOBAL_ID_REGEX) do |proposal_gid|
22
24
  proposal = GlobalID::Locator.locate(proposal_gid)
23
25
  Decidim::Proposals::ProposalPresenter.new(proposal).display_mention
@@ -22,6 +22,8 @@ Decidim.register_component(:proposals) do |component|
22
22
  component.permissions_class_name = "Decidim::Proposals::Permissions"
23
23
 
24
24
  component.settings(:global) do |settings|
25
+ settings.attribute :scopes_enabled, type: :boolean, default: false
26
+ settings.attribute :scope_id, type: :scope
25
27
  settings.attribute :vote_limit, type: :integer, default: 0
26
28
  settings.attribute :minimum_votes_per_user, type: :integer, default: 0
27
29
  settings.attribute :proposal_limit, type: :integer, default: 0
@@ -32,6 +34,7 @@ Decidim.register_component(:proposals) do |component|
32
34
  settings.attribute :proposal_answering_enabled, type: :boolean, default: true
33
35
  settings.attribute :official_proposals_enabled, type: :boolean, default: true
34
36
  settings.attribute :comments_enabled, type: :boolean, default: true
37
+ settings.attribute :comments_max_length, type: :integer, required: false
35
38
  settings.attribute :geocoding_enabled, type: :boolean, default: false
36
39
  settings.attribute :attachments_allowed, type: :boolean, default: false
37
40
  settings.attribute :allow_card_image, type: :boolean, default: false
@@ -43,7 +46,7 @@ Decidim.register_component(:proposals) do |component|
43
46
  settings.attribute :amendments_enabled, type: :boolean, default: false
44
47
  settings.attribute :amendments_wizard_help_text, type: :text, translated: true, editor: true, required: false
45
48
  settings.attribute :announcement, type: :text, translated: true, editor: true
46
- settings.attribute :new_proposal_body_template, type: :text, translated: true, editor: false, required: false
49
+ settings.attribute :new_proposal_body_template, type: :text, translated: true, editor: true, required: false
47
50
  settings.attribute :new_proposal_help_text, type: :text, translated: true, editor: true
48
51
  settings.attribute :proposal_wizard_step_1_help_text, type: :text, translated: true, editor: true
49
52
  settings.attribute :proposal_wizard_step_2_help_text, type: :text, translated: true, editor: true
@@ -106,7 +109,7 @@ Decidim.register_component(:proposals) do |component|
106
109
 
107
110
  component.register_stat :comments_count, tag: :comments do |components, start_at, end_at|
108
111
  proposals = Decidim::Proposals::FilteredProposals.for(components, start_at, end_at).published.not_hidden
109
- Decidim::Comments::Comment.where(root_commentable: proposals).count
112
+ proposals.sum(:comments_count)
110
113
  end
111
114
 
112
115
  component.register_stat :followers_count, tag: :followers, priority: Decidim::StatsRegistry::LOW_PRIORITY do |components, start_at, end_at|
@@ -203,8 +206,8 @@ Decidim.register_component(:proposals) do |component|
203
206
  component: component,
204
207
  category: participatory_space.categories.sample,
205
208
  scope: Faker::Boolean.boolean(0.5) ? global : scopes.sample,
206
- title: Faker::Lorem.sentence(2),
207
- body: Faker::Lorem.paragraphs(2).join("\n"),
209
+ title: { en: Faker::Lorem.sentence(2) },
210
+ body: { en: Faker::Lorem.paragraphs(2).join("\n") },
208
211
  state: state,
209
212
  answer: answer,
210
213
  answered_at: state.present? ? Time.current : nil,
@@ -269,8 +272,8 @@ Decidim.register_component(:proposals) do |component|
269
272
  component: component,
270
273
  category: participatory_space.categories.sample,
271
274
  scope: Faker::Boolean.boolean(0.5) ? global : scopes.sample,
272
- title: "#{proposal.title} #{Faker::Lorem.sentence(1)}",
273
- body: "#{proposal.body} #{Faker::Lorem.sentence(3)}",
275
+ title: { en: "#{proposal.title["en"]} #{Faker::Lorem.sentence(1)}" },
276
+ body: { en: "#{proposal.body["en"]} #{Faker::Lorem.sentence(3)}" },
274
277
  state: "evaluating",
275
278
  answer: nil,
276
279
  answered_at: Time.current,
@@ -28,7 +28,7 @@ module Decidim
28
28
  put :withdraw
29
29
  end
30
30
  resource :proposal_vote, only: [:create, :destroy]
31
- resource :proposal_widget, only: :show, path: "embed"
31
+ resource :widget, only: :show, path: "embed"
32
32
  resources :versions, only: [:show, :index]
33
33
  end
34
34
  resources :collaborative_drafts, except: [:destroy] do
@@ -131,8 +131,8 @@ module Decidim
131
131
  def create_proposal(title, body, participatory_text_level)
132
132
  attributes = {
133
133
  component: @component,
134
- title: title,
135
- body: body,
134
+ title: { I18n.locale => title },
135
+ body: { I18n.locale => body },
136
136
  participatory_text_level: participatory_text_level
137
137
  }
138
138
 
@@ -31,8 +31,8 @@ module Decidim
31
31
  url: Decidim::ResourceLocatorPresenter.new(proposal.participatory_space).url
32
32
  },
33
33
  component: { id: component.id },
34
- title: present(proposal).title,
35
- body: present(proposal).body,
34
+ title: proposal.title,
35
+ body: proposal.body,
36
36
  state: proposal.state.to_s,
37
37
  reference: proposal.reference,
38
38
  answer: ensure_translatable(proposal.answer),
@@ -41,7 +41,7 @@ module Decidim
41
41
  total_count: proposal.endorsements.count,
42
42
  user_endorsements: user_endorsements
43
43
  },
44
- comments: proposal.comments.count,
44
+ comments: proposal.comments_count,
45
45
  attachments: proposal.attachments.count,
46
46
  followers: proposal.followers.count,
47
47
  published_at: proposal.published_at,
@@ -12,7 +12,7 @@ module Capybara
12
12
 
13
13
  expected.each do |proposal|
14
14
  expect(data_picker).to have_selector(".picker-values div input[value='#{proposal.id}']", visible: :all)
15
- expect(data_picker).to have_selector(:xpath, "//div[contains(@class,'picker-values')]/div/a[text()[contains(.,\"#{proposal.title}\")]]")
15
+ expect(data_picker).to have_selector(:xpath, "//div[contains(@class,'picker-values')]/div/a[text()[contains(.,\"#{translated(proposal.title)}\")]]")
16
16
  end
17
17
  end
18
18
  end
@@ -23,7 +23,7 @@ module Capybara
23
23
 
24
24
  expected.each do |proposal|
25
25
  expect(data_picker).not_to have_selector(".picker-values div input[value='#{proposal.id}']", visible: :all)
26
- expect(data_picker).not_to have_selector(:xpath, "//div[contains(@class,'picker-values')]/div/a[text()[contains(.,\"#{proposal.title}\")]]")
26
+ expect(data_picker).not_to have_selector(:xpath, "//div[contains(@class,'picker-values')]/div/a[text()[contains(.,\"#{translated(proposal.title)}\")]]")
27
27
  end
28
28
  end
29
29
  end
@@ -160,15 +160,6 @@ FactoryBot.define do
160
160
  end
161
161
  end
162
162
 
163
- trait :with_geocoding_and_collaborative_drafts_enabled do
164
- settings do
165
- {
166
- geocoding_enabled: true,
167
- collaborative_drafts_enabled: true
168
- }
169
- end
170
- end
171
-
172
163
  trait :with_attachments_allowed_and_collaborative_drafts_enabled do
173
164
  settings do
174
165
  {
@@ -268,20 +259,38 @@ FactoryBot.define do
268
259
  end
269
260
 
270
261
  title do
271
- content = generate(:title).dup
272
- content.prepend("<script>alert('TITLE');</script> ") unless skip_injection
273
- content
262
+ if skip_injection
263
+ Decidim::Faker::Localized.localized { generate(:title) }
264
+ else
265
+ Decidim::Faker::Localized.localized { "<script>alert(\"TITLE\");</script> " + generate(:title) }
266
+ end
274
267
  end
275
268
  body do
276
- content = Faker::Lorem.sentences(3).join("\n")
277
- content.prepend("<script>alert('BODY');</script> ") unless skip_injection
278
- content
269
+ if skip_injection
270
+ Decidim::Faker::Localized.localized { Faker::Lorem.sentences(3).join("\n") }
271
+ else
272
+ Decidim::Faker::Localized.localized { "<script>alert(\"TITLE\");</script> " + Faker::Lorem.sentences(3).join("\n") }
273
+ end
279
274
  end
280
275
  component { create(:proposal_component) }
281
276
  published_at { Time.current }
282
277
  address { "#{Faker::Address.street_name}, #{Faker::Address.city}" }
283
278
 
284
279
  after(:build) do |proposal, evaluator|
280
+ proposal.title = if evaluator.title.is_a?(String)
281
+ { proposal.try(:organization).try(:default_locale) || "en" => evaluator.title }
282
+ else
283
+ evaluator.title
284
+ end
285
+ proposal.body = if evaluator.body.is_a?(String)
286
+ { proposal.try(:organization).try(:default_locale) || "en" => evaluator.body }
287
+ else
288
+ evaluator.body
289
+ end
290
+
291
+ proposal.title = Decidim::ContentProcessor.parse_with_processor(:hashtag, proposal.title, current_organization: proposal.organization).rewrite
292
+ proposal.body = Decidim::ContentProcessor.parse_with_processor(:hashtag, proposal.body, current_organization: proposal.organization).rewrite
293
+
285
294
  if proposal.component
286
295
  users = evaluator.users || [create(:user, organization: proposal.component.participatory_space.organization)]
287
296
  users.each_with_index do |user, idx|
@@ -299,6 +308,23 @@ FactoryBot.define do
299
308
  published_at { nil }
300
309
  end
301
310
 
311
+ trait :citizen_author do
312
+ after :build do |proposal|
313
+ proposal.coauthorships.clear
314
+ user = build(:user, organization: proposal.component.participatory_space.organization)
315
+ proposal.coauthorships.build(author: user)
316
+ end
317
+ end
318
+
319
+ trait :user_group_author do
320
+ after :build do |proposal|
321
+ proposal.coauthorships.clear
322
+ user = create(:user, organization: proposal.component.participatory_space.organization)
323
+ user_group = create(:user_group, :verified, organization: user.organization, users: [user])
324
+ proposal.coauthorships.build(author: user, user_group: user_group)
325
+ end
326
+ end
327
+
302
328
  trait :official do
303
329
  after :build do |proposal|
304
330
  proposal.coauthorships.clear
@@ -309,7 +335,7 @@ FactoryBot.define do
309
335
  trait :official_meeting do
310
336
  after :build do |proposal|
311
337
  proposal.coauthorships.clear
312
- component = create(:meeting_component, participatory_space: proposal.component.participatory_space)
338
+ component = build(:meeting_component, participatory_space: proposal.component.participatory_space)
313
339
  proposal.coauthorships.build(author: build(:meeting, component: component))
314
340
  end
315
341
  end
@@ -441,8 +467,8 @@ FactoryBot.define do
441
467
  end
442
468
 
443
469
  factory :participatory_text, class: "Decidim::Proposals::ParticipatoryText" do
444
- title { "<script>alert(\"TITLE\");</script> " + generate(:title) }
445
- description { "<script>alert(\"DESCRIPTION\");</script>\n" + Faker::Lorem.sentences(3).join("\n") }
470
+ title { { en: "<script>alert(\"TITLE\");</script> " + generate(:title) } }
471
+ description { { en: "<script>alert(\"DESCRIPTION\");</script>\n" + Faker::Lorem.sentences(3).join("\n") } }
446
472
  component { create(:proposal_component) }
447
473
  end
448
474
 
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds decidim-proposals version.
5
5
  module Proposals
6
6
  def self.version
7
- "0.22.0"
7
+ "0.23.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-proposals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.23.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: 2020-09-01 00:00:00.000000000 Z
13
+ date: 2020-11-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: acts_as_list
@@ -60,28 +60,28 @@ dependencies:
60
60
  requirements:
61
61
  - - '='
62
62
  - !ruby/object:Gem::Version
63
- version: 0.22.0
63
+ version: 0.23.0
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - '='
69
69
  - !ruby/object:Gem::Version
70
- version: 0.22.0
70
+ version: 0.23.0
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: decidim-core
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - '='
76
76
  - !ruby/object:Gem::Version
77
- version: 0.22.0
77
+ version: 0.23.0
78
78
  type: :runtime
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.22.0
84
+ version: 0.23.0
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: doc2text
87
87
  requirement: !ruby/object:Gem::Requirement
@@ -150,84 +150,84 @@ dependencies:
150
150
  requirements:
151
151
  - - '='
152
152
  - !ruby/object:Gem::Version
153
- version: 0.22.0
153
+ version: 0.23.0
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.22.0
160
+ version: 0.23.0
161
161
  - !ruby/object:Gem::Dependency
162
162
  name: decidim-assemblies
163
163
  requirement: !ruby/object:Gem::Requirement
164
164
  requirements:
165
165
  - - '='
166
166
  - !ruby/object:Gem::Version
167
- version: 0.22.0
167
+ version: 0.23.0
168
168
  type: :development
169
169
  prerelease: false
170
170
  version_requirements: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - '='
173
173
  - !ruby/object:Gem::Version
174
- version: 0.22.0
174
+ version: 0.23.0
175
175
  - !ruby/object:Gem::Dependency
176
176
  name: decidim-budgets
177
177
  requirement: !ruby/object:Gem::Requirement
178
178
  requirements:
179
179
  - - '='
180
180
  - !ruby/object:Gem::Version
181
- version: 0.22.0
181
+ version: 0.23.0
182
182
  type: :development
183
183
  prerelease: false
184
184
  version_requirements: !ruby/object:Gem::Requirement
185
185
  requirements:
186
186
  - - '='
187
187
  - !ruby/object:Gem::Version
188
- version: 0.22.0
188
+ version: 0.23.0
189
189
  - !ruby/object:Gem::Dependency
190
190
  name: decidim-dev
191
191
  requirement: !ruby/object:Gem::Requirement
192
192
  requirements:
193
193
  - - '='
194
194
  - !ruby/object:Gem::Version
195
- version: 0.22.0
195
+ version: 0.23.0
196
196
  type: :development
197
197
  prerelease: false
198
198
  version_requirements: !ruby/object:Gem::Requirement
199
199
  requirements:
200
200
  - - '='
201
201
  - !ruby/object:Gem::Version
202
- version: 0.22.0
202
+ version: 0.23.0
203
203
  - !ruby/object:Gem::Dependency
204
204
  name: decidim-meetings
205
205
  requirement: !ruby/object:Gem::Requirement
206
206
  requirements:
207
207
  - - '='
208
208
  - !ruby/object:Gem::Version
209
- version: 0.22.0
209
+ version: 0.23.0
210
210
  type: :development
211
211
  prerelease: false
212
212
  version_requirements: !ruby/object:Gem::Requirement
213
213
  requirements:
214
214
  - - '='
215
215
  - !ruby/object:Gem::Version
216
- version: 0.22.0
216
+ version: 0.23.0
217
217
  - !ruby/object:Gem::Dependency
218
218
  name: decidim-participatory_processes
219
219
  requirement: !ruby/object:Gem::Requirement
220
220
  requirements:
221
221
  - - '='
222
222
  - !ruby/object:Gem::Version
223
- version: 0.22.0
223
+ version: 0.23.0
224
224
  type: :development
225
225
  prerelease: false
226
226
  version_requirements: !ruby/object:Gem::Requirement
227
227
  requirements:
228
228
  - - '='
229
229
  - !ruby/object:Gem::Version
230
- version: 0.22.0
230
+ version: 0.23.0
231
231
  description: A proposals component for decidim's participatory spaces.
232
232
  email:
233
233
  - josepjaume@gmail.com
@@ -335,9 +335,9 @@ files:
335
335
  - app/controllers/decidim/proposals/collaborative_draft_collaborator_requests_controller.rb
336
336
  - app/controllers/decidim/proposals/collaborative_drafts_controller.rb
337
337
  - app/controllers/decidim/proposals/proposal_votes_controller.rb
338
- - app/controllers/decidim/proposals/proposal_widgets_controller.rb
339
338
  - app/controllers/decidim/proposals/proposals_controller.rb
340
339
  - app/controllers/decidim/proposals/versions_controller.rb
340
+ - app/controllers/decidim/proposals/widgets_controller.rb
341
341
  - app/events/decidim/proposals/accepted_proposal_event.rb
342
342
  - app/events/decidim/proposals/admin/proposal_note_created_event.rb
343
343
  - app/events/decidim/proposals/admin/update_proposal_category_event.rb
@@ -513,22 +513,27 @@ files:
513
513
  - app/views/decidim/proposals/proposals/show.html.erb
514
514
  - app/views/decidim/proposals/versions/index.html.erb
515
515
  - app/views/decidim/proposals/versions/show.html.erb
516
+ - config/locales/am-ET.yml
516
517
  - config/locales/ar-SA.yml
517
518
  - config/locales/ar.yml
518
519
  - config/locales/bg-BG.yml
520
+ - config/locales/bg.yml
519
521
  - config/locales/ca.yml
520
522
  - config/locales/cs-CZ.yml
521
523
  - config/locales/cs.yml
522
524
  - config/locales/da-DK.yml
525
+ - config/locales/da.yml
523
526
  - config/locales/de.yml
524
527
  - config/locales/el-GR.yml
525
528
  - config/locales/el.yml
526
529
  - config/locales/en.yml
527
530
  - config/locales/eo-UY.yml
531
+ - config/locales/eo.yml
528
532
  - config/locales/es-MX.yml
529
533
  - config/locales/es-PY.yml
530
534
  - config/locales/es.yml
531
535
  - config/locales/et-EE.yml
536
+ - config/locales/et.yml
532
537
  - config/locales/eu.yml
533
538
  - config/locales/fi-pl.yml
534
539
  - config/locales/fi-plain.yml
@@ -538,16 +543,24 @@ files:
538
543
  - config/locales/ga-IE.yml
539
544
  - config/locales/gl.yml
540
545
  - config/locales/hr-HR.yml
546
+ - config/locales/hr.yml
541
547
  - config/locales/hu.yml
542
548
  - config/locales/id-ID.yml
543
549
  - config/locales/is-IS.yml
550
+ - config/locales/is.yml
544
551
  - config/locales/it.yml
545
552
  - config/locales/ja-JP.yml
553
+ - config/locales/ja.yml
554
+ - config/locales/ko-KR.yml
555
+ - config/locales/ko.yml
546
556
  - config/locales/lt-LT.yml
547
- - config/locales/lv-LV.yml
557
+ - config/locales/lt.yml
558
+ - config/locales/lv.yml
548
559
  - config/locales/mt-MT.yml
560
+ - config/locales/mt.yml
549
561
  - config/locales/nl.yml
550
562
  - config/locales/no.yml
563
+ - config/locales/om-ET.yml
551
564
  - config/locales/pl.yml
552
565
  - config/locales/pt-BR.yml
553
566
  - config/locales/pt.yml
@@ -556,10 +569,16 @@ files:
556
569
  - config/locales/sk-SK.yml
557
570
  - config/locales/sk.yml
558
571
  - config/locales/sl.yml
572
+ - config/locales/so-SO.yml
559
573
  - config/locales/sr-CS.yml
560
574
  - config/locales/sv.yml
575
+ - config/locales/ti-ER.yml
561
576
  - config/locales/tr-TR.yml
562
577
  - config/locales/uk.yml
578
+ - config/locales/vi-VN.yml
579
+ - config/locales/vi.yml
580
+ - config/locales/zh-CN.yml
581
+ - config/locales/zh-TW.yml
563
582
  - db/migrate/20161212110850_create_decidim_proposals.rb
564
583
  - db/migrate/20170112115253_create_proposal_votes.rb
565
584
  - db/migrate/20170113114245_add_text_search_indexes.rb
@@ -601,12 +620,17 @@ files:
601
620
  - db/migrate/20190215113158_use_md5_indexes.rb
602
621
  - db/migrate/20191206154128_add_endorsements_counter_cache_to_proposals.rb
603
622
  - db/migrate/20200120215928_move_proposal_endorsements_to_core_endorsements.rb
623
+ - db/migrate/20200120230130_drop_proposal_endorsements.rb
604
624
  - db/migrate/20200203111239_add_proposal_valuation_assignments.rb
605
625
  - db/migrate/20200210135152_add_costs_to_proposals.rb
606
626
  - db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
607
627
  - db/migrate/20200227175922_add_state_published_at_to_proposals.rb
608
628
  - db/migrate/20200306123652_publish_existing_proposals_state.rb
629
+ - db/migrate/20200708091228_move_proposals_fields_to_i18n.rb
609
630
  - db/migrate/20200730131631_move_proposal_endorsed_event_notifications_to_resource_endorsed_event.rb
631
+ - db/migrate/20200827154156_add_commentable_counter_cache_to_proposals.rb
632
+ - db/migrate/20200915151348_fix_proposals_data_to_ensure_title_and_body_are_hashes.rb
633
+ - db/migrate/20201002085508_fix_proposals_data.rb
610
634
  - lib/decidim/content_parsers/proposal_parser.rb
611
635
  - lib/decidim/content_renderers/proposal_renderer.rb
612
636
  - lib/decidim/proposals.rb
@@ -637,14 +661,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
637
661
  requirements:
638
662
  - - ">="
639
663
  - !ruby/object:Gem::Version
640
- version: '2.5'
664
+ version: '2.6'
641
665
  required_rubygems_version: !ruby/object:Gem::Requirement
642
666
  requirements:
643
667
  - - ">="
644
668
  - !ruby/object:Gem::Version
645
669
  version: '0'
646
670
  requirements: []
647
- rubygems_version: 3.1.2
671
+ rubygems_version: 3.0.3
648
672
  signing_key:
649
673
  specification_version: 4
650
674
  summary: Decidim proposals module