decidim-initiatives 0.26.0 → 0.27.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +1 -1
  4. data/app/cells/decidim/initiatives/initiative_m/footer.erb +1 -1
  5. data/app/cells/decidim/initiatives/initiative_m/tags.erb +1 -1
  6. data/app/cells/decidim/initiatives/initiative_m_cell.rb +1 -0
  7. data/app/commands/decidim/initiatives/admin/create_initiative_type.rb +7 -3
  8. data/app/commands/decidim/initiatives/admin/create_initiative_type_scope.rb +3 -3
  9. data/app/commands/decidim/initiatives/admin/publish_initiative.rb +1 -1
  10. data/app/commands/decidim/initiatives/admin/send_initiative_to_technical_validation.rb +2 -2
  11. data/app/commands/decidim/initiatives/admin/unpublish_initiative.rb +1 -1
  12. data/app/commands/decidim/initiatives/admin/update_initiative.rb +1 -1
  13. data/app/commands/decidim/initiatives/admin/update_initiative_answer.rb +1 -1
  14. data/app/commands/decidim/initiatives/admin/update_initiative_type.rb +19 -14
  15. data/app/commands/decidim/initiatives/admin/update_initiative_type_scope.rb +1 -1
  16. data/app/commands/decidim/initiatives/admin/update_initiatives_settings.rb +46 -0
  17. data/app/commands/decidim/initiatives/approve_membership_request.rb +1 -1
  18. data/app/commands/decidim/initiatives/create_initiative.rb +1 -1
  19. data/app/commands/decidim/initiatives/revoke_membership_request.rb +1 -1
  20. data/app/commands/decidim/initiatives/send_initiative_to_technical_validation.rb +2 -2
  21. data/app/commands/decidim/initiatives/spawn_committee_request.rb +1 -1
  22. data/app/commands/decidim/initiatives/unvote_initiative.rb +1 -1
  23. data/app/commands/decidim/initiatives/update_initiative.rb +1 -1
  24. data/app/commands/decidim/initiatives/validate_mobile_phone.rb +1 -1
  25. data/app/commands/decidim/initiatives/validate_sms_code.rb +1 -1
  26. data/app/commands/decidim/initiatives/vote_initiative.rb +2 -6
  27. data/app/controllers/concerns/decidim/initiatives/orderable.rb +8 -0
  28. data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +3 -7
  29. data/app/controllers/decidim/initiatives/admin/initiatives_settings_controller.rb +49 -0
  30. data/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb +6 -3
  31. data/app/controllers/decidim/initiatives/committee_requests_controller.rb +1 -1
  32. data/app/controllers/decidim/initiatives/create_initiative_controller.rb +2 -2
  33. data/app/controllers/decidim/initiatives/initiatives_controller.rb +18 -22
  34. data/app/forms/decidim/initiatives/admin/initiative_form.rb +23 -23
  35. data/app/forms/decidim/initiatives/admin/initiative_type_form.rb +2 -1
  36. data/app/forms/decidim/initiatives/admin/initiatives_settings_form.rb +14 -0
  37. data/app/forms/decidim/initiatives/vote_form.rb +0 -3
  38. data/app/helpers/decidim/initiatives/create_initiative_helper.rb +3 -3
  39. data/app/helpers/decidim/initiatives/initiative_helper.rb +6 -4
  40. data/app/mailers/decidim/initiatives/initiatives_mailer.rb +2 -2
  41. data/app/models/decidim/initiative.rb +64 -15
  42. data/app/models/decidim/initiatives_settings.rb +17 -0
  43. data/app/models/decidim/initiatives_type.rb +5 -0
  44. data/app/permissions/decidim/initiatives/admin/permissions.rb +10 -3
  45. data/app/permissions/decidim/initiatives/permissions.rb +1 -1
  46. data/app/presenters/decidim/initiatives/admin_log/initiatives_settings_presenter.rb +27 -0
  47. data/app/presenters/decidim/initiatives/admin_log/initiatives_type_presenter.rb +45 -0
  48. data/app/presenters/decidim/initiatives/initiative_stats_presenter.rb +4 -2
  49. data/app/queries/decidim/initiatives/admin/admin_users.rb +1 -1
  50. data/app/queries/decidim/initiatives/admin/manageable_initiatives.rb +1 -1
  51. data/app/queries/decidim/initiatives/freetext_initiative_types.rb +1 -1
  52. data/app/queries/decidim/initiatives/initiative_types.rb +1 -1
  53. data/app/queries/decidim/initiatives/initiatives_created.rb +1 -1
  54. data/app/queries/decidim/initiatives/initiatives_promoted.rb +1 -1
  55. data/app/queries/decidim/initiatives/organization_prioritized_initiatives.rb +1 -1
  56. data/app/queries/decidim/initiatives/outdated_validating_initiatives.rb +1 -1
  57. data/app/queries/decidim/initiatives/similar_initiatives.rb +1 -1
  58. data/app/queries/decidim/initiatives/support_period_finished_initiatives.rb +1 -1
  59. data/app/queries/decidim/initiatives/user_authorizations.rb +1 -1
  60. data/app/services/decidim/initiatives/initiative_search.rb +11 -102
  61. data/app/services/decidim/initiatives/pdf_signature_example.rb +15 -16
  62. data/app/services/decidim/initiatives/status_change_notifier.rb +1 -1
  63. data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +5 -4
  64. data/app/views/decidim/initiatives/admin/initiatives_settings/_form.html.erb +10 -0
  65. data/app/views/decidim/initiatives/admin/initiatives_settings/edit.html.erb +6 -0
  66. data/app/views/decidim/initiatives/admin/initiatives_types/_form.html.erb +5 -1
  67. data/app/views/decidim/initiatives/admin/initiatives_types/index.html.erb +23 -1
  68. data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +3 -1
  69. data/app/views/decidim/initiatives/initiatives/_filters.html.erb +5 -5
  70. data/app/views/decidim/initiatives/initiatives/_form.html.erb +3 -1
  71. data/app/views/decidim/initiatives/initiatives/_progress_bar.html.erb +2 -2
  72. data/app/views/decidim/initiatives/initiatives/index.html.erb +1 -1
  73. data/app/views/decidim/initiatives/initiatives/print.html.erb +120 -118
  74. data/app/views/decidim/initiatives/initiatives/show.html.erb +7 -6
  75. data/app/views/layouts/decidim/_initiative_header.html.erb +3 -3
  76. data/app/views/layouts/decidim/_initiative_header_steps.html.erb +3 -1
  77. data/app/views/layouts/decidim/initiative_creation.html.erb +4 -1
  78. data/app/views/layouts/decidim/initiative_signature_creation.html.erb +4 -1
  79. data/config/locales/am-ET.yml +1 -0
  80. data/config/locales/ar.yml +3 -2
  81. data/config/locales/bg.yml +1 -0
  82. data/config/locales/ca.yml +28 -4
  83. data/config/locales/cs.yml +28 -4
  84. data/config/locales/da.yml +1 -0
  85. data/config/locales/de.yml +1 -2
  86. data/config/locales/el.yml +1 -2
  87. data/config/locales/en.yml +27 -4
  88. data/config/locales/eo.yml +1 -0
  89. data/config/locales/es-MX.yml +28 -4
  90. data/config/locales/es-PY.yml +28 -4
  91. data/config/locales/es.yml +28 -4
  92. data/config/locales/et.yml +1 -0
  93. data/config/locales/eu.yml +1 -2
  94. data/config/locales/fi-plain.yml +28 -4
  95. data/config/locales/fi.yml +28 -4
  96. data/config/locales/fr-CA.yml +22 -14
  97. data/config/locales/fr.yml +141 -133
  98. data/config/locales/ga-IE.yml +1 -2
  99. data/config/locales/gl.yml +1 -2
  100. data/config/locales/hr.yml +1 -0
  101. data/config/locales/hu.yml +111 -2
  102. data/config/locales/id-ID.yml +1 -2
  103. data/config/locales/is-IS.yml +2 -3
  104. data/config/locales/it.yml +1 -4
  105. data/config/locales/ja.yml +37 -13
  106. data/config/locales/ko.yml +1 -0
  107. data/config/locales/lb.yml +1 -2
  108. data/config/locales/lt.yml +1 -0
  109. data/config/locales/lv.yml +1 -2
  110. data/config/locales/mt.yml +1 -0
  111. data/config/locales/nl.yml +1 -3
  112. data/config/locales/no.yml +1 -2
  113. data/config/locales/om-ET.yml +1 -0
  114. data/config/locales/pl.yml +1 -4
  115. data/config/locales/pt-BR.yml +2 -5
  116. data/config/locales/pt.yml +1 -4
  117. data/config/locales/ro-RO.yml +2 -4
  118. data/config/locales/ru.yml +1 -2
  119. data/config/locales/si-LK.yml +1 -0
  120. data/config/locales/sk.yml +1 -2
  121. data/config/locales/sl.yml +1 -0
  122. data/config/locales/so-SO.yml +1 -0
  123. data/config/locales/sr-CS.yml +1 -0
  124. data/config/locales/sv.yml +7 -2
  125. data/config/locales/sw-KE.yml +1 -0
  126. data/config/locales/ti-ER.yml +1 -0
  127. data/config/locales/tr-TR.yml +1 -4
  128. data/config/locales/uk.yml +1 -2
  129. data/config/locales/val-ES.yml +1 -0
  130. data/config/locales/vi.yml +1 -0
  131. data/config/locales/zh-CN.yml +1 -3
  132. data/config/locales/zh-TW.yml +1 -0
  133. data/db/migrate/20220518053612_add_comments_enabled_to_initiative_types.rb +7 -0
  134. data/db/migrate/20220527130640_create_decidim_initiatives_settings.rb +10 -0
  135. data/lib/decidim/initiatives/admin_engine.rb +17 -1
  136. data/lib/decidim/initiatives/engine.rb +14 -0
  137. data/lib/decidim/initiatives/participatory_space.rb +3 -3
  138. data/lib/decidim/initiatives/test/factories.rb +34 -1
  139. data/lib/decidim/initiatives/version.rb +1 -1
  140. data/lib/gem_overrides/origami/date.rb +47 -0
  141. metadata +28 -33
  142. data/app/views/decidim/initiatives/admin/initiatives/show.html.erb +0 -180
  143. data/config/initializers/mail_previews.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54a55b3aaf36d56a260dd3eb95eb0527c7398dea0e0b24fb72ed53a8c38998be
