decidim-initiatives 0.26.2 → 0.27.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) 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 +2 -2
  4. data/app/commands/decidim/initiatives/admin/create_initiative_type.rb +7 -3
  5. data/app/commands/decidim/initiatives/admin/create_initiative_type_scope.rb +3 -3
  6. data/app/commands/decidim/initiatives/admin/publish_initiative.rb +1 -1
  7. data/app/commands/decidim/initiatives/admin/send_initiative_to_technical_validation.rb +2 -2
  8. data/app/commands/decidim/initiatives/admin/unpublish_initiative.rb +1 -1
  9. data/app/commands/decidim/initiatives/admin/update_initiative.rb +1 -1
  10. data/app/commands/decidim/initiatives/admin/update_initiative_answer.rb +1 -1
  11. data/app/commands/decidim/initiatives/admin/update_initiative_type.rb +19 -14
  12. data/app/commands/decidim/initiatives/admin/update_initiative_type_scope.rb +1 -1
  13. data/app/commands/decidim/initiatives/admin/update_initiatives_settings.rb +46 -0
  14. data/app/commands/decidim/initiatives/approve_membership_request.rb +1 -1
  15. data/app/commands/decidim/initiatives/create_initiative.rb +1 -1
  16. data/app/commands/decidim/initiatives/revoke_membership_request.rb +1 -1
  17. data/app/commands/decidim/initiatives/send_initiative_to_technical_validation.rb +2 -2
  18. data/app/commands/decidim/initiatives/spawn_committee_request.rb +1 -1
  19. data/app/commands/decidim/initiatives/unvote_initiative.rb +1 -1
  20. data/app/commands/decidim/initiatives/update_initiative.rb +1 -1
  21. data/app/commands/decidim/initiatives/validate_mobile_phone.rb +1 -1
  22. data/app/commands/decidim/initiatives/validate_sms_code.rb +1 -1
  23. data/app/commands/decidim/initiatives/vote_initiative.rb +2 -6
  24. data/app/controllers/concerns/decidim/initiatives/orderable.rb +8 -0
  25. data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +3 -2
  26. data/app/controllers/decidim/initiatives/admin/initiatives_settings_controller.rb +49 -0
  27. data/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb +6 -3
  28. data/app/controllers/decidim/initiatives/committee_requests_controller.rb +1 -1
  29. data/app/controllers/decidim/initiatives/create_initiative_controller.rb +2 -2
  30. data/app/controllers/decidim/initiatives/initiatives_controller.rb +18 -22
  31. data/app/forms/decidim/initiatives/admin/initiative_form.rb +4 -4
  32. data/app/forms/decidim/initiatives/admin/initiative_type_form.rb +2 -1
  33. data/app/forms/decidim/initiatives/admin/initiatives_settings_form.rb +14 -0
  34. data/app/forms/decidim/initiatives/vote_form.rb +0 -3
  35. data/app/helpers/decidim/initiatives/create_initiative_helper.rb +3 -3
  36. data/app/helpers/decidim/initiatives/initiative_helper.rb +6 -4
  37. data/app/mailers/decidim/initiatives/initiatives_mailer.rb +2 -2
  38. data/app/models/decidim/initiative.rb +60 -9
  39. data/app/models/decidim/initiatives_settings.rb +17 -0
  40. data/app/models/decidim/initiatives_type.rb +5 -0
  41. data/app/permissions/decidim/initiatives/admin/permissions.rb +10 -3
  42. data/app/permissions/decidim/initiatives/permissions.rb +1 -1
  43. data/app/presenters/decidim/initiatives/admin_log/initiatives_settings_presenter.rb +27 -0
  44. data/app/presenters/decidim/initiatives/admin_log/initiatives_type_presenter.rb +45 -0
  45. data/app/presenters/decidim/initiatives/initiative_stats_presenter.rb +4 -2
  46. data/app/queries/decidim/initiatives/admin/admin_users.rb +1 -1
  47. data/app/queries/decidim/initiatives/admin/manageable_initiatives.rb +1 -1
  48. data/app/queries/decidim/initiatives/freetext_initiative_types.rb +1 -1
  49. data/app/queries/decidim/initiatives/initiative_types.rb +1 -1
  50. data/app/queries/decidim/initiatives/initiatives_created.rb +1 -1
  51. data/app/queries/decidim/initiatives/initiatives_promoted.rb +1 -1
  52. data/app/queries/decidim/initiatives/organization_prioritized_initiatives.rb +1 -1
  53. data/app/queries/decidim/initiatives/outdated_validating_initiatives.rb +1 -1
  54. data/app/queries/decidim/initiatives/similar_initiatives.rb +1 -1
  55. data/app/queries/decidim/initiatives/support_period_finished_initiatives.rb +1 -1
  56. data/app/queries/decidim/initiatives/user_authorizations.rb +1 -1
  57. data/app/services/decidim/initiatives/initiative_search.rb +11 -102
  58. data/app/services/decidim/initiatives/pdf_signature_example.rb +15 -16
  59. data/app/services/decidim/initiatives/status_change_notifier.rb +1 -1
  60. data/app/views/decidim/initiatives/admin/initiatives_settings/_form.html.erb +10 -0
  61. data/app/views/decidim/initiatives/admin/initiatives_settings/edit.html.erb +6 -0
  62. data/app/views/decidim/initiatives/admin/initiatives_types/_form.html.erb +4 -0
  63. data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +3 -1
  64. data/app/views/decidim/initiatives/initiatives/_filters.html.erb +5 -5
  65. data/app/views/decidim/initiatives/initiatives/_form.html.erb +3 -1
  66. data/app/views/decidim/initiatives/initiatives/show.html.erb +4 -2
  67. data/app/views/decidim/initiatives/initiatives_mailer/notify_creation.html.erb +2 -2
  68. data/app/views/layouts/decidim/_initiative_header.html.erb +1 -1
  69. data/app/views/layouts/decidim/_initiative_header_steps.html.erb +3 -1
  70. data/app/views/layouts/decidim/initiative_creation.html.erb +4 -1
  71. data/app/views/layouts/decidim/initiative_signature_creation.html.erb +4 -1
  72. data/config/locales/ar.yml +1 -1
  73. data/config/locales/bg.yml +1 -0
  74. data/config/locales/ca.yml +26 -1
  75. data/config/locales/cs.yml +28 -3
  76. data/config/locales/de.yml +30 -1
  77. data/config/locales/el.yml +1 -0
  78. data/config/locales/en.yml +25 -1
  79. data/config/locales/es-MX.yml +26 -1
  80. data/config/locales/es-PY.yml +26 -1
  81. data/config/locales/es.yml +26 -1
  82. data/config/locales/eu.yml +1 -0
  83. data/config/locales/fi-plain.yml +25 -0
  84. data/config/locales/fi.yml +25 -0
  85. data/config/locales/fr-CA.yml +26 -1
  86. data/config/locales/fr.yml +27 -2
  87. data/config/locales/ga-IE.yml +1 -0
  88. data/config/locales/gl.yml +1 -0
  89. data/config/locales/hu.yml +191 -0
  90. data/config/locales/id-ID.yml +1 -0
  91. data/config/locales/is-IS.yml +4 -1
  92. data/config/locales/it.yml +1 -0
  93. data/config/locales/ja.yml +26 -1
  94. data/config/locales/lb.yml +1 -0
  95. data/config/locales/lt.yml +658 -0
  96. data/config/locales/lv.yml +1 -0
  97. data/config/locales/nl.yml +1 -0
  98. data/config/locales/no.yml +18 -0
  99. data/config/locales/pl.yml +1 -0
  100. data/config/locales/pt-BR.yml +1 -0
  101. data/config/locales/pt.yml +1 -0
  102. data/config/locales/ro-RO.yml +2 -0
  103. data/config/locales/ru.yml +3 -0
  104. data/config/locales/sk.yml +1 -0
  105. data/config/locales/sl.yml +1 -0
  106. data/config/locales/sv.yml +7 -0
  107. data/config/locales/tr-TR.yml +1 -0
  108. data/config/locales/uk.yml +3 -0
  109. data/config/locales/zh-CN.yml +1 -0
  110. data/db/migrate/20220518053612_add_comments_enabled_to_initiative_types.rb +7 -0
  111. data/db/migrate/20220527130640_create_decidim_initiatives_settings.rb +10 -0
  112. data/lib/decidim/initiatives/admin_engine.rb +16 -0
  113. data/lib/decidim/initiatives/participatory_space.rb +3 -3
  114. data/lib/decidim/initiatives/test/factories.rb +34 -1
  115. data/lib/decidim/initiatives/version.rb +1 -1
  116. data/lib/gem_overrides/origami/date.rb +47 -0
  117. metadata +45 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69fc6ffef72993607c5315d6493dce7779fda12587d681825afb949dc760e27f
