decidim-proposals 0.26.10 → 0.27.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) 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/highlighted_proposals_for_component_cell.rb +9 -1
  4. data/app/cells/decidim/proposals/proposal_m_cell.rb +6 -8
  5. data/app/commands/decidim/proposals/accept_access_to_collaborative_draft.rb +1 -1
  6. data/app/commands/decidim/proposals/admin/answer_proposal.rb +1 -1
  7. data/app/commands/decidim/proposals/admin/assign_proposals_to_valuator.rb +1 -1
  8. data/app/commands/decidim/proposals/admin/create_proposal.rb +10 -7
  9. data/app/commands/decidim/proposals/admin/create_proposal_note.rb +2 -2
  10. data/app/commands/decidim/proposals/admin/discard_participatory_text.rb +1 -1
  11. data/app/commands/decidim/proposals/admin/import_participatory_text.rb +1 -1
  12. data/app/commands/decidim/proposals/admin/import_proposals.rb +2 -5
  13. data/app/commands/decidim/proposals/admin/merge_proposals.rb +1 -1
  14. data/app/commands/decidim/proposals/admin/notify_proposal_answer.rb +1 -3
  15. data/app/commands/decidim/proposals/admin/publish_answers.rb +1 -1
  16. data/app/commands/decidim/proposals/admin/split_proposals.rb +1 -1
  17. data/app/commands/decidim/proposals/admin/unassign_proposals_from_valuator.rb +1 -1
  18. data/app/commands/decidim/proposals/admin/update_participatory_text.rb +1 -1
  19. data/app/commands/decidim/proposals/admin/update_proposal.rb +8 -2
  20. data/app/commands/decidim/proposals/admin/update_proposal_category.rb +5 -3
  21. data/app/commands/decidim/proposals/admin/update_proposal_scope.rb +3 -3
  22. data/app/commands/decidim/proposals/create_collaborative_draft.rb +5 -5
  23. data/app/commands/decidim/proposals/create_proposal.rb +1 -1
  24. data/app/commands/decidim/proposals/destroy_proposal.rb +1 -1
  25. data/app/commands/decidim/proposals/publish_collaborative_draft.rb +1 -1
  26. data/app/commands/decidim/proposals/publish_proposal.rb +1 -1
  27. data/app/commands/decidim/proposals/reject_access_to_collaborative_draft.rb +1 -1
  28. data/app/commands/decidim/proposals/request_access_to_collaborative_draft.rb +1 -1
  29. data/app/commands/decidim/proposals/unvote_proposal.rb +1 -1
  30. data/app/commands/decidim/proposals/update_collaborative_draft.rb +1 -1
  31. data/app/commands/decidim/proposals/update_proposal.rb +8 -2
  32. data/app/commands/decidim/proposals/vote_proposal.rb +1 -1
  33. data/app/commands/decidim/proposals/withdraw_collaborative_draft.rb +1 -1
  34. data/app/commands/decidim/proposals/withdraw_proposal.rb +1 -1
  35. data/app/controllers/concerns/decidim/proposals/orderable.rb +7 -5
  36. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +7 -7
  37. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +10 -10
  38. data/app/controllers/decidim/proposals/proposal_votes_controller.rb +1 -1
  39. data/app/controllers/decidim/proposals/proposals_controller.rb +25 -18
  40. data/app/events/decidim/proposals/publish_proposal_event.rb +0 -8
  41. data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +4 -4
  42. data/app/forms/decidim/proposals/admin/proposal_base_form.rb +4 -4
  43. data/app/forms/decidim/proposals/admin/proposal_form.rb +2 -0
  44. data/app/forms/decidim/proposals/admin/proposals_fork_form.rb +2 -2
  45. data/app/forms/decidim/proposals/admin/proposals_import_form.rb +1 -1
  46. data/app/forms/decidim/proposals/proposal_form.rb +11 -4
  47. data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +3 -0
  48. data/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb +4 -0
  49. data/app/helpers/decidim/proposals/application_helper.rb +4 -17
  50. data/app/helpers/decidim/proposals/proposal_cells_helper.rb +1 -3
  51. data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +7 -7
  52. data/app/helpers/decidim/proposals/proposals_helper.rb +1 -1
  53. data/app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb +1 -1
  54. data/app/models/decidim/proposals/collaborative_draft.rb +10 -0
  55. data/app/models/decidim/proposals/collaborative_draft_collaborator_request.rb +0 -2
  56. data/app/models/decidim/proposals/proposal.rb +47 -8
  57. data/app/queries/decidim/proposals/filtered_proposals.rb +1 -1
  58. data/app/queries/decidim/proposals/similar_proposals.rb +1 -1
  59. data/app/services/decidim/proposals/proposal_search.rb +16 -71
  60. data/app/validators/proposal_length_validator.rb +2 -5
  61. data/app/views/decidim/proposals/admin/participatory_texts/_article-preview.html.erb +2 -2
  62. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +1 -1
  63. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +2 -2
  64. data/app/views/decidim/proposals/admin/proposals/edit.html.erb +0 -1
  65. data/app/views/decidim/proposals/admin/proposals/index.html.erb +0 -1
  66. data/app/views/decidim/proposals/admin/proposals/new.html.erb +0 -1
  67. data/app/views/decidim/proposals/admin/proposals/publish_answers.js.erb +1 -1
  68. data/app/views/decidim/proposals/admin/proposals/show.html.erb +0 -1
  69. data/app/views/decidim/proposals/admin/proposals/update_attribute.js.erb +26 -0
  70. data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +9 -17
  71. data/app/views/decidim/proposals/collaborative_drafts/_filters.html.erb +4 -4
  72. data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +1 -1
  73. data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +3 -1
  74. data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +3 -1
  75. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -1
  76. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +13 -36
  77. data/app/views/decidim/proposals/proposals/_filters.html.erb +5 -5
  78. data/app/views/decidim/proposals/proposals/_linked_proposals.html.erb +1 -2
  79. data/app/views/decidim/proposals/proposals/_proposals.html.erb +5 -5
  80. data/app/views/decidim/proposals/proposals/complete.html.erb +3 -1
  81. data/app/views/decidim/proposals/proposals/edit.html.erb +3 -1
  82. data/app/views/decidim/proposals/proposals/edit_draft.html.erb +3 -1
  83. data/app/views/decidim/proposals/proposals/new.html.erb +3 -1
  84. data/config/locales/am-ET.yml +1 -0
  85. data/config/locales/ar.yml +4 -262
  86. data/config/locales/bg.yml +1 -19
  87. data/config/locales/ca.yml +19 -31
  88. data/config/locales/cs.yml +34 -46
  89. data/config/locales/da.yml +1 -0
  90. data/config/locales/de.yml +10 -107
  91. data/config/locales/el.yml +5 -146
  92. data/config/locales/en.yml +12 -25
  93. data/config/locales/eo.yml +1 -0
  94. data/config/locales/es-MX.yml +20 -32
  95. data/config/locales/es-PY.yml +20 -32
  96. data/config/locales/es.yml +15 -27
  97. data/config/locales/et.yml +1 -0
  98. data/config/locales/eu.yml +283 -343
  99. data/config/locales/fi-plain.yml +17 -28
  100. data/config/locales/fi.yml +21 -32
  101. data/config/locales/fr-CA.yml +19 -32
  102. data/config/locales/fr.yml +31 -44
  103. data/config/locales/ga-IE.yml +1 -2
  104. data/config/locales/gl.yml +16 -13
  105. data/config/locales/hr.yml +1 -0
  106. data/config/locales/hu.yml +13 -64
  107. data/config/locales/id-ID.yml +5 -19
  108. data/config/locales/is-IS.yml +8 -17
  109. data/config/locales/it.yml +12 -18
  110. data/config/locales/ja.yml +67 -79
  111. data/config/locales/ko.yml +1 -0
  112. data/config/locales/lb.yml +1 -0
  113. data/config/locales/lt.yml +1 -1007
  114. data/config/locales/lv.yml +5 -17
  115. data/config/locales/mt.yml +1 -0
  116. data/config/locales/nl.yml +15 -20
  117. data/config/locales/no.yml +6 -11
  118. data/config/locales/om-ET.yml +1 -0
  119. data/config/locales/pl.yml +5 -28
  120. data/config/locales/pt-BR.yml +6 -33
  121. data/config/locales/pt.yml +6 -13
  122. data/config/locales/ro-RO.yml +9 -9
  123. data/config/locales/ru.yml +8 -16
  124. data/config/locales/si-LK.yml +1 -0
  125. data/config/locales/sk.yml +6 -18
  126. data/config/locales/sl.yml +4 -0
  127. data/config/locales/so-SO.yml +1 -0
  128. data/config/locales/sr-CS.yml +1 -2
  129. data/config/locales/sv.yml +12 -12
  130. data/config/locales/sw-KE.yml +1 -0
  131. data/config/locales/ti-ER.yml +1 -0
  132. data/config/locales/tr-TR.yml +7 -14
  133. data/config/locales/uk.yml +8 -16
  134. data/config/locales/val-ES.yml +1 -0
  135. data/config/locales/vi.yml +1 -0
  136. data/config/locales/zh-CN.yml +5 -16
  137. data/config/locales/zh-TW.yml +1 -964
  138. data/db/migrate/20180529110230_move_authorships_to_coauthorships.rb +1 -0
  139. data/db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb +2 -9
  140. data/db/migrate/20200708091228_move_proposals_fields_to_i18n.rb +18 -28
  141. data/db/migrate/20201002085508_fix_proposals_data.rb +13 -25
  142. data/lib/decidim/proposals/component.rb +25 -21
  143. data/lib/decidim/proposals/engine.rb +0 -6
  144. data/lib/decidim/proposals/import/proposal_answer_creator.rb +4 -10
  145. data/lib/decidim/proposals/proposal_serializer.rb +1 -9
  146. data/lib/decidim/proposals/test/factories.rb +1 -1
  147. data/lib/decidim/proposals/version.rb +1 -1
  148. metadata +25 -52
  149. data/app/services/decidim/proposals/collaborative_draft_search.rb +0 -59
  150. data/app/views/decidim/proposals/admin/proposals/_js-callout.html.erb +0 -6
  151. data/app/views/decidim/proposals/admin/proposals/update_category.js.erb +0 -26
  152. data/app/views/decidim/proposals/admin/proposals/update_scope.js.erb +0 -27
  153. data/config/environment.rb +0 -3
  154. data/config/locales/fa-IR.yml +0 -1
  155. data/config/locales/gn-PY.yml +0 -1
  156. data/config/locales/ka-GE.yml +0 -1
  157. data/config/locales/kaa.yml +0 -1
  158. data/config/locales/lo-LA.yml +0 -1
  159. data/config/locales/oc-FR.yml +0 -1
  160. data/config/locales/sq-AL.yml +0 -1
  161. data/config/locales/th-TH.yml +0 -1
  162. data/lib/tasks/proposals/upgrade/decdim_proposal_upgrade_tasks.rake +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e101137e1dab45f7db4800b65cbc6c4876da84527070874e90e8493e679e42ab