4
- data.tar.gz: 7f8cbf99f92122ad1b354c6f61e83d2d4eab0b0734a597c07f9aa82081f5a0c8
3
+ metadata.gz: 3b8f445bf921e23456c088a9097081b230c135895702492b00e1a82090e30594
4
+ data.tar.gz: d23c120502ebcbf584a1cb4d4d9b64e1e1a47b95b927bee0cb18fe1b2004c495
5
5
  SHA512:
6
- metadata.gz: 62a06aa02e52618a4fefbf0d79e85a49752fdf8376c5556323ad736e4ed45a80ab349553ed35646e67155d9d074419e5a5a734f478c13e89a76cd33e9be34c4a
7
- data.tar.gz: 12180f554999011b7ee4a6a6b7034e2f0510dd1c2ed827fd684a6600eda3d633294894dd974e53fae4c9c2aacec55fc80b7cd614d1cd18b0f42a09a2fc182e07
6
+ metadata.gz: 4f5001df366f376cc13834bfc04359daaafe2b9aee78e908077df91ae01bd085efe6273d722627f490fd2d37ec5f3d49cf021a05b0e603375b688878fd7d952d
7
+ data.tar.gz: 9e79d6508a39cfbba8fe44aef2e0fdcf939012d21720acc42b252bd62e68ea49b8ec6fdc0a8cba562f0841dc12b7016eae15e94c07d7ead2e72600b320cfabca
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Decidim::Initiatives
2
2
 
