decidim-proposals 0.23.0 → 0.24.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +4 -1
  3. data/app/assets/stylesheets/decidim/proposals/_proposals.css.scss +1 -0
  4. data/app/assets/stylesheets/decidim/proposals/proposals/_preview.css.scss +3 -0
  5. data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +3 -3
  6. data/app/cells/decidim/proposals/collaborative_drafts/reported_content/show.erb +3 -0
  7. data/app/cells/decidim/proposals/collaborative_drafts/reported_content_cell.rb +15 -0
  8. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/elements.erb +5 -0
  9. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/heading.erb +1 -0
  10. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals_cell.rb +19 -0
  11. data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +1 -1
  12. data/app/cells/decidim/proposals/proposal_m_cell.rb +23 -2
  13. data/app/cells/decidim/proposals/reported_content/show.erb +4 -0
  14. data/app/cells/decidim/proposals/reported_content_cell.rb +13 -0
  15. data/app/commands/decidim/proposals/admin/update_proposal.rb +2 -0
  16. data/app/commands/decidim/proposals/hashtags_methods.rb +1 -1
  17. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +7 -5
  18. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +1 -30
  19. data/app/controllers/decidim/proposals/proposals_controller.rb +5 -6
  20. data/app/events/decidim/proposals/publish_proposal_event.rb +1 -1
  21. data/app/forms/decidim/proposals/access_to_collaborative_draft_form.rb +1 -3
  22. data/app/forms/decidim/proposals/admin/proposal_base_form.rb +3 -2
  23. data/app/forms/decidim/proposals/admin/proposal_form.rb +13 -0
  24. data/app/forms/decidim/proposals/proposal_form.rb +15 -5
  25. data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +1 -9
  26. data/app/helpers/decidim/proposals/admin/filterable_helper.rb +1 -1
  27. data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +1 -1
  28. data/app/helpers/decidim/proposals/admin/proposals_helper.rb +8 -8
  29. data/app/helpers/decidim/proposals/application_helper.rb +5 -2
  30. data/app/helpers/decidim/proposals/map_helper.rb +25 -4
  31. data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +14 -44
  32. data/app/helpers/decidim/proposals/proposals_helper.rb +3 -6
  33. data/app/models/decidim/proposals/collaborative_draft.rb +10 -0
  34. data/app/models/decidim/proposals/proposal.rb +21 -11
  35. data/app/permissions/decidim/proposals/admin/permissions.rb +2 -2
  36. data/app/permissions/decidim/proposals/permissions.rb +3 -2
  37. data/app/presenters/decidim/proposals/admin_log/proposal_presenter.rb +2 -2
  38. data/app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb +2 -2
  39. data/app/presenters/decidim/proposals/proposal_presenter.rb +35 -16
  40. data/app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb +4 -4
  41. data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +6 -6
  42. data/app/services/decidim/proposals/diff_renderer.rb +7 -11
  43. data/app/services/decidim/proposals/proposal_builder.rb +1 -0
  44. data/app/validators/proposal_length_validator.rb +4 -2
  45. data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +8 -1
  46. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +8 -2
  47. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +5 -1
  48. data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +1 -1
  49. data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +2 -7
  50. data/app/views/decidim/proposals/collaborative_drafts/_wizard_header.html.erb +14 -0
  51. data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +7 -7
  52. data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +5 -13
  53. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +7 -11
  54. data/app/views/decidim/proposals/proposals/_dynamic_map_instructions.html.erb +3 -0
  55. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +2 -2
  56. data/app/views/decidim/proposals/proposals/_filters.html.erb +34 -32
  57. data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +21 -11
  58. data/app/views/decidim/proposals/proposals/edit.html.erb +7 -7
  59. data/app/views/decidim/proposals/proposals/preview.html.erb +50 -2
  60. data/app/views/decidim/proposals/proposals/show.html.erb +8 -12
  61. data/config/locales/ar.yml +2 -22
  62. data/config/locales/ca.yml +9 -30
  63. data/config/locales/cs.yml +47 -52
  64. data/config/locales/de.yml +126 -104
  65. data/config/locales/el.yml +2 -29
  66. data/config/locales/en.yml +24 -29
  67. data/config/locales/es-MX.yml +3 -29
  68. data/config/locales/es-PY.yml +3 -29
  69. data/config/locales/es.yml +3 -29
  70. data/config/locales/eu.yml +4 -22
  71. data/config/locales/fi-plain.yml +19 -28
  72. data/config/locales/fi.yml +26 -35
  73. data/config/locales/fr-CA.yml +20 -29
  74. data/config/locales/fr.yml +20 -29
  75. data/config/locales/gl.yml +4 -22
  76. data/config/locales/hu.yml +2 -22
  77. data/config/locales/id-ID.yml +2 -22
  78. data/config/locales/is-IS.yml +0 -5
  79. data/config/locales/it.yml +4 -29
  80. data/config/locales/ja.yml +2 -29
  81. data/config/locales/lv.yml +2 -21
  82. data/config/locales/nl.yml +28 -43
  83. data/config/locales/no.yml +4 -24
  84. data/config/locales/pl.yml +17 -30
  85. data/config/locales/pt-BR.yml +2 -21
  86. data/config/locales/pt.yml +2 -29
  87. data/config/locales/ro-RO.yml +5 -28
  88. data/config/locales/ru.yml +0 -5
  89. data/config/locales/si-LK.yml +1 -0
  90. data/config/locales/sk.yml +5 -22
  91. data/config/locales/sv.yml +12 -34
  92. data/config/locales/sw-KE.yml +1 -0
  93. data/config/locales/tr-TR.yml +383 -231
  94. data/config/locales/uk.yml +0 -5
  95. data/config/locales/zh-CN.yml +2 -29
  96. data/db/migrate/20200708091228_move_proposals_fields_to_i18n.rb +8 -2
  97. data/db/migrate/20210127115628_fix_answered_proposals_after_copy.rb +14 -0
  98. data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_filter.rb +0 -0
  99. data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_sort.rb +3 -5
  100. data/lib/decidim/api/proposal_type.rb +56 -0
  101. data/lib/decidim/api/proposals_type.rb +43 -0
  102. data/lib/decidim/content_renderers/proposal_renderer.rb +1 -1
  103. data/lib/decidim/proposals.rb +2 -0
  104. data/lib/decidim/proposals/api.rb +10 -0
  105. data/lib/decidim/proposals/component.rb +30 -19
  106. data/lib/decidim/proposals/engine.rb +6 -27
  107. data/lib/decidim/proposals/proposal_creator.rb +98 -0
  108. data/lib/decidim/proposals/test/factories.rb +22 -8
  109. data/lib/decidim/proposals/version.rb +1 -1
  110. metadata +55 -40
  111. data/app/commands/decidim/proposals/create_proposal_export.rb +0 -37
  112. data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +0 -0
  113. data/app/queries/decidim/proposals/similar_collaborative_drafts.rb +0 -52
  114. data/app/types/decidim/proposals/proposal_type.rb +0 -70
  115. data/app/types/decidim/proposals/proposals_type.rb +0 -41
  116. data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +0 -13
  117. data/app/views/decidim/proposals/collaborative_drafts/compare.html.erb +0 -21
  118. data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +0 -24
  119. data/app/views/decidim/proposals/proposals/_proposal_preview.html.erb +0 -1
