decidim-proposals 0.15.2 → 0.16.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.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -0
  3. data/app/assets/config/decidim_proposals_manifest.js +1 -0
  4. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +1 -1
  5. data/app/assets/javascripts/decidim/proposals/admin/proposals_form.js.es6 +23 -0
  6. data/app/cells/decidim/proposals/collaborative_draft_cell.rb +0 -2
  7. data/app/cells/decidim/proposals/collaborative_draft_m_cell.rb +5 -1
  8. data/app/cells/decidim/proposals/highlighted_proposals/show.erb +3 -0
  9. data/app/cells/decidim/proposals/highlighted_proposals_cell.rb +25 -0
  10. data/app/cells/decidim/proposals/highlighted_proposals_for_component/show.erb +19 -0
  11. data/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb +34 -0
  12. data/app/cells/decidim/proposals/participatory_text_proposal/buttons.erb +33 -0
  13. data/app/cells/decidim/proposals/participatory_text_proposal/show.erb +9 -0
  14. data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +77 -0
  15. data/app/cells/decidim/proposals/proposal_cell.rb +0 -2
  16. data/app/cells/decidim/proposals/proposal_m/footer.erb +1 -1
  17. data/app/cells/decidim/proposals/proposal_m_cell.rb +6 -1
  18. data/app/commands/decidim/proposals/accept_access_to_collaborative_draft.rb +3 -3
  19. data/app/commands/decidim/proposals/admin/answer_proposal.rb +2 -1
  20. data/app/commands/decidim/proposals/admin/create_proposal.rb +7 -7
  21. data/app/commands/decidim/proposals/admin/import_participatory_text.rb +8 -8
  22. data/app/commands/decidim/proposals/admin/update_proposal.rb +13 -6
  23. data/app/commands/decidim/proposals/admin/update_proposal_category.rb +1 -1
  24. data/app/commands/decidim/proposals/create_collaborative_draft.rb +6 -3
  25. data/app/commands/decidim/proposals/create_proposal.rb +25 -11
  26. data/app/commands/decidim/proposals/endorse_proposal.rb +1 -2
  27. data/app/commands/decidim/proposals/hashtags_methods.rb +36 -0
  28. data/app/commands/decidim/proposals/publish_collaborative_draft.rb +39 -34
  29. data/app/commands/decidim/proposals/publish_proposal.rb +13 -17
  30. data/app/commands/decidim/proposals/reject_access_to_collaborative_draft.rb +2 -3
  31. data/app/commands/decidim/proposals/request_access_to_collaborative_draft.rb +1 -2
  32. data/app/commands/decidim/proposals/update_collaborative_draft.rb +11 -8
  33. data/app/commands/decidim/proposals/update_proposal.rb +37 -13
  34. data/app/commands/decidim/proposals/withdraw_collaborative_draft.rb +3 -3
  35. data/app/commands/decidim/proposals/withdraw_proposal.rb +14 -1
  36. data/app/controllers/decidim/proposals/admin/participatory_texts_controller.rb +2 -1
  37. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +9 -1
  38. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +8 -0
  39. data/app/controllers/decidim/proposals/proposals_controller.rb +64 -27
  40. data/app/controllers/decidim/proposals/versions_controller.rb +5 -1
  41. data/app/events/decidim/proposals/accepted_proposal_event.rb +8 -0
  42. data/app/events/decidim/proposals/evaluating_proposal_event.rb +3 -0
  43. data/app/events/decidim/proposals/proposal_endorsed_event.rb +4 -0
  44. data/app/events/decidim/proposals/publish_proposal_event.rb +4 -0
  45. data/app/events/decidim/proposals/rejected_proposal_event.rb +8 -0
  46. data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +4 -0
  47. data/app/forms/decidim/proposals/admin/proposal_form.rb +49 -0
  48. data/app/forms/decidim/proposals/collaborative_draft_form.rb +2 -0
  49. data/app/forms/decidim/proposals/proposal_form.rb +32 -0
  50. data/app/helpers/decidim/proposals/admin/proposals_helper.rb +19 -0
  51. data/app/helpers/decidim/proposals/application_helper.rb +48 -12
  52. data/app/helpers/decidim/proposals/control_version_helper.rb +61 -0
  53. data/app/helpers/decidim/proposals/participatory_texts_helper.rb +8 -0
  54. data/app/helpers/decidim/proposals/proposal_cells_helper.rb +7 -1
  55. data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +8 -6
  56. data/app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb +2 -2
  57. data/app/jobs/decidim/proposals/settings_change_job.rb +8 -6
  58. data/app/models/decidim/proposals/collaborative_draft.rb +3 -0
  59. data/app/models/decidim/proposals/proposal.rb +20 -8
  60. data/app/permissions/decidim/proposals/admin/permissions.rb +1 -1
  61. data/app/presenters/decidim/proposals/admin_log/value_types/proposal_title_body_presenter.rb +2 -1
  62. data/app/presenters/decidim/proposals/collaborative_draft_presenter.rb +15 -2
  63. data/app/presenters/decidim/proposals/official_author_presenter.rb +4 -0
  64. data/app/presenters/decidim/proposals/proposal_presenter.rb +10 -14
  65. data/app/queries/decidim/proposals/metrics/endorsements_metric_manage.rb +54 -0
  66. data/app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb +56 -0
  67. data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +64 -0
  68. data/app/services/decidim/proposals/proposal_search.rb +46 -5
  69. data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +1 -1
  70. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +43 -2
  71. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +6 -2
  72. data/app/views/decidim/proposals/admin/proposals/edit.html.erb +1 -1
  73. data/app/views/decidim/proposals/admin/proposals/new.html.erb +1 -1
  74. data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +81 -0
  75. data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +1 -49
  76. data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +1 -29
  77. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +5 -5
  78. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +27 -3
  79. data/app/views/decidim/proposals/proposals/_filters.html.erb +5 -2
  80. data/app/views/decidim/proposals/proposals/_proposal.html.erb +5 -1
  81. data/app/views/decidim/proposals/proposals/_proposal_similar.html.erb +2 -2
  82. data/app/views/decidim/proposals/proposals/_vote_button.html.erb +39 -35
  83. data/app/views/decidim/proposals/proposals/_votes_count.html.erb +16 -12
  84. data/app/views/decidim/proposals/proposals/new.html.erb +1 -1
  85. data/app/views/decidim/proposals/proposals/participatory_texts/_index.html.erb +19 -0
  86. data/app/views/decidim/proposals/proposals/participatory_texts/_proposal_vote_button.html.erb +46 -0
  87. data/app/views/decidim/proposals/proposals/participatory_texts/_proposal_votes_count.html.erb +41 -0
  88. data/app/views/decidim/proposals/proposals/participatory_texts/_view_index.html.erb +10 -0
  89. data/app/views/decidim/proposals/proposals/participatory_texts/participatory_text.html.erb +15 -0
  90. data/app/views/decidim/proposals/proposals/show.html.erb +45 -4
  91. data/app/views/decidim/proposals/versions/_version.html.erb +2 -2
  92. data/app/views/decidim/proposals/versions/index.html.erb +1 -1
  93. data/app/views/decidim/proposals/versions/show.html.erb +2 -2
  94. data/config/locales/ca.yml +87 -33
  95. data/config/locales/de.yml +87 -36
  96. data/config/locales/en.yml +87 -33
  97. data/config/locales/es-PY.yml +87 -33
  98. data/config/locales/es.yml +88 -34
  99. data/config/locales/eu.yml +87 -33
  100. data/config/locales/fi-pl.yml +87 -33
  101. data/config/locales/fi.yml +87 -33
  102. data/config/locales/fr.yml +87 -33
  103. data/config/locales/gl.yml +87 -33
  104. data/config/locales/hu.yml +87 -33
  105. data/config/locales/id-ID.yml +84 -30
  106. data/config/locales/it.yml +87 -33
  107. data/config/locales/nl.yml +87 -33
  108. data/config/locales/pl.yml +87 -33
  109. data/config/locales/pt-BR.yml +87 -33
  110. data/config/locales/pt.yml +87 -33
  111. data/config/locales/ru.yml +21 -38
  112. data/config/locales/sv.yml +87 -33
  113. data/config/locales/tr-TR.yml +86 -32
  114. data/config/locales/uk.yml +21 -38
  115. data/db/migrate/20181026073215_add_created_in_meeting.rb +7 -0
  116. data/lib/decidim/proposals.rb +2 -0
  117. data/lib/decidim/proposals/component.rb +74 -0
  118. data/lib/decidim/proposals/doc_to_markdown.rb +40 -0
  119. data/lib/decidim/proposals/engine.rb +52 -35
  120. data/lib/decidim/proposals/odt_to_markdown.rb +46 -0
  121. data/lib/decidim/proposals/proposal_serializer.rb +29 -13
  122. data/lib/decidim/proposals/test/factories.rb +76 -0
  123. data/lib/decidim/proposals/version.rb +1 -1
  124. metadata +56 -20
  125. data/app/views/decidim/participatory_spaces/_highlighted_proposals.html.erb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3178ec190b652c6edf575777f6a911d1961735f277b7be19688270eeac06a975