3
- Initiatives is the place on Decidim's where citizens can promote a civic initiative. Unlike
4
- participatory processes that must be created by an administrator, Civic initiatives can be
3
+ Initiatives is the place on Decidim's where participants can promote an initiative. Unlike
4
+ participatory processes that must be created by an administrator, initiatives can be
5
5
  created by any user of the platform.
6
6
 
7
7
  An initiative will contain attachments and comments from other users as well.
@@ -100,7 +100,7 @@ a mechanism to validate that there are no duplicated signatures. To do so the en
100
100
  a functionality that allows exporting the online signatures to validate them against physical
101
101
  signatures.
102
102
 
103
- The signatures are exported as a hash string in order to preserve the identity of the signer together with her privacy.
103
+ The signatures are exported as a hash string in order to preserve the identity of the signer together with their privacy.
104
104
  Each hash is composed with the following criteria:
105
105
 
106
106
  * Algorithm used: SHA1
@@ -1,4 +1,4 @@
1
- <section class="wrapper-home home-section">
1
+ <section id="highlighted_initiatives" class="wrapper-home home-section">
2
2
  <div class="row" id="highlighted-initiatives">
3
3
  <h3 class="section-heading"><%= t("active_initiatives", scope: i18n_scope) %></h3>
4
4
  <div class="row collapse">