4
- data.tar.gz: 291d57eb48bf0a681395a9b81dab330fea4f8aff38401bf75dc9c38e96473150
3
+ metadata.gz: cf760d1ce319c8806519053c5b3bfe6d48aaa1d91b11f81c0e7fde8b4d6398e4
4
+ data.tar.gz: 12707f653b6cca47f62a8f34c8204dc8de6a1078fa681a2dd68b6ef89cafb979
5
5
  SHA512:
6
- metadata.gz: 4175e5d0a23e692450b00fac603472b61f9d440f9e0ae4becf71c0d2def320ec62ff96ff2121bc3087d8cf0c2c6ac4f5854c4e6f458b86809c6117322a0fde05
7
- data.tar.gz: 4aa1de838049aeb09797d4ad29462a2d95ecda7f80e6780c4b1a44bb11cfaaac7f0e3af09e02816c8b436f8ccb142f5e3451722601f36f5ec3cd8b6c5cd51fea
6
+ metadata.gz: 55cd9f8ec704001e24cc90dc1d0be2a4153e4a1f2d003b68793924b91e0ffce786726b13e91664304b9dea9d26b2b18c844e9cd1e894962b1762a3a55004136f
7
+ data.tar.gz: b2f3f6e9760b568fbcee9d4e1cbc0ae724b16430731719c743bf90d8424600724a340aaa5d9788fb4a191a17f08f997c3011d3476bf9fabde5ac35602e726e70
@@ -23,7 +23,7 @@ module Decidim
23
23
  end