@@ -139,10 +139,6 @@ uk:
139
139
  email_outro: Ви отримали це сповіщення, тому що ви стежите за %{participatory_space_title}. Ви можете відписатися від цих сповіщень, перейшовши за наведеним вище посиланням.
140
140
  email_subject: У %{participatory_space_title} почалось голосування щодо пропозицій
141
141
  notification_title: Тепер в <a href="%{participatory_space_url}">%{participatory_space_title}</a> відкрилась можливість <a href="%{resource_path}">голосувати щодо пропозицій</a>
142
- participatory_processes:
143
- participatory_process_groups:
144
- highlighted_proposals:
145
- proposals: Пропозиції
146
142
  proposals:
147
143
  actions:
148
144
  import: Запозичити з іншої складової
@@ -152,7 +148,6 @@ uk:
152
148
  actions:
153
149
  preview: Попередній перегляд
154
150
  exports:
155
- comments: Коментарі
156
151
  proposals: Пропозиції
157
152
  models:
158
153
  proposal:
@@ -324,10 +324,6 @@ zh-CN:
324
324
  description: 支持提议的数量
325
325
  object: 支持
326
326
  title: 支持
327
- participatory_processes:
328
- participatory_process_groups:
329
- highlighted_proposals:
330
- proposals: 建议
331
327
  participatory_spaces:
332
328
  highlighted_proposals:
333
329
  see_all: 查看所有建议 (%{count})
@@ -344,7 +340,6 @@ zh-CN:
344
340
  actions:
345
341
  preview: 预览
346
342
  exports:
347
- comments: 评论
348
343
  proposals: 建议
349
344
  models:
350
345
  proposal:
@@ -368,9 +363,7 @@ zh-CN:
368
363
  new_import:
369
364
  accepted_mime_types:
370
365
  md: Markdown
371
- odt: 好的
372
366
  bottom_hint: "(您将能够预览和排序文档部分)"
373
- document_legend: '添加一个小于2MB的文档,每个部分直到3级深度将被解析为建议书。支持的格式为: %{valid_mime_types}'
374
367
  title: 添加文档
375
368
  upload_document: 上传文档
376
369
  publish:
@@ -555,13 +548,6 @@ zh-CN:
555
548
  ok: 撤回协作草稿
556
549
  title: 以下操作是不可逆的
557
550
  success: 协作草案已成功撤销。
558
- compare:
559
- mine_is_different: 我的合作草稿是不同的
560
- no_similars_found: 干得好!找不到类似的协作草稿
561
- title: 类似的合作草稿
562
- complete:
563
- send: 发送
564
- title: 完成您的协作草稿
565
551
  count:
566
552
  drafts_count:
567
553
  other: "%{count} 协作草稿"
@@ -592,7 +578,6 @@ zh-CN:
592
578
  unfold: 展开...
593
579
  new:
594
580
  send: 继续
595
- title: 创建您的协作草稿
596
581
  new_collaborative_draft_button:
597
582
  new_collaborative_draft: 新的协作草稿
598
583
  orders:
@@ -636,23 +621,11 @@ zh-CN:
636
621
  update:
637
622
  error: 保存合作草稿时出现问题。
638
623
  success: 协作草稿已成功更新。
639
- title: 编辑协作草稿
640
624
  wizard_aside:
641
- back: 后退
642
625
  back_from_collaborative_draft: 返回协作草稿
643
- back_from_step_1: 返回协作草稿
644
- back_from_step_2: 返回协作草稿
645
- back_from_step_3: 返回比较协作草稿
646
- back_from_step_4: 返回编辑草稿
647
626
  info: 您正在创建一个 <strong>协作草案</strong>。
648
- wizard_steps:
649
- current_step: 当前步骤
650
- see_steps: 查看步骤
651
- step_1: 创建您的协作草稿
652
- step_2: 与协作草稿比较
653
- step_3: 完成您的协作草稿
654
- step_of: 步骤 %{current_step_num} / %{total_steps}
655
- title: 协作创建步骤草案
627
+ wizard_header:
628
+ title: 创建您的协作草稿
656
629
  create:
657
630
  error: 保存建议时出现问题。
658
631
  success: 建议已成功创建为草稿。
@@ -11,7 +11,13 @@ class MoveProposalsFieldsToI18n < ActiveRecord::Migration[5.2]
11
11
  Decidim::Proposals::Proposal.find_each do |proposal|
12
12
  author = proposal.coauthorships.first.author
13
13
 
14
- locale = author.try(:locale).presence || author.try(:default_locale).presence || author.try(:organization).try(:default_locale).presence
14
+ locale = if author
15
+ author.try(:locale).presence || author.try(:default_locale).presence || author.try(:organization).try(:default_locale).presence
16
+ elsif proposal.component && proposal.component.participatory_space
17
+ proposal.component.participatory_space.organization.default_locale
18
+ else
19
+ I18n.default_locale.to_s
20
+ end
15
21
 
16
22
  proposal.new_title = {
17
23
  locale => proposal.title
@@ -20,7 +26,7 @@ class MoveProposalsFieldsToI18n < ActiveRecord::Migration[5.2]
20
26
  locale => proposal.body
21
27
  }
22
28
 
23
- proposal.save!
29
+ proposal.save(validate: false)
24
30
  end