@@ -1,6 +1,6 @@
1
1
  <div class="card__footer card__footer--spaces">
2
2
  <div class="card__support">
3
- <% if model.published? %>
3
+ <% if model.published? || model.rejected? || model.accepted? %>
4
4
  <div class="card__support__data">
5
5
  <%= cell(
6
6
  "decidim/progress_bar",
@@ -1,7 +1,7 @@
1
1
  <% if model.hashtag.present? %>
2
2
  <%= link_to(
3
3
  "##{hashtag}",
4
- "https://twitter.com/hashtag/#{hashtag}",
4
+ twitter_hashtag_url(hashtag),
5
5
  class: "card__text--category",
6
6
  target: "_blank"
7
7
  ) %>
@@ -6,6 +6,7 @@ module Decidim
6
6
  # for an given instance of an Initiative
7
7
  class InitiativeMCell < Decidim::CardMCell
8
8
  include Decidim::Initiatives::Engine.routes.url_helpers
9
+ include Decidim::TwitterSearchHelper
9
10
 
10
11
  property :state
11
12
 
@@ -4,12 +4,13 @@ module Decidim
4
4
  module Initiatives
5
5
  module Admin
6
6
  # A command with all the business logic that creates a new initiative type
7
- class CreateInitiativeType < Rectify::Command
7
+ class CreateInitiativeType < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A form object with the params.
11
- def initialize(form)
11
+ def initialize(form, user)
12
12
  @form = form
13
+ @user = user
13
14
  end
14
15
 
15
16
  # Executes the command. Broadcasts these events:
@@ -36,11 +37,14 @@ module Decidim
36
37
  attr_reader :form
37
38
 
38
39
  def create_initiative_type
39
- initiative_type = InitiativesType.new(
40
+ initiative_type = Decidim.traceability.create!(
41
+ InitiativesType,
42
+ @user,
40
43
  organization: form.current_organization,
41
44
  title: form.title,
42
45
  description: form.description,
43
46
  signature_type: form.signature_type,
47
+ comments_enabled: form.comments_enabled,
44
48
  attachments_enabled: form.attachments_enabled,
45
49
  undo_online_signatures_enabled: form.undo_online_signatures_enabled,
46
50
  custom_signature_end_date_enabled: form.custom_signature_end_date_enabled,
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Initiatives
5
5
  module Admin
6
6
  # A command with all the business logic that creates a new initiative type scope
7
- class CreateInitiativeTypeScope < Rectify::Command
7
+ class CreateInitiativeTypeScope < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A form object with the params.
@@ -26,8 +26,8 @@ module Decidim
26
26
  if initiative_type_scope.persisted?
27
27
  broadcast(:ok, initiative_type_scope)
28
28
  else
29
- initiative_type_scope.errors.each do |attribute, error|
30
- form.errors.add(attribute, error)
29
+ initiative_type_scope.errors.each do |error|
30
+ form.errors.add(error.attribute, error.message)
31
31
  end
32
32
 
33
33
  broadcast(:invalid)
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic that publishes an
7
7
  # existing initiative.
8
- class PublishInitiative < Rectify::Command
8
+ class PublishInitiative < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # initiative - Decidim::Initiative
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic that sends an
7
7
  # existing initiative to technical validation.
8
- class SendInitiativeToTechnicalValidation < Rectify::Command
8
+ class SendInitiativeToTechnicalValidation < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # initiative - Decidim::Initiative
@@ -51,7 +51,7 @@ module Decidim
51
51
  force_send: true
52
52
  }
53
53
 
54
- Decidim::EventsManager.publish(data)
54
+ Decidim::EventsManager.publish(**data)
55
55
  end
56
56
  end
57
57
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic that unpublishes an
7
7
  # existing initiative.
8
- class UnpublishInitiative < Rectify::Command
8
+ class UnpublishInitiative < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # initiative - Decidim::Initiative
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic that updates an
7
7
  # existing initiative.
8
- class UpdateInitiative < Rectify::Command
8
+ class UpdateInitiative < Decidim::Command
9
9
  include Decidim::Initiatives::AttachmentMethods
10
10
 
11
11
  # Public: Initializes the command.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic to answer
7
7
  # initiatives.
8
- class UpdateInitiativeAnswer < Rectify::Command
8
+ class UpdateInitiativeAnswer < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # initiative - Decidim::Initiative
@@ -5,14 +5,17 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic that updates an
7
7
  # existing initiative type.
8
- class UpdateInitiativeType < Rectify::Command
8
+ class UpdateInitiativeType < Decidim::Command
9
+ include ::Decidim::AttachmentAttributesMethods
10
+
9
11
  # Public: Initializes the command.
10
12
  #
11
13
  # initiative_type: Decidim::InitiativesType
12
14
  # form - A form object with the params.
13
- def initialize(initiative_type, form)
15
+ def initialize(initiative_type, form, user)
14
16
  @form = form
15
17
  @initiative_type = initiative_type
18
+ @user = user
16
19
  end
17
20
 
18
21
  # Executes the command. Broadcasts these events:
@@ -24,13 +27,15 @@ module Decidim
24
27
  def call
25
28
  return broadcast(:invalid) if form.invalid?
26
29
 
27
- initiative_type.update(attributes)
30
+ Decidim.traceability.perform_action!("update", initiative_type, @user) do
31
+ initiative_type.update(attributes)
28
32
 
29
- if initiative_type.valid?
30
- upate_initiatives_signature_type
31
- broadcast(:ok, initiative_type)
32
- else
33
- broadcast(:invalid)
33
+ if initiative_type.valid?
34
+ update_initiatives_signature_type
35
+ broadcast(:ok, initiative_type)
36
+ else
37
+ broadcast(:invalid)
38
+ end
34
39
  end
35
40
  end
36
41
 
@@ -39,11 +44,12 @@ module Decidim
39
44
  attr_reader :form, :initiative_type
40
45
 
41
46
  def attributes
42
- result = {
47
+ {
43
48
  title: form.title,
44
49
  description: form.description,
45
50
  signature_type: form.signature_type,
46
51
  attachments_enabled: form.attachments_enabled,
52
+ comments_enabled: form.comments_enabled,
47
53
  undo_online_signatures_enabled: form.undo_online_signatures_enabled,
48
54
  custom_signature_end_date_enabled: form.custom_signature_end_date_enabled,
49
55
  area_enabled: form.area_enabled,
@@ -55,13 +61,12 @@ module Decidim
55
61
  document_number_authorization_handler: form.document_number_authorization_handler,
56
62
  child_scope_threshold_enabled: form.child_scope_threshold_enabled,
57
63
  only_global_scope_enabled: form.only_global_scope_enabled
58
- }
59
-
60
- result[:banner_image] = form.banner_image unless form.banner_image.nil?
61
- result
64
+ }.merge(
65
+ attachment_attributes(:banner_image)
66
+ )
62
67
  end
63
68
 
64
- def upate_initiatives_signature_type
69
+ def update_initiatives_signature_type
65
70
  initiative_type.initiatives.signature_type_updatable.each do |initiative|
66
71
  initiative.update!(signature_type: initiative_type.signature_type)
67
72
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic that updates an
7
7
  # existing initiative type scope.
8
- class UpdateInitiativeTypeScope < Rectify::Command
8
+ class UpdateInitiativeTypeScope < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # initiative_type: Decidim::InitiativesTypeScope
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ module Admin
6
+ # A command with all the business logic when updating initiatives
7
+ # settings in admin area.
8
+ class UpdateInitiativesSettings < Decidim::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # initiatives_settings - A initiatives settings object to update.
12
+ # form - A form object with the params.
13
+ def initialize(initiatives_settings, form)
14
+ @initiatives_settings = initiatives_settings
15
+ @form = form
16
+ end
17
+
18
+ # Executes the command. Broadcasts these events:
19
+ #
20
+ # - :ok when everything is valid.
21
+ # - :invalid if the form or initiatives_settings isn't valid and we couldn't proceed.
22
+ #
23
+ # Returns nothing.
24
+ def call
25
+ return broadcast(:invalid) if form.invalid? || initiatives_settings.invalid?
26
+
27
+ update_initiatives_settings!
28
+
29
+ broadcast(:ok)
30
+ end
31
+
32
+ private
33
+
34
+ attr_reader :form, :initiatives_settings
35
+
36
+ def update_initiatives_settings!
37
+ Decidim.traceability.update!(
38
+ @initiatives_settings,
39
+ form.current_user,
40
+ initiatives_order: form.initiatives_order
41
+ )
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  # A command with all the business logic that creates a new initiative.
6
- class ApproveMembershipRequest < Rectify::Command
6
+ class ApproveMembershipRequest < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # membership_request - A pending committee member
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  # A command with all the business logic that creates a new initiative.
6
- class CreateInitiative < Rectify::Command
6
+ class CreateInitiative < Decidim::Command
7
7
  include CurrentLocale
8
8
  include ::Decidim::MultipleAttachmentsMethods
9
9
 
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  # A command with all the business logic that creates a new initiative.
6
- class RevokeMembershipRequest < Rectify::Command
6
+ class RevokeMembershipRequest < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # membership_request - A pending committee member
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Initiatives
5
5
  # A command with all the business logic that sends an
6
6
  # existing initiative to technical validation.
7
- class SendInitiativeToTechnicalValidation < Rectify::Command
7
+ class SendInitiativeToTechnicalValidation < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # initiative - Decidim::Initiative
@@ -50,7 +50,7 @@ module Decidim
50
50
  force_send: true
51
51
  }
52
52
 
53
- Decidim::EventsManager.publish(data)
53
+ Decidim::EventsManager.publish(**data)
54
54
  end
55
55
  end
56
56
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Initiatives
5
5
  # A command with all the business logic that creates a new membership
6
6
  # request for the committee of an initiative.
7
- class SpawnCommitteeRequest < Rectify::Command
7
+ class SpawnCommitteeRequest < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - Decidim::Initiative::CommitteeMemberForm
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  # A command with all the business logic when a user or organization unvotes an initiative.
6
- class UnvoteInitiative < Rectify::Command
6
+ class UnvoteInitiative < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # initiative - A Decidim::Initiative object.
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Initiatives
5
5
  # A command with all the business logic that updates an
6
6
  # existing initiative.
7
- class UpdateInitiative < Rectify::Command
7
+ class UpdateInitiative < Decidim::Command
8
8
  include ::Decidim::MultipleAttachmentsMethods
9
9
  include ::Decidim::GalleryMethods
10
10
  include CurrentLocale
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Initiatives
5
5
  # Command to check if mobile phone has an authorization and
6
6
  # deliver sms code
7
- class ValidateMobilePhone < Rectify::Command
7
+ class ValidateMobilePhone < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A MobilePhoneForm.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  # Command to check if sms code provided by user is valid
6
- class ValidateSmsCode < Rectify::Command
6
+ class ValidateSmsCode < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - form containing confirmation_code.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  # A command with all the business logic when a user or organization votes an initiative.
6
- class VoteInitiative < Rectify::Command
6
+ class VoteInitiative < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - A form object with the params.
@@ -101,13 +101,9 @@ module Decidim
101
101
  event: "decidim.events.initiatives.support_threshold_reached",
102
102
  event_class: Decidim::Initiatives::Admin::SupportThresholdReachedEvent,
103
103
  resource: initiative,
104
- followers: organization_admins
104
+ followers: initiative.organization.admins
105
105
  )