24
24
 
25
25
  def description
26
- decidim_sanitize_editor(present(model).body.truncate(100, separator: /\s/), strip_tags: true)
26
+ decidim_sanitize_editor(present(model).body.truncate(100, separator: /\s/))
27
27
  end
28
28
 
29
29
  def has_badge?
@@ -19,7 +19,7 @@ module Decidim
19
19
  def proposals
20
20
  @proposals ||= Decidim::Proposals::Proposal.published.not_hidden.except_withdrawn
21
21
  .where(component: model)
22
- .order_randomly(rand * 2 - 1)
22
+ .order_randomly((rand * 2) - 1)
23
23
  end
24
24
 
25
25
  def proposals_to_render
@@ -29,6 +29,14 @@ module Decidim
29
29
  def proposals_count
30
30
  @proposals_count ||= proposals.count
31
31
  end
32
+
33
+ def cache_hash
34
+ hash = []
35
+ hash << "decidim/proposals/highlighted_proposals_for_component"
36
+ hash << proposals.cache_key_with_version
37
+ hash << I18n.locale.to_s
38
+ hash.join(Decidim.cache_key_separator)
39
+ end
32
40
  end
33
41
  end
34
42
  end
@@ -21,7 +21,7 @@ module Decidim
21
21
  end
22
22
 