4
- data.tar.gz: 82b8bd589fe391cea20cf6bd3bb90d068bf12a2630d62667f7cb36107893345d
3
+ metadata.gz: 1eb9355480e7b5f78b9eb01ede6e1e51362cf77f991b45d43944fbe3b52eece1
4
+ data.tar.gz: c44373543399ee2bd9c95d5d47ba89d209cd9033c899ef7cb614166a531e4b4d
5
5
  SHA512:
6
- metadata.gz: 669d98ba3e10844143fed41db59bf8275be07ffb880ac0df685d0fb45a0a8c4cb8897a866e7bdb20916cdbe64650c84c1cf8f0007b136212fe631ea99a2611c8
7
- data.tar.gz: fa7407ac02421a6950106755aef55b5208465b58e4e2df48311977fd55eb414503c9fdeceda99f015c9c7d1a31c9aa12192e448ccd5f7e0283c75736cc4ed634
6
+ metadata.gz: 5e4582447ccb88226799caaa32bedcf851e81af9ed927c1a7a4adabc9dedd8341438d45ce735cc471998e018119f597c7cb577b7e938d575f3b96de6a34bc1a9
7
+ data.tar.gz: 985e3a9309033dbceed04819a85796c8faaf379c6e845420ca9884a2b545464025c5d195dd03659ed6fc571622b751462bda1b9f9de519c99ac887eb8d9844d6
data/README.md CHANGED
@@ -43,6 +43,18 @@ This module includes the following models to Decidim's Global Search:
43
43
 