106
106
  end
107
-
108
- def organization_admins
109
- Decidim::User.where(organization: initiative.organization, admin: true)
110
- end
111
107
  end
112
108
  end
113
109
  end
@@ -37,6 +37,14 @@ module Decidim
37
37
  initiatives.order_randomly(random_seed)
38
38
  end
39
39
  end
40
+
41
+ def order
42
+ @order ||= detect_order(params[:order]) || current_initiatives_settings.initiatives_order || default_order
43
+ end
44
+
45
+ def current_initiatives_settings
46
+ @current_initiatives_settings ||= Decidim::InitiativesSettings.find_or_create_by!(organization: current_organization)
47
+ end
40
48
  end
41
49
  end
42
50
  end
@@ -22,11 +22,6 @@ module Decidim
22
22
  @initiatives = filtered_collection
23
23
  end
24
24
 
25
- # GET /admin/initiatives/:id
26
- def show
27
- enforce_permission_to :read, :initiative, initiative: current_initiative
28
- end
29
-
30
25
  # GET /admin/initiatives/:id/edit
31
26
  def edit
32
27
  enforce_permission_to :edit, :initiative, initiative: current_initiative
@@ -115,7 +110,7 @@ module Decidim
115
110
  redirect_to EngineRouter.main_proxy(current_initiative).initiatives_path(initiative_slug: nil), flash: {
116
111
  notice: I18n.t(
117
112
  "success",
118
- scope: %w(decidim initiatives admin initiatives edit)
113
+ scope: "decidim.initiatives.admin.initiatives.edit"
119
114
  )
120
115
  }