23
23
  def title
24
- present(model).title(html_escape: true)
24
+ decidim_html_escape(present(model).title)
25
25
  end
26
26
 
27
27
  def body
@@ -57,13 +57,11 @@ module Decidim
57
57
  end
58
58
 
59
59
  def base_statuses
60
- @base_statuses ||= begin
61
- if endorsements_visible?
62
- [:endorsements_count, :comments_count]
63
- else
64
- [:comments_count]
65
- end
66
- end
60
+ @base_statuses ||= if endorsements_visible?
61
+ [:endorsements_count, :comments_count]
62
+ else
63
+ [:comments_count]
64
+ end
67
65
  end
68
66
 
69
67
  def statuses
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic to accept a user request to
6
6
  # contribute to a collaborative draft.
7
- class AcceptAccessToCollaborativeDraft < Rectify::Command
7
+ class AcceptAccessToCollaborativeDraft < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A form object with the params.
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  module Admin
6
6
  # A command with all the business logic when an admin answers a proposal.
7
- class AnswerProposal < Rectify::Command
7
+ class AnswerProposal < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A form object with the params.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic to assign proposals to a given
7
7
  # valuator.
8
- class AssignProposalsToValuator < Rectify::Command
8
+ class AssignProposalsToValuator < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  module Admin
6
6
  # A command with all the business logic when a user creates a new proposal.
7
- class CreateProposal < Rectify::Command
7
+ class CreateProposal < Decidim::Command
8
8
  include ::Decidim::AttachmentMethods