4
- data.tar.gz: f25a94094ea82027a0c9ca45f5daf620934702d516acb19a7d6c8ec69a9cec26
3
+ metadata.gz: c658918a028b8d1f57c0628e1910eea0a8ffbcd7e3975a9d9d1de5ef6d1c9c60
4
+ data.tar.gz: 223c6b5e9e3ee76f1b2d010fa748d2e8710951d7e6081597ec74eb52cccf5023
5
5
  SHA512:
6
- metadata.gz: 3fe96ffb51d38cdd870106dbe109b19734c0f88b3162244d47e65424a2dc14281c4a0143c8505084ebf251677442c6d617ee0c417ced4bfe6d7e8b3de225c9b4
7
- data.tar.gz: f5abf4851d109d4d1f396a2467c2990e123d26cb72213e4a13a01c4a867b713df4c6c678dbed64ed1a9972679c7d2b43a64cc345e9caeb477c55406914c95180
6
+ metadata.gz: 4843b50d4362f76aa9fbc8d9b5b4ff07748d1db2632dcded98b813e6e15272c1491b4e1e1b5231a370fcc799643f6b7167c9ebe3b215c8efd5a67bd02ed8bd0a
7
+ data.tar.gz: '0749e6b80832e86321f81b6cb73e28933b9a7450c6c747470014b72f98ee995060d4f01bb831a522378db667932523f5cc441fef1b31431b49ff1f299ad76b5e'
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">
@@ -7,7 +7,7 @@
7
7
  <div class="column">