121
116
  end
@@ -163,7 +158,8 @@ module Decidim
163
158
  output = render_to_string(
164
159
  pdf: "votes_#{current_initiative.id}",
165
160
  layout: "decidim/admin/initiatives_votes",
166
- template: "decidim/initiatives/admin/initiatives/export_pdf_signatures.pdf.erb"
161
+ template: "decidim/initiatives/admin/initiatives/export_pdf_signatures",
162
+ format: [:pdf]
167
163
  )
168
164
  output = pdf_signature_service.new(pdf: output).signed_pdf if pdf_signature_service
169
165
 
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ module Admin
6
+ # Controller used to manage the initiatives settings for the current
7
+ # organization.
8
+ class InitiativesSettingsController < Decidim::Initiatives::Admin::ApplicationController
9
+ layout "decidim/admin/initiatives"
10
+
11
+ # GET /admin/initiatives_settings/edit
12
+ def edit
13
+ enforce_permission_to :update, :initiatives_settings, initiatives_settings: current_initiatives_settings
14
+ @form = initiatives_settings_form.from_model(current_initiatives_settings)
15
+ end
16
+
17
+ # PUT /admin/initiatives_settings
18
+ def update
19
+ enforce_permission_to :update, :initiatives_settings, initiatives_settings: current_initiatives_settings
20
+
21
+ @form = initiatives_settings_form
22
+ .from_params(params, initiatives_settings: current_initiatives_settings)
23
+
24
+ UpdateInitiativesSettings.call(current_initiatives_settings, @form) do
25
+ on(:ok) do
26
+ flash[:notice] = I18n.t("initiatives_settings.update.success", scope: "decidim.admin")
27
+ redirect_to edit_initiatives_setting_path
28
+ end
29
+
30
+ on(:invalid) do
31
+ flash.now[:alert] = I18n.t("initiatives_settings.update.error", scope: "decidim.admin")
32
+ render :edit
33
+ end
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def current_initiatives_settings
40
+ @current_initiatives_settings ||= Decidim::InitiativesSettings.find_or_create_by!(organization: current_organization)
41
+ end
42
+
43
+ def initiatives_settings_form
44
+ form(Decidim::Initiatives::Admin::InitiativesSettingsForm)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -27,7 +27,7 @@ module Decidim
27
27
  enforce_permission_to :create, :initiative_type