9
9
  include GalleryMethods
10
10
  include HashtagsMethods
@@ -37,13 +37,12 @@ module Decidim
37
37
 
38
38
  transaction do
39
39
  create_proposal
40
- create_attachment if process_attachments?
41
40
  create_gallery if process_gallery?
41
+ create_attachment(weight: first_attachment_weight) if process_attachments?
42
42
  link_author_meeeting if form.created_in_meeting?
43
+ send_notification
43
44
  end
44
45
 
45
- send_notification
46
-
47
46
  broadcast(:ok, proposal)
48
47
  end
49
48
 
@@ -82,18 +81,22 @@ module Decidim
82
81
  end
83
82
 
84
83
  def send_notification
85
- return unless proposal
86
-
87
84
  Decidim::EventsManager.publish(
88
85
  event: "decidim.events.proposals.proposal_published",
89
86
  event_class: Decidim::Proposals::PublishProposalEvent,
90
87
  resource: proposal,
91
- followers: proposal.participatory_space.followers,
88
+ followers: @proposal.participatory_space.followers,
92
89
  extra: {
93
90
  participatory_space: true
94
91
  }
95
92
  )
96
93
  end
94
+
95
+ def first_attachment_weight
96
+ return 1 if proposal.photos.count.zero?
97
+
98
+ proposal.photos.count
99
+ end
97
100
  end
98
101
  end
99
102
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  module Admin
6
6
  # A command with all the business logic when an admin creates a private note proposal.
7
- class CreateProposalNote < Rectify::Command
7
+ class CreateProposalNote < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A form object with the params.
@@ -59,7 +59,7 @@ module Decidim
59
59
  affected_users: affected_users
60
60
  }
61
61
 
62
- Decidim::EventsManager.publish(data)
62
+ Decidim::EventsManager.publish(**data)
63
63
  end
64
64
  end
65
65
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  module Admin
6
6
  # A command with all the business logic related with an admin discarding participatory text proposals.
7
- class DiscardParticipatoryText < Rectify::Command
7
+ class DiscardParticipatoryText < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A PreviewParticipatoryTextForm form object with the params.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when an admin imports proposals from
7
7
  # a participatory text.
8
- class ImportParticipatoryText < Rectify::Command
8
+ class ImportParticipatoryText < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when an admin imports proposals from
7
7
  # one component to another.
8
- class ImportProposals < Rectify::Command
8
+ class ImportProposals < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -76,10 +76,7 @@ module Decidim
76
76
  end
77
77
 
78
78
  def proposal_already_copied?(original_proposal, target_component)
79
- # Note: we are including also proposals from unpublished components
80
- # because otherwise duplicates could be created until the component is
81
- # published.
82
- original_proposal.linked_resources(:proposals, "copied_from_component", component_published: false).any? do |proposal|
79
+ original_proposal.linked_resources(:proposals, "copied_from_component").any? do |proposal|
83
80
  proposal.component == target_component
84
81
  end
85
82
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when an admin merges proposals from
7
7
  # one component to another.
8
- class MergeProposals < Rectify::Command
8
+ class MergeProposals < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  module Admin
6
6
  # A command to notify about the change of the published state for a proposal.
7
- class NotifyProposalAnswer < Rectify::Command
7
+ class NotifyProposalAnswer < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # proposal - The proposal to write the answer for.
@@ -21,8 +21,6 @@ module Decidim
21
21
  #
22
22
  # Returns nothing.
23
23
  def call
24
- return broadcast(:invalid) if proposal.blank?
25
-
26
24
  if proposal.published_state? && state_changed?
27
25
  transaction do
28
26
  increment_score
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  module Admin
6
6
  # A command with all the business logic to publish many answers at once.
7
- class PublishAnswers < Rectify::Command
7
+ class PublishAnswers < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # component - The component that contains the answers.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when an admin splits proposals from
7
7
  # one component to another.
