decidim-initiatives 0.26.9 → 0.27.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +2 -2
- data/app/commands/decidim/initiatives/admin/create_initiative_type.rb +7 -3
- data/app/commands/decidim/initiatives/admin/create_initiative_type_scope.rb +3 -3
- data/app/commands/decidim/initiatives/admin/publish_initiative.rb +1 -1
- data/app/commands/decidim/initiatives/admin/send_initiative_to_technical_validation.rb +2 -2
- data/app/commands/decidim/initiatives/admin/unpublish_initiative.rb +1 -1
- data/app/commands/decidim/initiatives/admin/update_initiative.rb +1 -1
- data/app/commands/decidim/initiatives/admin/update_initiative_answer.rb +1 -1
- data/app/commands/decidim/initiatives/admin/update_initiative_type.rb +19 -14
- data/app/commands/decidim/initiatives/admin/update_initiative_type_scope.rb +1 -1
- data/app/commands/decidim/initiatives/admin/update_initiatives_settings.rb +46 -0
- data/app/commands/decidim/initiatives/approve_membership_request.rb +1 -1
- data/app/commands/decidim/initiatives/create_initiative.rb +2 -3
- data/app/commands/decidim/initiatives/revoke_membership_request.rb +1 -1
- data/app/commands/decidim/initiatives/send_initiative_to_technical_validation.rb +2 -2
- data/app/commands/decidim/initiatives/spawn_committee_request.rb +1 -1
- data/app/commands/decidim/initiatives/unvote_initiative.rb +1 -1
- data/app/commands/decidim/initiatives/update_initiative.rb +1 -1
- data/app/commands/decidim/initiatives/validate_mobile_phone.rb +1 -1
- data/app/commands/decidim/initiatives/validate_sms_code.rb +1 -1
- data/app/commands/decidim/initiatives/vote_initiative.rb +2 -6
- data/app/constraints/decidim/initiatives/current_initiative.rb +1 -1
- data/app/controllers/concerns/decidim/initiatives/orderable.rb +8 -0
- data/app/controllers/decidim/initiatives/admin/committee_requests_controller.rb +1 -1
- data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +4 -3
- data/app/controllers/decidim/initiatives/admin/initiatives_settings_controller.rb +49 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb +1 -1
- data/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb +7 -4
- data/app/controllers/decidim/initiatives/application_controller.rb +0 -7
- data/app/controllers/decidim/initiatives/committee_requests_controller.rb +2 -2
- data/app/controllers/decidim/initiatives/create_initiative_controller.rb +4 -19
- data/app/controllers/decidim/initiatives/initiatives_controller.rb +17 -24
- data/app/controllers/decidim/initiatives/initiatives_type_scopes_controller.rb +1 -1
- data/app/controllers/decidim/initiatives/initiatives_type_signature_types_controller.rb +1 -1
- data/app/forms/decidim/initiatives/admin/initiative_form.rb +4 -4
- data/app/forms/decidim/initiatives/admin/initiative_type_form.rb +2 -1
- data/app/forms/decidim/initiatives/admin/initiatives_settings_form.rb +14 -0
- data/app/forms/decidim/initiatives/initiative_form.rb +0 -3
- data/app/forms/decidim/initiatives/vote_form.rb +0 -4
- data/app/helpers/decidim/initiatives/{signature_type_options_helper.rb → create_initiative_helper.rb} +4 -4
- data/app/helpers/decidim/initiatives/initiative_helper.rb +6 -4
- data/app/mailers/decidim/initiatives/initiatives_mailer.rb +2 -2
- data/app/models/decidim/initiative.rb +60 -9
- data/app/models/decidim/initiatives_settings.rb +17 -0
- data/app/models/decidim/initiatives_type.rb +5 -0
- data/app/packs/stylesheets/decidim/initiatives/print-initiative.scss +0 -16
- data/app/permissions/decidim/initiatives/admin/permissions.rb +10 -4
- data/app/permissions/decidim/initiatives/permissions.rb +1 -1
- data/app/presenters/decidim/initiatives/admin_log/initiatives_settings_presenter.rb +27 -0
- data/app/presenters/decidim/initiatives/admin_log/initiatives_type_presenter.rb +45 -0
- data/app/presenters/decidim/initiatives/initiative_stats_presenter.rb +4 -2
- data/app/queries/decidim/initiatives/admin/admin_users.rb +1 -1
- data/app/queries/decidim/initiatives/admin/manageable_initiatives.rb +1 -1
- data/app/queries/decidim/initiatives/freetext_initiative_types.rb +1 -1
- data/app/queries/decidim/initiatives/initiative_types.rb +1 -1
- data/app/queries/decidim/initiatives/initiatives_created.rb +1 -1
- data/app/queries/decidim/initiatives/initiatives_promoted.rb +1 -1
- data/app/queries/decidim/initiatives/organization_prioritized_initiatives.rb +1 -1
- data/app/queries/decidim/initiatives/outdated_validating_initiatives.rb +1 -1
- data/app/queries/decidim/initiatives/similar_initiatives.rb +1 -1
- data/app/queries/decidim/initiatives/support_period_finished_initiatives.rb +1 -1
- data/app/queries/decidim/initiatives/user_authorizations.rb +1 -1
- data/app/services/decidim/initiatives/initiative_search.rb +11 -102
- data/app/services/decidim/initiatives/pdf_signature_example.rb +15 -16
- data/app/services/decidim/initiatives/status_change_notifier.rb +1 -1
- data/app/views/decidim/initiatives/admin/initiatives/_form.html.erb +1 -1
- data/app/views/decidim/initiatives/admin/initiatives/edit.html.erb +0 -2
- data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +0 -1
- data/app/views/decidim/initiatives/admin/initiatives_settings/_form.html.erb +10 -0
- data/app/views/decidim/initiatives/admin/initiatives_settings/edit.html.erb +6 -0
- data/app/views/decidim/initiatives/admin/initiatives_type_scopes/edit.html.erb +0 -1
- data/app/views/decidim/initiatives/admin/initiatives_type_scopes/new.html.erb +0 -1
- data/app/views/decidim/initiatives/admin/initiatives_types/_form.html.erb +5 -1
- data/app/views/decidim/initiatives/admin/initiatives_types/edit.html.erb +0 -1
- data/app/views/decidim/initiatives/admin/initiatives_types/index.html.erb +0 -2
- data/app/views/decidim/initiatives/admin/initiatives_types/new.html.erb +0 -1
- data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +15 -28
- data/app/views/decidim/initiatives/create_initiative/previous_form.html.erb +1 -1
- data/app/views/decidim/initiatives/initiatives/_author.html.erb +1 -1
- data/app/views/decidim/initiatives/initiatives/_count.html.erb +1 -1
- data/app/views/decidim/initiatives/initiatives/_filters.html.erb +5 -5
- data/app/views/decidim/initiatives/initiatives/_form.html.erb +26 -30
- data/app/views/decidim/initiatives/initiatives/print.html.erb +2 -2
- data/app/views/decidim/initiatives/initiatives/show.html.erb +4 -2
- data/app/views/decidim/initiatives/initiatives_mailer/notify_creation.html.erb +2 -2
- data/app/views/layouts/decidim/_initiative_header.html.erb +1 -1
- data/app/views/layouts/decidim/_initiative_header_steps.html.erb +3 -1
- data/app/views/layouts/decidim/initiative_creation.html.erb +4 -1
- data/app/views/layouts/decidim/initiative_signature_creation.html.erb +4 -1
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +14 -10
- data/config/locales/bg.yml +1 -0
- data/config/locales/ca.yml +41 -29
- data/config/locales/cs.yml +42 -30
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +19 -38
- data/config/locales/el.yml +10 -6
- data/config/locales/en.yml +28 -17
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +33 -21
- data/config/locales/es-PY.yml +33 -21
- data/config/locales/es.yml +34 -22
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +80 -97
- data/config/locales/fi-plain.yml +28 -16
- data/config/locales/fi.yml +29 -17
- data/config/locales/fr-CA.yml +20 -24
- data/config/locales/fr.yml +17 -21
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +10 -5
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +29 -86
- data/config/locales/id-ID.yml +9 -5
- data/config/locales/is-IS.yml +8 -9
- data/config/locales/it.yml +12 -2
- data/config/locales/ja.yml +33 -20
- data/config/locales/ko.yml +1 -0
- data/config/locales/lb.yml +19 -15
- data/config/locales/lt.yml +1 -645
- data/config/locales/lv.yml +11 -6
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +10 -5
- data/config/locales/no.yml +11 -1
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +7 -3
- data/config/locales/pt-BR.yml +9 -6
- data/config/locales/pt.yml +10 -0
- data/config/locales/ro-RO.yml +15 -12
- data/config/locales/ru.yml +12 -10
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +13 -6
- data/config/locales/sl.yml +1 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +1 -0
- data/config/locales/sv.yml +15 -14
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +12 -1
- data/config/locales/uk.yml +12 -10
- data/config/locales/val-ES.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +10 -6
- data/config/locales/zh-TW.yml +1 -616
- data/db/migrate/20181003082010_fix_user_groups_ids_on_initiatives.rb +3 -18
- data/db/migrate/20220518053612_add_comments_enabled_to_initiative_types.rb +7 -0
- data/db/migrate/20220527130640_create_decidim_initiatives_settings.rb +10 -0
- data/lib/decidim/initiatives/admin_engine.rb +17 -2
- data/lib/decidim/initiatives/engine.rb +1 -2
- data/lib/decidim/initiatives/participatory_space.rb +3 -3
- data/lib/decidim/initiatives/test/factories.rb +34 -1
- data/lib/decidim/initiatives/version.rb +1 -1
- data/lib/gem_overrides/origami/date.rb +47 -0
- metadata +29 -56
- data/app/controllers/decidim/initiatives/admin/exports_controller.rb +0 -14
- data/config/environment.rb +0 -3
- data/config/locales/fa-IR.yml +0 -1
- data/config/locales/gn-PY.yml +0 -1
- data/config/locales/ka-GE.yml +0 -1
- data/config/locales/kaa.yml +0 -1
- data/config/locales/lo-LA.yml +0 -1
- data/config/locales/oc-FR.yml +0 -1
- data/config/locales/sq-AL.yml +0 -1
- data/config/locales/th-TH.yml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b8f445bf921e23456c088a9097081b230c135895702492b00e1a82090e30594
|
4
|
+
data.tar.gz: d23c120502ebcbf584a1cb4d4d9b64e1e1a47b95b927bee0cb18fe1b2004c495
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
4
|
-
participatory processes that must be created by an administrator,
|
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
|
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(
|
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 <
|
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 =
|
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 <
|
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 |
|
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 <
|
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 <
|
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 <
|
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 <
|
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 <
|
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 <
|
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
|
-
|
30
|
+
Decidim.traceability.perform_action!("update", initiative_type, @user) do
|
31
|
+
initiative_type.update(attributes)
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
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
|
-
|
61
|
-
result
|
64
|
+
}.merge(
|
65
|
+
attachment_attributes(:banner_image)
|
66
|
+
)
|
62
67
|
end
|
63
68
|
|
64
|
-
def
|
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 <
|
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 <
|
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 <
|
6
|
+
class CreateInitiative < Decidim::Command
|
7
7
|
include CurrentLocale
|
8
8
|
include ::Decidim::MultipleAttachmentsMethods
|
9
9
|
|
@@ -73,8 +73,7 @@ module Decidim
|
|
73
73
|
area: area,
|
74
74
|
signature_type: form.signature_type,
|
75
75
|
signature_end_date: signature_end_date,
|
76
|
-
state: "created"
|
77
|
-
hashtag: form.hashtag
|
76
|
+
state: "created"
|
78
77
|
)
|
79
78
|
end
|
80
79
|
|
@@ -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 <
|
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 <
|
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 <
|
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 <
|
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 <
|
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 <
|
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 <
|
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 <
|
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:
|
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
|
@@ -8,7 +8,7 @@ module Decidim
|
|
8
8
|
class CurrentInitiative
|
9
9
|
include InitiativeSlug
|
10
10
|
|
11
|
-
# Public: Matches the request against an
|
11
|
+
# Public: Matches the request against an initative and injects it
|
12
12
|
# into the environment.
|
13
13
|
#
|
14
14
|
# request - The request that holds the initiative relevant
|
@@ -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
|
@@ -41,7 +41,7 @@ module Decidim
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def membership_request
|
44
|
-
@membership_request ||= InitiativesCommitteeMember.
|
44
|
+
@membership_request ||= InitiativesCommitteeMember.find(params[:id])
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -14,7 +14,7 @@ module Decidim
|
|
14
14
|
|
15
15
|
helper ::Decidim::Admin::ResourcePermissionsHelper
|
16
16
|
helper Decidim::Initiatives::InitiativeHelper
|
17
|
-
helper Decidim::Initiatives::
|
17
|
+
helper Decidim::Initiatives::CreateInitiativeHelper
|
18
18
|
|
19
19
|
# GET /admin/initiatives
|
20
20
|
def index
|
@@ -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:
|
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
|
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
|
@@ -69,7 +69,7 @@ module Decidim
|
|
69
69
|
private
|
70
70
|
|
71
71
|
def current_initiative_type_scope
|
72
|
-
@current_initiative_type_scope ||= InitiativesTypeScope.
|
72
|
+
@current_initiative_type_scope ||= InitiativesTypeScope.find(params[:id])
|
73
73
|
end
|
74
74
|
|
75
75
|
def initiative_type_scope_form
|
@@ -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
|
-
|
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")
|
@@ -81,7 +84,7 @@ module Decidim
|
|
81
84
|
private
|
82
85
|
|
83
86
|
def current_initiative_type
|
84
|
-
@current_initiative_type ||= InitiativesType.
|
87
|
+
@current_initiative_type ||= InitiativesType.find(params[:id])
|
85
88
|
end
|
86
89
|
|
87
90
|
def initiative_type_form
|
@@ -11,13 +11,6 @@ module Decidim
|
|
11
11
|
::Decidim::Admin::Permissions,
|
12
12
|
::Decidim::Permissions)
|
13
13
|
|
14
|
-
before_action do
|
15
|
-
if Decidim::InitiativesType.joins(:scopes).where(organization: current_organization).all.empty?
|
16
|
-
flash[:alert] = t("index.uninitialized", scope: "decidim.initiatives")
|
17
|
-
redirect_to(decidim.root_path)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
14
|
def permissions_context
|
22
15
|
super.merge(
|
23
16
|
current_participatory_space: try(:current_participatory_space)
|
@@ -28,7 +28,7 @@ module Decidim
|
|
28
28
|
redirect_to initiatives_path, flash: {
|
29
29
|
notice: I18n.t(
|
30
30
|
"success",
|
31
|
-
scope:
|
31
|
+
scope: "decidim.initiatives.committee_requests.spawn"
|
32
32
|
)
|
33
33
|
}
|
34
34
|
end
|
@@ -70,7 +70,7 @@ module Decidim
|
|
70
70
|
private
|
71
71
|
|
72
72
|
def membership_request
|
73
|
-
@membership_request ||= InitiativesCommitteeMember.
|
73
|
+
@membership_request ||= InitiativesCommitteeMember.find(params[:id])
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|