28
28
  @form = initiative_type_form.from_params(params)
29
29
 
30
- CreateInitiativeType.call(@form) do
30
+ CreateInitiativeType.call(@form, current_user) do
31
31
  on(:ok) do |initiative_type|
32
32
  flash[:notice] = I18n.t("decidim.initiatives.admin.initiatives_types.create.success")
33
33
  redirect_to edit_initiatives_type_path(initiative_type)
@@ -55,7 +55,7 @@ module Decidim
55
55
  @form = initiative_type_form
56
56
  .from_params(params, initiative_type: current_initiative_type)
57
57
 
58
- UpdateInitiativeType.call(current_initiative_type, @form) do
58
+ UpdateInitiativeType.call(current_initiative_type, @form, current_user) do
59
59
  on(:ok) do
60
60
  flash[:notice] = I18n.t("decidim.initiatives.admin.initiatives_types.update.success")
61
61
  redirect_to edit_initiatives_type_path(current_initiative_type)
@@ -71,7 +71,10 @@ module Decidim
71
71
  # DELETE /admin/initiatives_types/:id
72
72
  def destroy
73
73
  enforce_permission_to :destroy, :initiative_type, initiative_type: current_initiative_type
74
- current_initiative_type.destroy!
74
+
75
+ Decidim.traceability.perform_action!("delete", current_initiative_type, current_user) do
76
+ current_initiative_type.destroy!
77
+ end
75
78
 
76
79
  redirect_to initiatives_types_path, flash: {
77
80
  notice: I18n.t("decidim.initiatives.admin.initiatives_types.destroy.success")
@@ -28,7 +28,7 @@ module Decidim
28
28
  redirect_to initiatives_path, flash: {
29
29
  notice: I18n.t(
30
30
  "success",
31
- scope: %w(decidim initiatives committee_requests spawn)
31
+ scope: "decidim.initiatives.committee_requests.spawn"
32
32
  )
33
33
  }
34
34
  end
@@ -125,9 +125,9 @@ module Decidim
125
125
 
126
126
  def build_form(klass, parameters)
127
127
  @form = if single_initiative_type?
128
- form(klass).from_params(parameters.merge(type_id: current_organization_initiatives_type.first.id), extra_context)
128
+ form(klass).from_params(parameters.except(:id).merge(type_id: current_organization_initiatives_type.first.id), extra_context)
129
129
  else
130
- form(klass).from_params(parameters, extra_context)
130
+ form(klass).from_params(parameters.except(:id), extra_context)
131
131
  end
132
132
 
133
133
  attributes = @form.attributes_with_values