8
8
  <%= link_to decidim_initiatives.initiative_path(initiative), class: "card card--initiative card--mini" do %>
9
9
  <div aria-hidden="true" class="card__image-top"
10
- style="background-image:url(<%= initiative.banner_image.path %>)"></div>
10
+ style="background-image:url('<%= initiative.banner_image.path %>')"></div>
11
11
  <span class="show-for-sr"><%= translated_attribute initiative.title %></span>
12
12
  <div class="card__content">
13
13
  <span class="card__title card__link"><%= decidim_html_escape(translated_attribute(initiative.title)) %></span>
@@ -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
@@ -110,7 +110,7 @@ module Decidim
110
110
  redirect_to EngineRouter.main_proxy(current_initiative).initiatives_path(initiative_slug: nil), flash: {
111
111
  notice: I18n.t(
112
112
  "success",
113
- scope: %w(decidim initiatives admin initiatives edit)
113
+ scope: "decidim.initiatives.admin.initiatives.edit"
114
114
  )
115
115
  }
116
116
  end
@@ -158,7 +158,8 @@ module Decidim
158
158
  output = render_to_string(
159
159
  pdf: "votes_#{current_initiative.id}",
160
160
  layout: "decidim/admin/initiatives_votes",
161
- template: "decidim/initiatives/admin/initiatives/export_pdf_signatures.pdf.erb"
161
+ template: "decidim/initiatives/admin/initiatives/export_pdf_signatures",
162
+ format: [:pdf]
162
163
  )