44
44
  - `Proposals`
45
45
 
46
+ ## Participatory Texts
47
+
48
+ Participatory texts persist each section of the document in a Proposal.
49
+
50
+ When importing participatory texts all formats are first transformed into Markdown and is the markdown that is parsed and processed to generate the corresponding Proposals.
51
+
52
+ When processing participatory text documents three kinds of secions are taken into account.
53
+
54
+ - Section: each "Title 1" in the document becomes a section.
55
+ - Subsection: the rest of the titles become subsections.
56
+ - Article: paragraphs become articles.
57
+
46
58
  ## Contributing
47
59
 
48
60
  See [Decidim](https://github.com/decidim/decidim).
@@ -1,3 +1,4 @@
1
1
  //= link decidim/proposals/social_share.js
2
2
  //= link decidim/proposals/add_proposal.js
3
+ //= link decidim/proposals/admin/proposals_form.js
3
4
  //= link_tree ../images/decidim
@@ -2,7 +2,7 @@ $(() => {
2
2
  window.DecidimProposals = window.DecidimProposals || {};
3
3
 
4
4
  window.DecidimProposals.bindProposalAddress = () => {
5
- const $checkbox = $("input:checkbox.has_address");
5
+ const $checkbox = $("input:checkbox[name$='[has_address]']");
6
6
  const $addressInput = $("#address_input");
7
7
 
8
8
  if ($checkbox.length > 0) {
@@ -0,0 +1,23 @@
1
+ $(() => {
2
+ const $form = $(".proposal_form_admin");
3
+
4
+ if ($form.length > 0) {
5
+ const $proposalCreatedInMeeting = $form.find("#proposal_created_in_meeting");
6
+ const $proposalMeeting = $form.find("#proposal_meeting");
7
+
8
+ const toggleDisabledHiddenFields = () => {
9
+ const enabledMeeting = $proposalCreatedInMeeting.prop("checked");
10
+ $proposalMeeting.find("select").attr("disabled", "disabled");
11
+ $proposalMeeting.hide();
12
+
13
+ if (enabledMeeting) {
14
+ $proposalMeeting.find("select").attr("disabled", !enabledMeeting);
15
+ $proposalMeeting.show();
16
+ }
17
+ };
18
+
19
+ $proposalCreatedInMeeting.on("change", toggleDisabledHiddenFields);
20
+ toggleDisabledHiddenFields();
21
+
22
+ }
23
+ });
@@ -11,8 +11,6 @@ module Decidim
11
11
  include Cell::ViewModel::Partial
12
12
  include Messaging::ConversationHelper
13
13
 
14
- delegate :user_signed_in?, to: :parent_controller
15
-
16
14
  def show
17
15
  cell card_size, model, @options
18
16
  end
@@ -18,8 +18,12 @@ module Decidim
18
18
  true
19
19
  end
20
20
 
21
+ def title
22
+ present(model).title
23
+ end
24
+
21
25
  def description
22
- truncate(model.body, length: 100)
26
+ truncate(present(model).body, length: 100)
23
27
  end
24
28
 
25
29
  def has_badge?
@@ -0,0 +1,3 @@
1
+ <% published_components.each do |component| %>
2
+ <%= cell "decidim/proposals/highlighted_proposals_for_component", component %>
3
+ <% end %>
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cell/partial"
4
+
5
+ module Decidim
6
+ module Proposals
7
+ # This cell renders the highlighted proposals for a given participatory
8
+ # space. It is intended to be used in the `participatory_space_highlighted_elements`
9
+ # view hook.
10
+ class HighlightedProposalsCell < Decidim::ViewModel
11
+ include ProposalCellsHelper
12
+
13
+ private
14
+
15
+ def published_components
16
+ Decidim::Component
17
+ .where(
18
+ participatory_space: model,
19
+ manifest_name: :proposals
20
+ )
21
+ .published
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ <section class="section row collapse highlighted_proposals">
2
+ <h4 class="section-heading">
3
+ <%= translated_attribute(model.name) %> <a href="<%= main_component_path(model) %>" class="text-small"><%= t("decidim.participatory_spaces.highlighted_proposals.see_all", count: proposals_count) %></a>
4
+ </h4>
5
+
6
+ <%= cell(
7
+ "decidim/collapsible_list",
8
+ proposals_to_render,
9
+ cell_options: {},
10
+ list_class: "row small-up-1 medium-up-2 card-grid",
11
+ size: proposals_count
12
+ ) %>
13
+
14
+ <%= link_to(
15
+ t("decidim.participatory_spaces.highlighted_proposals.see_all", count: proposals_count),
16
+ main_component_path(model),
17
+ class: "button button--sc light secondary button--right"
18
+ ) %>
19
+ </section>
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cell/partial"
4
+
5
+ module Decidim
6
+ module Proposals
7
+ # This cell renders the highlighted proposals for a given component.
8
+ # It is intended to be used in the `participatory_space_highlighted_elements`
9
+ # view hook.
10
+ class HighlightedProposalsForComponentCell < Decidim::ViewModel
11
+ include Decidim::ComponentPathHelper
12
+
13
+ def show
14
+ render unless proposals_count.zero?
15
+ end
16
+
17
+ private
18
+
19
+ def proposals
20
+ @proposals ||= Decidim::Proposals::Proposal.published.not_hidden.except_withdrawn
21
+ .where(component: model)
22
+ .order_randomly(rand * 2 - 1)
23
+ end
24
+
25
+ def proposals_to_render
26
+ @proposals_to_render ||= proposals.limit(Decidim::Proposals.config.participatory_space_highlighted_proposals_limit)
27
+ end
28
+
29
+ def proposals_count
30
+ @proposals_count ||= proposals.count
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,33 @@
1
+ <div class="columns mediumlarge-4 hidden-section p-sm">
2
+ <div class="medium-8">
3
+ <%= follow_button_for(model, true) %>
4
+ <% if amendments_enabled? %>
5
+ <div class="button-group button-group--collapse mb-s row collapse">
6
+ <%= link_to resource_amendments_path, class: "column medium-4 button light secondary" do %>
7
+ <%= model.emendations.count %>
8
+ <% end %>
9
+ <%= link_to amend_resource_path, class: "column button hollow secondary button--sc" do %>
10
+ <%= t("amend", scope: "decidim.proposals.participatory_text_proposal.buttons") %>
11
+ <% end %>
12
+ </div>
13
+ <% end %>
14
+ <% if component_settings.comments_enabled? %>
15
+ <div class="button-group button-group--collapse row collapse">
16
+ <% if current_settings.comments_blocked? %>
17
+ <%= content_tag :button, class: "column medium-4 button light secondary", title: t("endorse", scope: "decidim.proposals.participatory_text_proposal.buttons") do %>
18
+ <%= icon "comment-square", class: "icon--small", aria_label: t("comments", scope: "decidim.proposals.participatory_text_proposal.buttons"), role: "img" %>
19
+ <%= model.comments.count %>
20
+ <% end %>
21
+ <%= content_tag :button, t("comment", scope: "decidim.proposals.participatory_text_proposal.buttons"), class: "column button hollow secondary button--sc disabled", disabled: true, title: t("comment", scope: "decidim.proposals.participatory_text_proposal.buttons") %>
22
+ <% else %>
23
+ <%= link_to resource_comments_path, class: "column medium-4 button light secondary" do %>
24
+ <%= icon "comment-square", class: "icon--small", aria_label: t("comments", scope: "decidim.proposals.participatory_text_proposal.buttons"), role: "img" %> <%= model.comments.count %>
25
+ <% end %>
26
+ <%= link_to resource_comments_path, class: "column button hollow secondary button--sc" do %>
27
+ <%= t("comment", scope: "decidim.proposals.participatory_text_proposal.buttons") %>
28
+ <% end %>
29
+ <% end %>
30
+ </div>
31
+ <% end %>
32
+ </div>
33
+ </div>
@@ -0,0 +1,9 @@
1
+ <div class="row hover-section">
2
+ <div class="columns mediumlarge-8">
3
+ <%= link_to resource_path, class: "card__link--block pt-s pb-s" do %>
4
+ <%= title %>
5
+ <%= body %>
6
+ <% end %>
7
+ </div>
8
+ <%= render :buttons %>
9
+ </div>
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cell/partial"
4
+
5
+ module Decidim
6
+ module Proposals
7
+ # This cell renders the participatory text proposal card for an instance of a Proposal
8
+ # the default size is the Medium Card (:m)
9
+ class ParticipatoryTextProposalCell < Decidim::ViewModel
10
+ include ProposalCellsHelper
11
+ include Cell::ViewModel::Partial
12
+ include Messaging::ConversationHelper
13
+
14
+ delegate :current_organization, to: :controller
15
+
16
+ def show
17
+ render
18
+ end
19
+
20
+ private
21
+
22
+ def title
23
+ case model.participatory_text_level
24
+ when "section"
25
+ "<h5><strong class='text-uppercase'>#{present(model).title}</strong></h5>"
26
+ else
27
+ "<h6><strong>#{present(model).title}</strong></h6>"
28
+ end
29
+ end
30
+
31
+ def body
32
+ return unless model.participatory_text_level == "article"
33
+ present(model).body
34
+ end
35
+
36
+ def current_user
37
+ context[:current_user]
38
+ end
39
+
40
+ def resource_path
41
+ resource_locator(model).path
42
+ end
43
+
44
+ def amend_resource_path
45
+ decidim.new_amend_path(amendable_gid: model.to_sgid.to_s)
46
+ end
47
+
48
+ def resource_comments_path
49
+ resource_locator(model).path(anchor: "comments")
50
+ end
51
+
52
+ def resource_amendments_path
53
+ resource_locator(model).path(anchor: "amendments")
54
+ end
55
+
56
+ def current_participatory_space
57
+ model.component.participatory_space
58
+ end
59
+
60
+ def component_name
61
+ translated_attribute current_component.name
62
+ end
63
+
64
+ def component_type_name
65
+ model.class.model_name.human
66
+ end
67
+
68
+ def participatory_space_name
69
+ translated_attribute current_participatory_space.title
70
+ end
71
+
72
+ def participatory_space_type_name
73
+ translated_attribute current_participatory_space.model_name.human
74
+ end
75
+ end
76
+ end
77
+ end
@@ -11,8 +11,6 @@ module Decidim
11
11
  include Cell::ViewModel::Partial
12
12
  include Messaging::ConversationHelper
13
13
 
14
- delegate :user_signed_in?, to: :parent_controller
15
-
16
14
  def show
17
15
  cell card_size, model, options
18
16
  end
@@ -14,7 +14,7 @@
14
14
  ) %>
15
15
  <% end %>
16
16
  <%= render partial: "decidim/proposals/proposals/vote_button.html", locals: { proposal: model, from_proposals_list: true } %>
17
- <% else %>
17
+ <% elsif has_footer? %>
18
18
  <div class="card__support__data"></div>
19
19
  <%= link_to t("decidim.proposals.proposals.proposal.view_proposal"), resource_path, class: "card__button button--sc light button small secondary" %>
20
20
  <% end %>
@@ -27,13 +27,18 @@ module Decidim
27
27
  end
28
28
 
29
29
  def has_badge?
30
- answered? || withdrawn?
30
+ answered? || withdrawn? || emendation?
31
31
  end
32
32
 
33
33
  def has_link_to_resource?
34
34
  model.published?
35
35
  end
36
36
 
37
+ def has_footer?
38
+ return false if model.emendation?
39
+ true
40
+ end
41
+
37
42
  def description
38
43
  truncate(present(model).body, length: 100)
39
44
  end
@@ -45,12 +45,12 @@ module Decidim
45
45
  private
46
46
 
47
47
  def notify_collaborative_draft_authors
48
- recipient_ids = @collaborative_draft.authors.pluck(:id) - [@requester_user.id]
48
+ affected_users = @collaborative_draft.notifiable_identities - [@requester_user]
49
49
  Decidim::EventsManager.publish(
50
50
  event: "decidim.events.proposals.collaborative_draft_access_accepted",
51
51
  event_class: Decidim::Proposals::CollaborativeDraftAccessAcceptedEvent,
52
52
  resource: @collaborative_draft,
53
- recipient_ids: recipient_ids.uniq,
53
+ affected_users: affected_users.uniq,
54
54
  extra: {
55
55
  requester_id: @requester_user.id
56
56
  }
@@ -62,7 +62,7 @@ module Decidim
62
62
  event: "decidim.events.proposals.collaborative_draft_access_requester_accepted",
63
63
  event_class: Decidim::Proposals::CollaborativeDraftAccessRequesterAcceptedEvent,
64
64
  resource: @collaborative_draft,
65
- recipient_ids: [@requester_user.id]
65
+ affected_users: [@requester_user]
66
66
  )
67
67
  end
68
68
  end
@@ -74,7 +74,8 @@ module Decidim
74
74
  event: event,
75
75
  event_class: event_class,
76
76
  resource: proposal,
77
- recipient_ids: proposal.followers.pluck(:id)
77
+ affected_users: proposal.notifiable_identities,
78
+ followers: proposal.followers - proposal.notifiable_identities
78
79
  )
79
80
  end
80
81
 
@@ -5,6 +5,8 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when a user creates a new proposal.
7
7
  class CreateProposal < Rectify::Command
8
+ include HashtagsMethods
9
+
8
10
  # Public: Initializes the command.
9
11
  #
10
12
  # form - A form object with the params.
@@ -42,24 +44,22 @@ module Decidim
42
44
  def create_proposal
43
45
  @proposal = Decidim::Proposals::ProposalBuilder.create(
44
46
  attributes: attributes,
45
- author: form.current_organization,
47
+ author: form.author,
46
48
  action_user: form.current_user
47
49
  )
48
50
  end
49
51
 
50
52
  def attributes
51
- parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
52
- parsed_body = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.body, current_organization: form.current_organization).rewrite
53
-
54
53
  {
55
- title: parsed_title,
56
- body: parsed_body,
54
+ title: title_with_hashtags,
55
+ body: body_with_hashtags,
57
56
  category: form.category,
58
57
  scope: form.scope,
59
58
  component: form.component,
60
59
  address: form.address,
61
60
  latitude: form.latitude,
62
61
  longitude: form.longitude,
62
+ created_in_meeting: form.created_in_meeting,
63
63
  published_at: Time.current
64
64
  }
65
65
  end
@@ -101,7 +101,7 @@ module Decidim
101
101
  event: "decidim.events.proposals.proposal_published",
102
102
  event_class: Decidim::Proposals::PublishProposalEvent,
103
103
  resource: proposal,
104
- recipient_ids: @proposal.participatory_space.followers.pluck(:id),
104
+ followers: @proposal.participatory_space.followers,
105
105
  extra: {
106
106
  participatory_space: true
107
107
  }
@@ -20,11 +20,11 @@ module Decidim
20
20
  #
21
21
  # Returns nothing.
22
22
  def call
23
- return broadcast(:invalid) unless form.valid?
23
+ return broadcast(:invalid) unless @form.valid?
24
24
 
25
25
  transaction do
26
- save_participatory_text(form)
27
- parse_participatory_text_doc(form.document_text)
26
+ save_participatory_text_meta(@form)
27
+ parse_participatory_text_doc(@form)
28
28
  end
29
29
 
30
30
  broadcast(:ok)
@@ -32,16 +32,16 @@ module Decidim
32
32
 
33
33
  private
34
34
 
35
- attr_reader :form
36
-
37
- def save_participatory_text(form)
35
+ # Persist ParticipatoryText related meta information.
36
+ def save_participatory_text_meta(form)
38
37
  document = ParticipatoryText.find_or_initialize_by(component: form.current_component)
39
38
  document.update!(title: form.title, description: form.description)
40
39
  end
41
40
 
42
- def parse_participatory_text_doc(document)
41
+ def parse_participatory_text_doc(form)
42
+ markdown = DocToMarkdown.new(form.document_text, form.document_type).to_md
43
43
  parser = MarkdownToProposals.new(form.current_component, form.current_user)
44
- parser.parse(document)
44
+ parser.parse(markdown)
45
45
  end
46
46
  end
47
47
  end