25
31
  end
26
32
 
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FixAnsweredProposalsAfterCopy < ActiveRecord::Migration[5.2]
4
+ def change
5
+ proposals_after_copy = Decidim::ResourceLink.where(from_type: "Decidim::Proposals::Proposal").pluck(:from_id)
6
+
7
+ result = Decidim::Proposals::Proposal.where.not(state_published_at: nil).where(state: nil, id: proposals_after_copy)
8
+
9
+ result.find_each do |proposal|
10
+ proposal.state_published_at = nil
11
+ proposal.save!
12
+ end
13
+ end
14
+ end
@@ -9,14 +9,12 @@ module Decidim
9
9
  graphql_name "ProposalSort"
10
10
  description "A type used for sorting proposals"
11
11
 
12
- argument :id, String, "Sort by ID, valid values are ASC or DESC", required: false
12
+ argument :id, GraphQL::Types::String, "Sort by ID, valid values are ASC or DESC", required: false
13
13
  argument :vote_count,
14
- type: String,
14
+ type: GraphQL::Types::String,
15
15
  description: "Sort by number of votes, valid values are ASC or DESC. Will be ignored if votes are hidden",
16
16
  required: false,
17
- prepare: ->(value, _ctx) do
18
- { proposal_votes_count: value }
19
- end
17
+ as: :proposal_votes_count
20
18
  end
21
19
  end
22
20
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ class ProposalType < Decidim::Api::Types::BaseObject
6
+ description "A proposal"
7
+
8
+ implements Decidim::Comments::CommentableInterface
9
+ implements Decidim::Core::CoauthorableInterface
10
+ implements Decidim::Core::CategorizableInterface
11
+ implements Decidim::Core::ScopableInterface
12
+ implements Decidim::Core::AttachableInterface
13
+ implements Decidim::Core::FingerprintInterface
14
+ implements Decidim::Core::AmendableInterface
15
+ implements Decidim::Core::AmendableEntityInterface
16
+ implements Decidim::Core::TraceableInterface
17
+ implements Decidim::Core::EndorsableInterface
18
+ implements Decidim::Core::TimestampsInterface
19
+
20
+ field :id, GraphQL::Types::ID, null: false
21
+ field :title, Decidim::Core::TranslatedFieldType, "The title for this title", null: true
22
+ field :body, Decidim::Core::TranslatedFieldType, "The description for this body", null: true
23
+ field :address, GraphQL::Types::String, "The physical address (location) of this proposal", null: true
24
+ field :coordinates, Decidim::Core::CoordinatesType, "Physical coordinates for this proposal", null: true
25
+
26
+ def coordinates
27
+ [object.latitude, object.longitude]
28
+ end
29
+ field :reference, GraphQL::Types::String, "This proposal's unique reference", null: true
30
+ field :state, GraphQL::Types::String, "The answer status in which proposal is in", null: true
31
+ field :answer, Decidim::Core::TranslatedFieldType, "The answer feedback for the status for this proposal", null: true
32
+
33
+ field :answered_at, Decidim::Core::DateTimeType, description: "The date and time this proposal was answered", null: true
34
+
35
+ field :published_at, Decidim::Core::DateTimeType, description: "The date and time this proposal was published", null: true
36
+
37
+ field :participatory_text_level, GraphQL::Types::String, description: "If it is a participatory text, the level indicates the type of paragraph", null: true
38
+ field :position, GraphQL::Types::Int, "Position of this proposal in the participatory text", null: true
39
+
40
+ field :official, GraphQL::Types::Boolean, "Whether this proposal is official or not", method: :official?, null: true
41
+ field :created_in_meeting, GraphQL::Types::Boolean, "Whether this proposal comes from a meeting or not", method: :official_meeting?, null: true
42
+ field :meeting, Decidim::Meetings::MeetingType, description: "If the proposal comes from a meeting, the related meeting", null: true
43
+
44
+ def meeting
45
+ object.authors.first if object.official_meeting?
46
+ end
47
+
48
+ field :vote_count, GraphQL::Types::Int, description: "The total amount of votes the proposal has received", null: true
49
+
50
+ def vote_count
51
+ current_component = object.component
52
+ object.proposal_votes_count unless current_component.current_settings.votes_hidden?
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ class ProposalListHelper < Decidim::Core::ComponentListBase
6
+ # only querying published posts
7
+ def query_scope
8
+ super.published
9
+ end
10
+ end
11
+
12
+ class ProposalFinderHelper < Decidim::Core::ComponentFinderBase
13
+ # only querying published posts
14
+ def query_scope
15
+ super.published
16
+ end
17
+ end
18
+
19
+ class ProposalsType < Decidim::Api::Types::BaseObject
20
+ implements Decidim::Core::ComponentInterface
21
+
22
+ graphql_name "Proposals"
23
+ description "A proposals component of a participatory space."
24
+
25
+ field :proposals, type: Decidim::Proposals::ProposalType.connection_type, description: "List all proposals", connection: true, null: true do
26
+ argument :order, Decidim::Proposals::ProposalInputSort, "Provides several methods to order the results", required: false
27
+ argument :filter, Decidim::Proposals::ProposalInputFilter, "Provides several methods to filter the results", required: false
28
+ end
29
+
30
+ field :proposal, type: Decidim::Proposals::ProposalType, description: "Finds one proposal", null: true do
31
+ argument :id, GraphQL::Types::ID, "The ID of the proposal", required: true
32
+ end
33
+
34
+ def proposals(filter: {}, order: {})
35
+ Decidim::Proposals::ProposalListHelper.new(model_class: Proposal).call(object, { filter: filter, order: order }, context)
36
+ end
37
+
38
+ def proposal(id:)
39
+ Decidim::Proposals::ProposalFinderHelper.new(model_class: Proposal).call(object, { id: id }, context)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -10,7 +10,7 @@ module Decidim
10
10
  # @see BaseRenderer Examples of how to use a content renderer