163
164
  output = pdf_signature_service.new(pdf: output).signed_pdf if pdf_signature_service
164
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
5
- # This controller contains the logic regarding citizen initiatives
5
+ # This controller contains the logic regarding participants initiatives
6
6
  class InitiativesController < Decidim::Initiatives::ApplicationController
7
7
  include ParticipatorySpaceContext
8
8
  participatory_space_layout only: [:show]
@@ -33,13 +33,13 @@ module Decidim
33
33
  # GET /initiatives
34
34
  def index
35
35
  enforce_permission_to :list, :initiative
36
- return unless search.results.blank? && params.dig("filter", "state") != %w(closed)
36
+ return unless search.result.blank? && params.dig("filter", "with_any_state") != %w(closed)
37
37
 
38
- @closed_initiatives = search_klass.new(search_params.merge(state: %w(closed)))
38
+ @closed_initiatives ||= search_with(filter_params.merge(with_any_state: %w(closed)))
39
39
 
40
- if @closed_initiatives.results.present?
40
+ if @closed_initiatives.result.present?
41
41
  params[:filter] ||= {}
42
- params[:filter][:date] = %w(closed)
42
+ params[:filter][:with_any_state] = %w(closed)
43
43
  @forced_closed_initiatives = true
44
44
 
45
45
  @search = @closed_initiatives
@@ -60,7 +60,7 @@ module Decidim
60
60
  redirect_to EngineRouter.main_proxy(current_initiative).initiatives_path(initiative_slug: nil), flash: {
61
61
  notice: I18n.t(
62
62
  "success",
63
- scope: %w(decidim initiatives admin initiatives edit)
63
+ scope: "decidim.initiatives.admin.initiatives.edit"
64
64
  )
65
65
  }
66
66
  end
@@ -111,7 +111,7 @@ module Decidim
111
111
  alias current_initiative current_participatory_space
112
112
 
113
113
  def current_participatory_space
114
- @current_participatory_space ||= Initiative.find_by(id: id_from_slug(params[:slug]))
114
+ @current_participatory_space ||= Initiative.find(id_from_slug(params[:slug]))
115
115
  end
116
116
 
117
117
  def current_participatory_space_manifest
@@ -119,25 +119,28 @@ module Decidim
119
119
  end
120
120
 
121
121
  def initiatives
122
- @initiatives = search.results.includes(:scoped_type)
122
+ @initiatives = search.result.includes(:scoped_type)
123
123
  @initiatives = reorder(@initiatives)
124
124
  @initiatives = paginate(@initiatives)
125
125
  end
126
126
 
127
127
  alias collection initiatives
128
128
 
129
- def search_klass
130
- InitiativeSearch
129
+ def search_collection
130
+ Initiative
131
+ .includes(scoped_type: [:scope])
132
+ .joins("JOIN decidim_users ON decidim_users.id = decidim_initiatives.decidim_author_id")
133
+ .where(organization: current_organization)
131
134
  end
132
135
 
133
136
  def default_filter_params
134
137
  {
135
- search_text: "",
136
- state: ["open"],
137
- type_id: default_filter_type_params,
138
+ search_text_cont: "",
139
+ with_any_state: %w(open),
140
+ with_any_type: default_filter_type_params,
138
141
  author: "any",
139
- scope_id: default_filter_scope_params,
140
- area_id: default_filter_area_params
142
+ with_any_scope: default_filter_scope_params,
143
+ with_any_area: default_filter_area_params
141
144
  }
142
145
  end
143
146
 
@@ -153,13 +156,6 @@ module Decidim
153
156
  %w(all) + current_organization.areas.pluck(:id).map(&:to_s)
154
157
  end
155
158
 
156
- def context_params
157
- {
158
- organization: current_organization,
159
- current_user: current_user
160
- }
161
- end
162
-
163
159
  def stats
164
160
  @stats ||= InitiativeStatsPresenter.new(initiative: current_initiative)
165
161
  end