8
- class SplitProposals < Rectify::Command
8
+ class SplitProposals < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic to unassign proposals from a given
7
7
  # valuator.
8
- class UnassignProposalsFromValuator < Rectify::Command
8
+ class UnassignProposalsFromValuator < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  module Admin
6
6
  # A command with all the business logic when an admin updates participatory text proposals.
7
- class UpdateParticipatoryText < Rectify::Command
7
+ class UpdateParticipatoryText < Decidim::Command
8
8
  include Decidim::TranslatableAttributes
9
9
 
10
10
  # Public: Initializes the command.
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  module Admin
6
6
  # A command with all the business logic when a user updates a proposal.
7
- class UpdateProposal < Rectify::Command
7
+ class UpdateProposal < Decidim::Command
8
8
  include ::Decidim::AttachmentMethods
9
9
  include GalleryMethods
10
10
  include HashtagsMethods
@@ -45,8 +45,8 @@ module Decidim
45
45
  transaction do
46
46
  update_proposal
47
47
  update_proposal_author
48
- create_attachment if process_attachments?
49
48
  create_gallery if process_gallery?
49
+ create_attachment(weight: first_attachment_weight) if process_attachments?
50
50
  photo_cleanup!
51
51
  end
52
52
 
@@ -80,6 +80,12 @@ module Decidim
80
80
  proposal.save!
81
81
  proposal
82
82
  end
83
+
84
+ def first_attachment_weight
85
+ return 1 if proposal.photos.count.zero?
86
+
87
+ proposal.photos.count
88
+ end
83
89
  end
84
90
  end
85
91
  end
@@ -4,7 +4,9 @@ module Decidim
4
4
  module Proposals
5
5
  module Admin
6
6
  # A command with all the business logic when an admin batch updates proposals category.
7
- class UpdateProposalCategory < Rectify::Command
7
+ class UpdateProposalCategory < Decidim::Command
8
+ include TranslatableAttributes
9
+
8
10
  # Public: Initializes the command.
9
11
  #
10
12
  # category_id - the category id to update
@@ -33,13 +35,13 @@ module Decidim
33
35
  @response[:category_name] = @category.translated_name
34
36
  Proposal.where(id: @proposal_ids).find_each do |proposal|
35
37
  if @category == proposal.category
36
- @response[:errored] << proposal.title
38
+ @response[:errored] << translated_attribute(proposal.title)
37
39
  else
38
40
  transaction do
39
41
  update_proposal_category proposal
40
42
  notify_author proposal if proposal.coauthorships.any?
41
43
  end
42
- @response[:successful] << proposal.title
44
+ @response[:successful] << translated_attribute(proposal.title)
43
45
  end
44
46
  end
45
47
 
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  module Admin
6
6
  # A command with all the business logic when an admin batch updates proposals scope.
7
- class UpdateProposalScope < Rectify::Command
7
+ class UpdateProposalScope < Decidim::Command
8
8
  include TranslatableAttributes
9
9
  # Public: Initializes the command.
10
10
  #
@@ -44,13 +44,13 @@ module Decidim
44
44
  @response[:scope_name] = translated_attribute(scope.name, scope.organization)
45
45
  Proposal.where(id: proposal_ids).find_each do |proposal|
46
46
  if scope == proposal.scope
47
- @response[:errored] << proposal.title
47
+ @response[:errored] << translated_attribute(proposal.title)
48
48
  else
49
49
  transaction do
50
50
  update_proposal_scope proposal
51
51
  notify_author proposal if proposal.coauthorships.any?
52
52
  end
53
- @response[:successful] << proposal.title
53
+ @response[:successful] << translated_attribute(proposal.title)
54
54
  end
55
55
  end
56
56
  end
@@ -3,8 +3,8 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user creates a new collaborative draft.
6
- class CreateCollaborativeDraft < Rectify::Command
7
- include ::Decidim::AttachmentMethods
6
+ class CreateCollaborativeDraft < Decidim::Command
7
+ include ::Decidim::MultipleAttachmentsMethods
8
8
  include HashtagsMethods