11
11
  class ProposalRenderer < BaseRenderer
12
12
  # Matches a global id representing a Decidim::User
13
- GLOBAL_ID_REGEX = %r{gid:\/\/([\w-]*\/Decidim::Proposals::Proposal\/(\d+))}i.freeze
13
+ GLOBAL_ID_REGEX = %r{gid://([\w-]*/Decidim::Proposals::Proposal/(\d+))}i.freeze
14
14
 
15
15
  # Replaces found Global IDs matching an existing proposal with
16
16
  # a link to its show page. The Global IDs representing an
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "decidim/proposals/admin"
4
+ require "decidim/proposals/api"
4
5
  require "decidim/proposals/engine"
5
6
  require "decidim/proposals/admin_engine"
6
7
  require "decidim/proposals/component"
@@ -11,6 +12,7 @@ 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"
15
+ autoload :ProposalCreator, "decidim/proposals/proposal_creator"
14
16
  autoload :CommentableProposal, "decidim/proposals/commentable_proposal"
15
17
  autoload :CommentableCollaborativeDraft, "decidim/proposals/commentable_collaborative_draft"
16
18
  autoload :MarkdownToProposals, "decidim/proposals/markdown_to_proposals"
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ autoload :ProposalInputFilter, "decidim/api/proposal_input_filter"
6
+ autoload :ProposalInputSort, "decidim/api/proposal_input_sort"
7
+ autoload :ProposalType, "decidim/api/proposal_type"
8
+ autoload :ProposalsType, "decidim/api/proposals_type"
9
+ end
10
+ end
@@ -5,6 +5,7 @@ require "decidim/components/namer"
5
5
  Decidim.register_component(:proposals) do |component|
6
6
  component.engine = Decidim::Proposals::Engine
7
7
  component.admin_engine = Decidim::Proposals::AdminEngine
8
+ component.stylesheet = "decidim/proposals/proposals"
8
9
  component.icon = "decidim/proposals/icon.svg"
9
10
 
10
11
  component.on(:before_destroy) do |instance|
@@ -28,6 +29,7 @@ Decidim.register_component(:proposals) do |component|
28
29
  settings.attribute :minimum_votes_per_user, type: :integer, default: 0
29
30
  settings.attribute :proposal_limit, type: :integer, default: 0
30
31
  settings.attribute :proposal_length, type: :integer, default: 500
32
+ settings.attribute :proposal_edit_time, type: :enum, default: "limited", choices: -> { %w(limited infinite) }
31
33
  settings.attribute :proposal_edit_before_minutes, type: :integer, default: 5
32
34
  settings.attribute :threshold_per_proposal, type: :integer, default: 0
33
35
  settings.attribute :can_accumulate_supports_beyond_threshold, type: :boolean, default: false
@@ -80,6 +82,7 @@ Decidim.register_component(:proposals) do |component|
80
82
  resource.model_class_name = "Decidim::Proposals::Proposal"
81
83
  resource.template = "decidim/proposals/proposals/linked_proposals"
82
84
  resource.card = "decidim/proposals/proposal"
85
+ resource.reported_content_cell = "decidim/proposals/reported_content"
83
86
  resource.actions = %w(endorse vote amend)
84
87
  resource.searchable = true
85
88
  end
@@ -87,6 +90,7 @@ Decidim.register_component(:proposals) do |component|
87
90
  component.register_resource(:collaborative_draft) do |resource|
88
91
  resource.model_class_name = "Decidim::Proposals::CollaborativeDraft"
89
92
  resource.card = "decidim/proposals/collaborative_draft"
93
+ resource.reported_content_cell = "decidim/proposals/collaborative_drafts/reported_content"
90
94
  end
91
95
 
92
96
  component.register_stat :proposals_count, primary: true, priority: Decidim::StatsRegistry::HIGH_PRIORITY do |components, start_at, end_at|
@@ -138,16 +142,22 @@ Decidim.register_component(:proposals) do |component|
138
142
  exports.serializer Decidim::Proposals::ProposalSerializer
139
143
  end
140
144
 
141
- component.exports :comments do |exports|
145
+ component.exports :proposal_comments do |exports|
142
146
  exports.collection do |component_instance|
143
147
  Decidim::Comments::Export.comments_for_resource(
144
148
  Decidim::Proposals::Proposal, component_instance
145
149
  )
146
150
  end
147
151
 
152
+ exports.include_in_open_data = true
153
+
148
154
  exports.serializer Decidim::Comments::CommentSerializer
149
155
  end
150
156
 
157
+ component.imports :proposals do |imports|
158
+ imports.creator Decidim::Proposals::ProposalCreator
159
+ end
160
+
151
161
  component.seeds do |participatory_space|
152
162
  admin_user = Decidim::User.find_by(
153
163
  organization: participatory_space.organization,
@@ -191,13 +201,13 @@ Decidim.register_component(:proposals) do |component|
191
201
 
192
202
  5.times do |n|
193
203
  state, answer, state_published_at = if n > 3
194
- ["accepted", Decidim::Faker::Localized.sentence(10), Time.current]
204
+ ["accepted", Decidim::Faker::Localized.sentence(word_count: 10), Time.current]
195
205
  elsif n > 2
196
206
  ["rejected", nil, Time.current]
197
207
  elsif n > 1
198
208
  ["evaluating", nil, Time.current]
199
209
  elsif n.positive?
200
- ["accepted", Decidim::Faker::Localized.sentence(10), nil]
210
+ ["accepted", Decidim::Faker::Localized.sentence(word_count: 10), nil]
201
211
  else
202
212
  [nil, nil, nil]
203
213
  end
@@ -205,9 +215,9 @@ Decidim.register_component(:proposals) do |component|
205
215
  params = {
206
216
  component: component,
207
217
  category: participatory_space.categories.sample,
208
- scope: Faker::Boolean.boolean(0.5) ? global : scopes.sample,
209
- title: { en: Faker::Lorem.sentence(2) },
210
- body: { en: Faker::Lorem.paragraphs(2).join("\n") },
218
+ scope: Faker::Boolean.boolean(true_ratio: 0.5) ? global : scopes.sample,
219
+ title: { en: Faker::Lorem.sentence(word_count: 2) },
220
+ body: { en: Faker::Lorem.paragraphs(number: 2).join("\n") },
211
221
  state: state,
212
222
  answer: answer,
213
223
  answered_at: state.present? ? Time.current : nil,
@@ -271,9 +281,9 @@ Decidim.register_component(:proposals) do |component|
271
281
  params = {
272
282
  component: component,
273
283
  category: participatory_space.categories.sample,
274
- scope: Faker::Boolean.boolean(0.5) ? global : scopes.sample,
275
- title: { en: "#{proposal.title["en"]} #{Faker::Lorem.sentence(1)}" },
276
- body: { en: "#{proposal.body["en"]} #{Faker::Lorem.sentence(3)}" },
284
+ scope: Faker::Boolean.boolean(true_ratio: 0.5) ? global : scopes.sample,
285
+ title: { en: "#{proposal.title["en"]} #{Faker::Lorem.sentence(word_count: 1)}" },
286
+ body: { en: "#{proposal.body["en"]} #{Faker::Lorem.sentence(word_count: 3)}" },
277
287
  state: "evaluating",
278
288
  answer: nil,
279
289
  answered_at: Time.current,
@@ -314,7 +324,7 @@ Decidim.register_component(:proposals) do |component|
314
324
  tos_agreement: "1",
315
325
  confirmed_at: Time.current,
316
326
  personal_url: Faker::Internet.url,
317
- about: Faker::Lorem.paragraph(2)
327
+ about: Faker::Lorem.paragraph(sentence_count: 2)
318
328
  )
319
329
 
320
330
  Decidim::Proposals::ProposalVote.create!(proposal: proposal, author: author) unless proposal.published_state? && proposal.rejected?
@@ -366,7 +376,7 @@ Decidim.register_component(:proposals) do |component|
366
376
  Decidim::Proposals::ProposalNote.create!(
367
377
  proposal: proposal,
368
378
  author: author_admin,
369
- body: Faker::Lorem.paragraphs(2).join("\n")
379
+ body: Faker::Lorem.paragraphs(number: 2).join("\n")
370
380
  )
371
381
  end
372
382
 
@@ -388,9 +398,9 @@ Decidim.register_component(:proposals) do |component|
388
398
  draft = Decidim::Proposals::CollaborativeDraft.new(
389
399
  component: component,
390
400
  category: participatory_space.categories.sample,
391
- scope: Faker::Boolean.boolean(0.5) ? global : scopes.sample,
392
- title: Faker::Lorem.sentence(2),
393
- body: Faker::Lorem.paragraphs(2).join("\n"),
401
+ scope: Faker::Boolean.boolean(true_ratio: 0.5) ? global : scopes.sample,
402
+ title: Faker::Lorem.sentence(word_count: 2),
403
+ body: Faker::Lorem.paragraphs(number: 2).join("\n"),
394
404
  state: state,
395
405
  published_at: Time.current
396
406
  )
@@ -399,7 +409,8 @@ Decidim.register_component(:proposals) do |component|
399
409
  draft
400
410
  end
401
411
 
402
- if n == 2
412
+ case n
413
+ when 2
403
414
  author2 = Decidim::User.where(organization: component.organization).all.sample
404
415
  Decidim::Coauthorship.create(coauthorable: draft, author: author2)
405
416
  author3 = Decidim::User.where(organization: component.organization).all.sample
@@ -410,7 +421,7 @@ Decidim.register_component(:proposals) do |component|
410
421
  Decidim::Coauthorship.create(coauthorable: draft, author: author5)
411
422
  author6 = Decidim::User.where(organization: component.organization).all.sample
412
423
  Decidim::Coauthorship.create(coauthorable: draft, author: author6)
413
- elsif n == 3
424
+ when 3
414
425
  author2 = Decidim::User.where(organization: component.organization).all.sample
415
426
  Decidim::Coauthorship.create(coauthorable: draft, author: author2)
416
427
  end
@@ -423,9 +434,9 @@ Decidim.register_component(:proposals) do |component|
423
434
  Decidim::User.where(organization: component.organization).all.sample,
424
435
  component: component,
425
436
  category: participatory_space.categories.sample,
426
- scope: Faker::Boolean.boolean(0.5) ? global : scopes.sample,
427
- title: Faker::Lorem.sentence(2),
428
- body: Faker::Lorem.paragraphs(2).join("\n")
437
+ scope: Faker::Boolean.boolean(true_ratio: 0.5) ? global : scopes.sample,
438
+ title: Faker::Lorem.sentence(word_count: 2),
439
+ body: Faker::Lorem.paragraphs(number: 2).join("\n")
429
440
  )
430
441
  end
431
442
  end