9
9
 
10
10
  # Public: Initializes the command.
@@ -27,13 +27,13 @@ module Decidim
27
27
  return broadcast(:invalid) if form.invalid?
28
28
 
29
29
  if process_attachments?
30
- build_attachment
31
- return broadcast(:invalid) if attachment_invalid?
30
+ build_attachments
31
+ return broadcast(:invalid) if attachments_invalid?
32
32
  end
33
33
 
34
34
  transaction do
35
35
  create_collaborative_draft
36
- create_attachment if process_attachments?
36
+ create_attachments if process_attachments?
37
37
  end
38
38
 
39
39
  broadcast(:ok, collaborative_draft)
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user creates a new proposal.
6
- class CreateProposal < Rectify::Command
6
+ class CreateProposal < Decidim::Command
7
7
  include ::Decidim::AttachmentMethods
8
8
  include HashtagsMethods
9
9
 
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user destroys a draft proposal.
6
- class DestroyProposal < Rectify::Command
6
+ class DestroyProposal < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # proposal - The proposal to destroy.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user publishes a collaborative_draft.
6
- class PublishCollaborativeDraft < Rectify::Command
6
+ class PublishCollaborativeDraft < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # collaborative_draft - The collaborative_draft to publish.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user publishes a draft proposal.
6
- class PublishProposal < Rectify::Command
6
+ class PublishProposal < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # proposal - The proposal to publish.
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic to reject a user request to
6
6
  # contribute to a collaborative draft.
7
- class RejectAccessToCollaborativeDraft < Rectify::Command
7
+ class RejectAccessToCollaborativeDraft < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A form object with the params.
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user requests access
6
6
  # to edit a collaborative draft.
7
- class RequestAccessToCollaborativeDraft < Rectify::Command
7
+ class RequestAccessToCollaborativeDraft < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A form object with the params.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user unvotes a proposal.
6
- class UnvoteProposal < Rectify::Command
6
+ class UnvoteProposal < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # proposal - A Decidim::Proposals::Proposal object.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user updates a collaborative_draft.
6
- class UpdateCollaborativeDraft < Rectify::Command
6
+ class UpdateCollaborativeDraft < Decidim::Command
7
7
  include HashtagsMethods
8
8
 
9
9
  # Public: Initializes the command.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user updates a proposal.
6
- class UpdateProposal < Rectify::Command
6
+ class UpdateProposal < Decidim::Command
7
7
  include ::Decidim::MultipleAttachmentsMethods
8
8
  include GalleryMethods
9
9
  include HashtagsMethods
@@ -50,7 +50,7 @@ module Decidim
50
50
  document_cleanup!
51
51
 
52
52
  create_gallery if process_gallery?
53
- create_attachments if process_attachments?
53
+ create_attachments(first_weight: first_attachment_weight) if process_attachments?
54
54
  end
55
55
 
56
56
  broadcast(:ok, proposal)
@@ -116,6 +116,12 @@ module Decidim
116
116
  end
117
117
  end
118
118
 
119
+ def first_attachment_weight
120
+ return 1 if proposal.photos.count.zero?
121
+
122
+ proposal.photos.count
123
+ end
124
+
119
125
  def user_group
120
126
  @user_group ||= Decidim::UserGroup.find_by(organization: organization, id: form.user_group_id)
121
127
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user votes a proposal.
6
- class VoteProposal < Rectify::Command
6
+ class VoteProposal < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # proposal - A Decidim::Proposals::Proposal object.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user withdraws a collaborative_draft.
6
- class WithdrawCollaborativeDraft < Rectify::Command
6
+ class WithdrawCollaborativeDraft < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # collaborative_draft - The collaborative_draft to withdraw.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user withdraws a new proposal.
6
- class WithdrawProposal < Rectify::Command
6
+ class WithdrawProposal < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # proposal - The proposal to withdraw.
@@ -30,12 +30,14 @@ module Decidim
30
30
  end
31
31
 
32
32
  def default_order
33
- @default_order ||= begin
34
- default_order = current_settings.default_sort_order.presence || component_settings.default_sort_order
35
- return order_by_default if default_order == "default"
33
+ @default_order ||= fetch_default_order
34
+ end
36
35
 
37
- possible_orders.include?(default_order) ? default_order : order_by_default
38
- end
36
+ def fetch_default_order
37
+ default_order = current_settings.default_sort_order.presence || component_settings.default_sort_order
38
+ return order_by_default if default_order == "default"
39
+
40
+ possible_orders.include?(default_order) ? default_order : order_by_default
39
41
  end
40
42
 
41
43
  def order_by_default
@@ -65,9 +65,10 @@ module Decidim
65
65
  flash.now[:notice] = update_proposals_bulk_response_successful(@response, :category)
66
66
  flash.now[:alert] = update_proposals_bulk_response_errored(@response, :category)
67
67
  end
68
- respond_to do |format|
69
- format.js
70
- end
68
+ end
69
+
70
+ respond_to do |format|
71
+ format.js { render :update_attribute, locals: { form_selector: "#js-form-recategorize-projects", attribute_selector: "#category_id" } }
71
72
  end
72
73
  end
73
74
 
@@ -114,10 +115,9 @@ module Decidim
114
115
  flash.now[:notice] = update_proposals_bulk_response_successful(@response, :scope)
115
116
  flash.now[:alert] = update_proposals_bulk_response_errored(@response, :scope)
116
117
  end
117
-
118
- respond_to do |format|
119
- format.js
120
- end
118
+ end
119
+ respond_to do |format|
120
+ format.js { render :update_attribute, locals: { form_selector: "#js-form-scope-change-projects", attribute_selector: "#scope_id" } }
121
121
  end
122
122
  end
123
123
 
@@ -25,13 +25,13 @@ module Decidim
25
25
 
26
26
  def index
27
27
  @collaborative_drafts = search
28
- .results
28
+ .result
29
29
  .not_hidden
30
30
  .includes(:category)
31
31
  .includes(:scope)
32
32
 
33
- @collaborative_drafts = reorder(@collaborative_drafts)
34
33
  @collaborative_drafts = paginate(@collaborative_drafts)
34
+ @collaborative_drafts = reorder(@collaborative_drafts)
35
35
  end
36
36
 
37
37
  def show
@@ -63,7 +63,7 @@ module Decidim
63
63
 
64
64
  on(:invalid) do
65
65
  flash.now[:alert] = I18n.t("proposals.collaborative_drafts.create.error", scope: "decidim")
66
- render :new
66
+ render :complete
67
67
  end
68
68
  end
69
69
  end
@@ -134,19 +134,19 @@ module Decidim
134
134
  end
135
135
 
136
136
  def geocoded_collaborative_draft
137
- @geocoded_collaborative_draft ||= search.results.not_hidden.select(&:geocoded_and_valid?)
137
+ @geocoded_collaborative_draft ||= search.result.not_hidden.select(&:geocoded_and_valid?)
138
138
  end
139
139
 
140
- def search_klass
141
- CollaborativeDraftSearch
140
+ def search_collection
141
+ CollaborativeDraft.where(component: current_component).not_hidden
142
142
  end
143
143
 
144
144
  def default_filter_params
145
145
  {
146
- search_text: "",
147
- category_id: default_filter_category_params,
148
- state: %w(open),
149
- scope_id: default_filter_scope_params,
146
+ search_text_cont: "",
147
+ with_any_category: default_filter_category_params,
148
+ with_any_state: %w(open),
149
+ with_any_scope: default_filter_scope_params,
150
150
  related_to: ""
151
151
  }
152
152
  end