decidim-initiatives 0.27.10 → 0.28.0.rc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_cell.rb +17 -18
- data/app/cells/decidim/initiatives/initiative_cell.rb +6 -1
- data/app/cells/decidim/initiatives/initiative_dropdown_metadata_cell.rb +19 -0
- data/app/cells/decidim/initiatives/initiative_g_cell.rb +31 -0
- data/app/cells/decidim/initiatives/initiative_metadata_g_cell.rb +62 -0
- data/app/cells/decidim/initiatives/initiative_s_cell.rb +15 -0
- data/app/cells/decidim/initiatives_votes/vote/show.erb +25 -19
- data/app/cells/decidim/initiatives_votes/vote_cell.rb +3 -1
- data/app/commands/decidim/initiatives/admin/accept_initiative.rb +40 -0
- data/app/commands/decidim/initiatives/admin/create_initiative_type.rb +1 -1
- data/app/commands/decidim/initiatives/admin/create_initiative_type_scope.rb +1 -1
- data/app/commands/decidim/initiatives/admin/discard_initiative.rb +40 -0
- data/app/commands/decidim/initiatives/admin/publish_initiative.rb +1 -1
- data/app/commands/decidim/initiatives/admin/reject_initiative.rb +40 -0
- 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 +1 -1
- data/app/commands/decidim/initiatives/admin/update_initiative_type_scope.rb +1 -1
- data/app/commands/decidim/initiatives/admin/update_initiatives_settings.rb +1 -1
- data/app/commands/decidim/initiatives/attachment_methods.rb +2 -24
- data/app/commands/decidim/initiatives/create_initiative.rb +19 -14
- 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 +9 -2
- data/app/commands/decidim/initiatives/validate_mobile_phone.rb +2 -2
- data/app/commands/decidim/initiatives/vote_initiative.rb +5 -5
- data/app/constraints/decidim/initiatives/current_initiative.rb +1 -1
- data/app/controllers/concerns/decidim/initiatives/admin/filterable.rb +2 -2
- data/app/controllers/concerns/decidim/initiatives/needs_initiative.rb +1 -1
- data/app/controllers/decidim/initiatives/admin/answers_controller.rb +3 -0
- data/app/controllers/decidim/initiatives/admin/committee_requests_controller.rb +2 -0
- data/app/controllers/decidim/initiatives/admin/components_controller.rb +3 -0
- data/app/controllers/decidim/initiatives/admin/initiative_attachments_controller.rb +2 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +17 -6
- data/app/controllers/decidim/initiatives/admin/initiatives_permissions_controller.rb +3 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_settings_controller.rb +2 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb +30 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb +14 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_types_permissions_controller.rb +21 -0
- data/app/controllers/decidim/initiatives/admin/moderations/reports_controller.rb +2 -2
- data/app/controllers/decidim/initiatives/admin/moderations_controller.rb +4 -2
- data/app/controllers/decidim/initiatives/application_controller.rb +0 -1
- data/app/controllers/decidim/initiatives/authorization_create_modals_controller.rb +25 -0
- data/app/controllers/decidim/initiatives/authorization_sign_modals_controller.rb +2 -2
- data/app/controllers/decidim/initiatives/committee_requests_controller.rb +0 -2
- data/app/controllers/decidim/initiatives/create_initiative_controller.rb +62 -115
- data/app/controllers/decidim/initiatives/initiative_signatures_controller.rb +113 -81
- data/app/controllers/decidim/initiatives/initiative_types_controller.rb +7 -0
- data/app/controllers/decidim/initiatives/initiatives_controller.rb +37 -17
- data/app/controllers/decidim/initiatives/versions_controller.rb +0 -1
- data/app/events/decidim/initiatives/admin/initiative_sent_to_technical_validation_event.rb +2 -2
- data/app/events/decidim/initiatives/admin/support_threshold_reached_event.rb +1 -1
- data/app/events/decidim/initiatives/approve_membership_request_event.rb +16 -13
- data/app/events/decidim/initiatives/create_initiative_event.rb +10 -7
- data/app/events/decidim/initiatives/endorse_initiative_event.rb +1 -1
- data/app/events/decidim/initiatives/extend_initiative_event.rb +1 -1
- data/app/events/decidim/initiatives/initiative_sent_to_technical_validation_event.rb +2 -2
- data/app/events/decidim/initiatives/milestone_completed_event.rb +1 -1
- data/app/events/decidim/initiatives/revoke_membership_request_event.rb +16 -13
- data/app/events/decidim/initiatives/spawn_committee_request_event.rb +16 -13
- data/app/forms/decidim/initiatives/admin/initiative_form.rb +1 -1
- data/app/forms/decidim/initiatives/initiative_form.rb +22 -31
- data/app/forms/decidim/initiatives/previous_form.rb +4 -0
- data/app/forms/decidim/initiatives/vote_form.rb +11 -11
- data/app/helpers/decidim/initiatives/admin/initiatives_helper.rb +1 -1
- data/app/helpers/decidim/initiatives/application_helper.rb +5 -62
- data/app/helpers/decidim/initiatives/initiative_helper.rb +48 -5
- data/app/helpers/decidim/initiatives/initiatives_helper.rb +33 -12
- data/app/jobs/decidim/initiatives/export_initiatives_job.rb +1 -1
- data/app/models/decidim/initiative.rb +16 -14
- data/app/models/decidim/initiatives_vote.rb +1 -1
- data/app/packs/entrypoints/decidim_initiatives.js +3 -0
- data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_initiatives.svg +42 -1
- data/app/packs/src/decidim/initiatives/application.js +0 -1
- data/app/packs/src/decidim/initiatives/scoped_type.js +1 -1
- data/app/packs/stylesheets/decidim/initiatives/initiatives-votes.scss +21 -21
- data/app/packs/stylesheets/decidim/initiatives/print-initiative.scss +47 -35
- data/app/packs/stylesheets/initiatives.scss +171 -0
- data/app/permissions/decidim/initiatives/permissions.rb +3 -13
- data/app/presenters/decidim/initiatives/admin_log/initiative_presenter.rb +2 -2
- data/app/presenters/decidim/initiatives/admin_log/initiatives_settings_presenter.rb +2 -2
- data/app/presenters/decidim/initiatives/admin_log/initiatives_type_presenter.rb +2 -2
- data/app/queries/decidim/initiatives/organization_prioritized_initiatives.rb +1 -1
- data/app/queries/decidim/initiatives/similar_initiatives.rb +2 -2
- 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/pdf_signature_example.rb +44 -52
- data/app/views/decidim/initiatives/_modal.html.erb +15 -0
- data/app/views/decidim/initiatives/admin/answers/_info_initiative.html.erb +21 -19
- data/app/views/decidim/initiatives/admin/answers/edit.html.erb +41 -27
- data/app/views/decidim/initiatives/admin/committee_requests/index.html.erb +41 -48
- data/app/views/decidim/initiatives/admin/exports/_dropdown.html.erb +8 -7
- data/app/views/decidim/initiatives/admin/initiatives/_form.html.erb +111 -95
- data/app/views/decidim/initiatives/admin/initiatives/_initiative_attachments.erb +7 -7
- data/app/views/decidim/initiatives/admin/initiatives/_signatures.html.erb +87 -0
- data/app/views/decidim/initiatives/admin/initiatives/edit.html.erb +72 -60
- data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.html.erb +8 -0
- data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.pdf.erb +5 -78
- data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +76 -75
- data/app/views/decidim/initiatives/admin/initiatives_settings/_form.html.erb +7 -8
- data/app/views/decidim/initiatives/admin/initiatives_settings/edit.html.erb +17 -5
- data/app/views/decidim/initiatives/admin/initiatives_type_scopes/_form.html.erb +11 -6
- data/app/views/decidim/initiatives/admin/initiatives_type_scopes/edit.html.erb +16 -22
- data/app/views/decidim/initiatives/admin/initiatives_type_scopes/new.html.erb +17 -15
- data/app/views/decidim/initiatives/admin/initiatives_types/_form.html.erb +93 -76
- data/app/views/decidim/initiatives/admin/initiatives_types/_initiative_type_scopes.html.erb +35 -33
- data/app/views/decidim/initiatives/admin/initiatives_types/edit.html.erb +16 -12
- data/app/views/decidim/initiatives/admin/initiatives_types/index.html.erb +39 -48
- data/app/views/decidim/initiatives/admin/initiatives_types/new.html.erb +16 -9
- data/app/views/decidim/initiatives/committee_requests/new.html.erb +21 -19
- data/app/views/decidim/initiatives/create_initiative/_share_committee_link.html.erb +15 -20
- data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +62 -100
- data/app/views/decidim/initiatives/create_initiative/finish.html.erb +24 -28
- data/app/views/decidim/initiatives/create_initiative/promotal_committee.html.erb +15 -17
- data/app/views/decidim/initiatives/create_initiative/select_initiative_type.html.erb +32 -46
- data/app/views/decidim/initiatives/initiative_signatures/_wizard_steps.html.erb +15 -19
- data/app/views/decidim/initiatives/initiative_signatures/fill_personal_data.html.erb +25 -36
- data/app/views/decidim/initiatives/initiative_signatures/finish.html.erb +5 -16
- data/app/views/decidim/initiatives/initiative_signatures/sms_code.html.erb +8 -19
- data/app/views/decidim/initiatives/initiative_signatures/sms_phone_number.html.erb +8 -20
- data/app/views/decidim/initiatives/initiatives/_committee_members.html.erb +48 -66
- data/app/views/decidim/initiatives/initiatives/_form.html.erb +49 -95
- data/app/views/decidim/initiatives/initiatives/_initiative_badge.html.erb +3 -5
- data/app/views/decidim/initiatives/initiatives/_initiative_hero.html.erb +13 -0
- data/app/views/decidim/initiatives/initiatives/_initiatives.html.erb +6 -15
- data/app/views/decidim/initiatives/initiatives/_interactions.html.erb +1 -1
- data/app/views/decidim/initiatives/initiatives/_new_initiative_button.html.erb +28 -0
- data/app/views/decidim/initiatives/initiatives/_progress_bar.html.erb +2 -6
- data/app/views/decidim/initiatives/initiatives/_result.html.erb +15 -21
- data/app/views/decidim/initiatives/initiatives/_send_to_technical_validation.html.erb +3 -3
- data/app/views/decidim/initiatives/initiatives/_tags_type.html.erb +1 -0
- data/app/views/decidim/initiatives/initiatives/_vote_button.html.erb +9 -9
- data/app/views/decidim/initiatives/initiatives/_vote_cabin.html.erb +7 -7
- data/app/views/decidim/initiatives/initiatives/edit.html.erb +63 -68
- data/app/views/decidim/initiatives/initiatives/index.html.erb +17 -18
- data/app/views/decidim/initiatives/initiatives/index.js.erb +0 -5
- data/app/views/decidim/initiatives/initiatives/print.html.erb +123 -120
- data/app/views/decidim/initiatives/initiatives/show.html.erb +188 -72
- data/app/views/decidim/initiatives/initiatives_mailer/notify_creation.html.erb +2 -2
- data/app/views/decidim/initiatives/initiatives_type_scopes/search.html.erb +2 -1
- data/app/views/decidim/initiatives/versions/show.html.erb +15 -6
- data/app/views/layouts/decidim/_initiative_creation_header.html.erb +17 -28
- data/app/views/layouts/decidim/_initiative_header.html.erb +3 -23
- data/app/views/layouts/decidim/_initiative_header_steps.html.erb +4 -12
- data/app/views/layouts/decidim/_initiative_signature_creation_header.html.erb +5 -26
- data/app/views/layouts/decidim/admin/initiative.html.erb +12 -13
- data/app/views/layouts/decidim/admin/initiatives.html.erb +40 -11
- data/app/views/layouts/decidim/initiative.html.erb +16 -11
- data/app/views/layouts/decidim/initiative_creation.html.erb +7 -18
- data/app/views/layouts/decidim/initiative_head.html.erb +15 -0
- data/app/views/layouts/decidim/initiative_signature_creation.html.erb +3 -11
- data/config/assets.rb +0 -1
- data/config/initializers/wicked_pdf.rb +1 -1
- data/config/locales/ar.yml +1 -96
- data/config/locales/bg.yml +0 -642
- data/config/locales/ca.yml +76 -115
- data/config/locales/cs.yml +70 -109
- data/config/locales/de.yml +78 -117
- data/config/locales/el.yml +1 -98
- data/config/locales/en.yml +69 -108
- data/config/locales/es-MX.yml +65 -104
- data/config/locales/es-PY.yml +65 -104
- data/config/locales/es.yml +73 -112
- data/config/locales/eu.yml +66 -105
- data/config/locales/fi-plain.yml +67 -106
- data/config/locales/fi.yml +68 -107
- data/config/locales/fr-CA.yml +69 -108
- data/config/locales/fr.yml +67 -106
- data/config/locales/ga-IE.yml +0 -35
- data/config/locales/gl.yml +1 -89
- data/config/locales/hu.yml +25 -114
- data/config/locales/id-ID.yml +1 -89
- data/config/locales/is-IS.yml +1 -60
- data/config/locales/it.yml +6 -111
- data/config/locales/ja.yml +65 -111
- data/config/locales/lb.yml +6 -88
- data/config/locales/lt.yml +52 -103
- data/config/locales/lv.yml +1 -99
- data/config/locales/nl.yml +6 -104
- data/config/locales/no.yml +6 -114
- data/config/locales/pl.yml +6 -158
- data/config/locales/pt-BR.yml +23 -146
- data/config/locales/pt.yml +6 -111
- data/config/locales/ro-RO.yml +13 -108
- data/config/locales/ru.yml +1 -68
- data/config/locales/sk.yml +1 -85
- data/config/locales/sl.yml +3 -5
- data/config/locales/sv.yml +25 -120
- data/config/locales/tr-TR.yml +9 -110
- data/config/locales/uk.yml +1 -68
- data/config/locales/zh-CN.yml +6 -102
- data/config/locales/zh-TW.yml +31 -95
- data/db/migrate/20171017091734_add_scopes_for_all_initiative_types.rb +1 -1
- data/db/migrate/20171017095143_update_initiative_scoped_type.rb +1 -1
- data/db/migrate/20191002082220_move_signature_type_to_initative_type.rb +1 -1
- data/lib/decidim/api/initiative_committee_member_type.rb +2 -2
- data/lib/decidim/initiatives/admin_engine.rb +13 -93
- data/lib/decidim/initiatives/content_blocks/registry_manager.rb +22 -0
- data/lib/decidim/initiatives/engine.rb +45 -23
- data/lib/decidim/initiatives/menu.rb +150 -0
- data/lib/decidim/initiatives/participatory_space.rb +6 -91
- data/lib/decidim/initiatives/query_extensions.rb +5 -5
- data/lib/decidim/initiatives/seeds.rb +95 -0
- data/lib/decidim/initiatives/test/factories.rb +43 -48
- data/lib/decidim/initiatives/version.rb +1 -1
- data/lib/decidim/initiatives.rb +1 -1
- data/lib/tasks/decidim_initiatives.rake +2 -2
- data/lib/tasks/initiatives/upgrade/decidim_initiatives_upgrade_tasks.rake +1 -1
- metadata +51 -81
- data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +0 -28
- data/app/cells/decidim/initiatives/initiative_m/author.erb +0 -10
- data/app/cells/decidim/initiatives/initiative_m/footer.erb +0 -28
- data/app/cells/decidim/initiatives/initiative_m/tags.erb +0 -9
- data/app/cells/decidim/initiatives/initiative_m_cell.rb +0 -77
- data/app/controllers/decidim/initiatives/widgets_controller.rb +0 -44
- data/app/packs/stylesheets/decidim/initiatives/admin.scss +0 -33
- data/app/packs/stylesheets/decidim/initiatives/initiatives.scss +0 -64
- data/app/packs/stylesheets/decidim/initiatives/popularity_item.scss +0 -76
- data/app/packs/stylesheets/decidim/initiatives/statistics.scss +0 -15
- data/app/views/decidim/initiatives/create_initiative/_finish_help.html.erb +0 -2
- data/app/views/decidim/initiatives/create_initiative/previous_form.html.erb +0 -40
- data/app/views/decidim/initiatives/create_initiative/show_similar_initiatives.html.erb +0 -23
- data/app/views/decidim/initiatives/initiatives/_author.html.erb +0 -35
- data/app/views/decidim/initiatives/initiatives/_count.html.erb +0 -1
- data/app/views/decidim/initiatives/initiatives/_filters.html.erb +0 -33
- data/app/views/decidim/initiatives/initiatives/_filters_small_view.html.erb +0 -18
- data/app/views/decidim/initiatives/initiatives/_index_header.html.erb +0 -44
- data/app/views/decidim/initiatives/initiatives/_tags.html.erb +0 -7
- data/app/views/decidim/initiatives/versions/index.html.erb +0 -8
- data/config/locales/he-IL.yml +0 -1
- data/db/seeds/city.jpeg +0 -0
- data/db/seeds/city2.jpeg +0 -0
- data/decidim-initiatives.gemspec +0 -38
- data/lib/decidim/initiatives/initiatives_filter_form_builder.rb +0 -56
- data/lib/gem_overrides/origami/date.rb +0 -47
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "decidim/components/namer"
|
4
|
+
|
3
5
|
module Decidim
|
4
6
|
module Initiatives
|
5
7
|
# A command with all the business logic that creates a new initiative.
|
6
8
|
class CreateInitiative < Decidim::Command
|
7
9
|
include CurrentLocale
|
8
10
|
include ::Decidim::MultipleAttachmentsMethods
|
11
|
+
include ::Decidim::GalleryMethods
|
9
12
|
|
10
13
|
# Public: Initializes the command.
|
11
14
|
#
|
@@ -19,7 +22,7 @@ module Decidim
|
|
19
22
|
# Executes the command. Broadcasts these events:
|
20
23
|
#
|
21
24
|
# - :ok when everything is valid.
|
22
|
-
# - :invalid if the form
|
25
|
+
# - :invalid if the form was not valid and we could not proceed.
|
23
26
|
#
|
24
27
|
# Returns nothing.
|
25
28
|
def call
|
@@ -30,6 +33,11 @@ module Decidim
|
|
30
33
|
return broadcast(:invalid) if attachments_invalid?
|
31
34
|
end
|
32
35
|
|
36
|
+
if process_gallery?
|
37
|
+
build_gallery
|
38
|
+
return broadcast(:invalid) if gallery_invalid?
|
39
|
+
end
|
40
|
+
|
33
41
|
initiative = create_initiative
|
34
42
|
|
35
43
|
if initiative.persisted?
|
@@ -50,8 +58,10 @@ module Decidim
|
|
50
58
|
|
51
59
|
initiative.transaction do
|
52
60
|
initiative.save!
|
61
|
+
|
53
62
|
@attached_to = initiative
|
54
63
|
create_attachments if process_attachments?
|
64
|
+
create_gallery if process_gallery?
|
55
65
|
|
56
66
|
create_components_for(initiative)
|
57
67
|
send_notification(initiative)
|
@@ -68,21 +78,16 @@ module Decidim
|
|
68
78
|
title: { current_locale => form.title },
|
69
79
|
description: { current_locale => form.description },
|
70
80
|
author: current_user,
|
81
|
+
scoped_type:,
|
82
|
+
signature_type: form.type.signature_type,
|
71
83
|
decidim_user_group_id: form.decidim_user_group_id,
|
72
|
-
|
73
|
-
|
74
|
-
signature_type: form.signature_type,
|
75
|
-
signature_end_date: signature_end_date,
|
76
|
-
state: "created",
|
77
|
-
hashtag: form.hashtag
|
84
|
+
decidim_area_id: form.area_id,
|
85
|
+
state: "created"
|
78
86
|
)
|
79
87
|
end
|
80
88
|
|
81
89
|
def scoped_type
|
82
|
-
InitiativesTypeScope.find_by(
|
83
|
-
type: form.initiative_type,
|
84
|
-
scope: form.scope
|
85
|
-
)
|
90
|
+
InitiativesTypeScope.order(:id).find_by(type: form.type)
|
86
91
|
end
|
87
92
|
|
88
93
|
def signature_end_date
|
@@ -112,7 +117,7 @@ module Decidim
|
|
112
117
|
|
113
118
|
def initialize_pages(component)
|
114
119
|
Decidim::Pages::CreatePage.call(component) do
|
115
|
-
on(:invalid) { raise "
|
120
|
+
on(:invalid) { raise "Cannot create page" }
|
116
121
|
end
|
117
122
|
end
|
118
123
|
|
@@ -130,7 +135,7 @@ module Decidim
|
|
130
135
|
.from_params(followable_gid: initiative.to_signed_global_id.to_s)
|
131
136
|
.with_context(
|
132
137
|
current_organization: initiative.organization,
|
133
|
-
current_user:
|
138
|
+
current_user:
|
134
139
|
)
|
135
140
|
|
136
141
|
Decidim::CreateFollow.new(form, current_user).call
|
@@ -141,7 +146,7 @@ module Decidim
|
|
141
146
|
.from_params(initiative_id: initiative.id, user_id: initiative.decidim_author_id, state: "accepted")
|
142
147
|
.with_context(
|
143
148
|
current_organization: initiative.organization,
|
144
|
-
current_user:
|
149
|
+
current_user:
|
145
150
|
)
|
146
151
|
|
147
152
|
Decidim::Initiatives::SpawnCommitteeRequest.new(form, current_user).call
|
@@ -17,7 +17,7 @@ module Decidim
|
|
17
17
|
# Executes the command. Broadcasts these events:
|
18
18
|
#
|
19
19
|
# - :ok when everything is valid.
|
20
|
-
# - :invalid if the form
|
20
|
+
# - :invalid if the form was not valid and we could not proceed.
|
21
21
|
#
|
22
22
|
# Returns nothing.
|
23
23
|
def call
|
@@ -46,7 +46,7 @@ module Decidim
|
|
46
46
|
event: "decidim.events.initiatives.initiative_sent_to_technical_validation",
|
47
47
|
event_class: Decidim::Initiatives::InitiativeSentToTechnicalValidationEvent,
|
48
48
|
resource: initiative,
|
49
|
-
affected_users
|
49
|
+
affected_users:,
|
50
50
|
force_send: true
|
51
51
|
}
|
52
52
|
|
@@ -17,7 +17,7 @@ module Decidim
|
|
17
17
|
# Executes the command. Broadcasts these events:
|
18
18
|
#
|
19
19
|
# - :ok when everything is valid.
|
20
|
-
# - :invalid if the form
|
20
|
+
# - :invalid if the form was not valid and we could not proceed.
|
21
21
|
#
|
22
22
|
# Returns nothing.
|
23
23
|
def call
|
@@ -16,7 +16,7 @@ module Decidim
|
|
16
16
|
# Executes the command. Broadcasts these events:
|
17
17
|
#
|
18
18
|
# - :ok when everything is valid, together with the initiative.
|
19
|
-
# - :invalid if the form
|
19
|
+
# - :invalid if the form was not valid and we could not proceed.
|
20
20
|
#
|
21
21
|
# Returns nothing.
|
22
22
|
def call
|
@@ -23,7 +23,7 @@ module Decidim
|
|
23
23
|
# Executes the command. Broadcasts these events:
|
24
24
|
#
|
25
25
|
# - :ok when everything is valid.
|
26
|
-
# - :invalid if the form
|
26
|
+
# - :invalid if the form was not valid and we could not proceed.
|
27
27
|
#
|
28
28
|
# Returns nothing.
|
29
29
|
def call
|
@@ -34,6 +34,11 @@ module Decidim
|
|
34
34
|
return broadcast(:invalid) if attachments_invalid?
|
35
35
|
end
|
36
36
|
|
37
|
+
if process_gallery?
|
38
|
+
build_gallery
|
39
|
+
return broadcast(:invalid) if gallery_invalid?
|
40
|
+
end
|
41
|
+
|
37
42
|
@initiative = Decidim.traceability.update!(
|
38
43
|
initiative,
|
39
44
|
current_user,
|
@@ -43,6 +48,7 @@ module Decidim
|
|
43
48
|
photo_cleanup!
|
44
49
|
document_cleanup!
|
45
50
|
create_attachments if process_attachments?
|
51
|
+
create_gallery if process_gallery?
|
46
52
|
|
47
53
|
broadcast(:ok, initiative)
|
48
54
|
rescue ActiveRecord::RecordInvalid
|
@@ -57,7 +63,8 @@ module Decidim
|
|
57
63
|
attrs = {
|
58
64
|
title: { current_locale => form.title },
|
59
65
|
description: { current_locale => form.description },
|
60
|
-
hashtag: form.hashtag
|
66
|
+
hashtag: form.hashtag,
|
67
|
+
decidim_user_group_id: form.decidim_user_group_id
|
61
68
|
}
|
62
69
|
|
63
70
|
if form.signature_type_updatable?
|
@@ -18,9 +18,9 @@ module Decidim
|
|
18
18
|
#
|
19
19
|
# - :ok when everything is valid. Returns the verification metadata of
|
20
20
|
# the form.
|
21
|
-
# - :invalid if the user
|
21
|
+
# - :invalid if the user does not have an authorization for sms in ok
|
22
22
|
# status or the phone number associated with its
|
23
|
-
# authorization
|
23
|
+
# authorization does not match the form number.
|
24
24
|
def call
|
25
25
|
return broadcast(:invalid) unless authorized? && phone_match?
|
26
26
|
|
@@ -14,7 +14,7 @@ module Decidim
|
|
14
14
|
# Executes the command. Broadcasts these events:
|
15
15
|
#
|
16
16
|
# - :ok when everything is valid, together with the proposal vote.
|
17
|
-
# - :invalid if the form
|
17
|
+
# - :invalid if the form was not valid and we could not proceed.
|
18
18
|
#
|
19
19
|
# Returns nothing.
|
20
20
|
def call
|
@@ -48,9 +48,9 @@ module Decidim
|
|
48
48
|
initiative.votes.create!(
|
49
49
|
author: form.signer,
|
50
50
|
encrypted_metadata: form.encrypted_metadata,
|
51
|
-
timestamp
|
51
|
+
timestamp:,
|
52
52
|
hash_id: form.hash_id,
|
53
|
-
scope:
|
53
|
+
scope:
|
54
54
|
)
|
55
55
|
end
|
56
56
|
end
|
@@ -88,13 +88,13 @@ module Decidim
|
|
88
88
|
affected_users: [initiative.author],
|
89
89
|
followers: initiative.followers - [initiative.author],
|
90
90
|
extra: {
|
91
|
-
percentage:
|
91
|
+
percentage:
|
92
92
|
}
|
93
93
|
)
|
94
94
|
end
|
95
95
|
|
96
96
|
def notify_support_threshold_reached(before, after)
|
97
|
-
#
|
97
|
+
# Do not need to notify if threshold has already been reached
|
98
98
|
return if before == after || after != 100
|
99
99
|
|
100
100
|
Decidim::EventsManager.publish(
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Initiatives
|
5
|
-
# This class infers the current initiative we
|
5
|
+
# This class infers the current initiative we are scoped to by
|
6
6
|
# looking at the request parameters and the organization in the request
|
7
7
|
# environment, and injects it into the environment.
|
8
8
|
class CurrentInitiative
|
@@ -38,11 +38,11 @@ module Decidim
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def translated_type_id_eq(id)
|
41
|
-
translated_attribute(Decidim::InitiativesType.find_by(id:
|
41
|
+
translated_attribute(Decidim::InitiativesType.find_by(id:).title[I18n.locale.to_s])
|
42
42
|
end
|
43
43
|
|
44
44
|
def translated_decidim_area_id_eq(id)
|
45
|
-
translated_attribute(Decidim::Area.find_by(id:
|
45
|
+
translated_attribute(Decidim::Area.find_by(id:).name[I18n.locale.to_s])
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -4,7 +4,7 @@ require "active_support/concern"
|
|
4
4
|
|
5
5
|
module Decidim
|
6
6
|
module Initiatives
|
7
|
-
# This module, when injected into a controller, ensures there
|
7
|
+
# This module, when injected into a controller, ensures there is an
|
8
8
|
# initiative available and deducts it from the context.
|
9
9
|
module NeedsInitiative
|
10
10
|
extend ActiveSupport::Concern
|
@@ -6,6 +6,9 @@ module Decidim
|
|
6
6
|
# Controller used to manage the initiatives answers
|
7
7
|
class AnswersController < Decidim::Initiatives::Admin::ApplicationController
|
8
8
|
include Decidim::Initiatives::NeedsInitiative
|
9
|
+
include Decidim::Admin::ParticipatorySpaceAdminBreadcrumb
|
10
|
+
|
11
|
+
add_breadcrumb_item_from_menu :admin_initiative_actions_menu
|
9
12
|
|
10
13
|
helper Decidim::Initiatives::InitiativeHelper
|
11
14
|
layout "decidim/admin/initiatives"
|
@@ -7,6 +7,8 @@ module Decidim
|
|
7
7
|
class CommitteeRequestsController < Decidim::Initiatives::Admin::ApplicationController
|
8
8
|
include InitiativeAdmin
|
9
9
|
|
10
|
+
add_breadcrumb_item_from_menu :admin_initiative_actions_menu
|
11
|
+
|
10
12
|
# GET /admin/initiatives/:initiative_id/committee_requests
|
11
13
|
def index
|
12
14
|
enforce_permission_to :index, :initiative_committee_member
|
@@ -11,6 +11,7 @@ module Decidim
|
|
11
11
|
include Decidim::Initiatives::SingleInitiativeType
|
12
12
|
include Decidim::Initiatives::TypeSelectorOptions
|
13
13
|
include Decidim::Initiatives::Admin::Filterable
|
14
|
+
include Decidim::Admin::ParticipatorySpaceAdminBreadcrumb
|
14
15
|
|
15
16
|
helper ::Decidim::Admin::ResourcePermissionsHelper
|
16
17
|
helper Decidim::Initiatives::InitiativeHelper
|
@@ -83,22 +84,31 @@ module Decidim
|
|
83
84
|
# DELETE /admin/initiatives/:id/discard
|
84
85
|
def discard
|
85
86
|
enforce_permission_to :discard, :initiative, initiative: current_initiative
|
86
|
-
current_initiative
|
87
|
-
|
87
|
+
DiscardInitiative.call(current_initiative, current_user) do
|
88
|
+
on(:ok) do
|
89
|
+
redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
|
90
|
+
end
|
91
|
+
end
|
88
92
|
end
|
89
93
|
|
90
94
|
# POST /admin/initiatives/:id/accept
|
91
95
|
def accept
|
92
96
|
enforce_permission_to :accept, :initiative, initiative: current_initiative
|
93
|
-
current_initiative
|
94
|
-
|
97
|
+
AcceptInitiative.call(current_initiative, current_user) do
|
98
|
+
on(:ok) do
|
99
|
+
redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
|
100
|
+
end
|
101
|
+
end
|
95
102
|
end
|
96
103
|
|
97
104
|
# DELETE /admin/initiatives/:id/reject
|
98
105
|
def reject
|
99
106
|
enforce_permission_to :reject, :initiative, initiative: current_initiative
|
100
|
-
current_initiative
|
101
|
-
|
107
|
+
RejectInitiative.call(current_initiative, current_user) do
|
108
|
+
on(:ok) do
|
109
|
+
redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
|
110
|
+
end
|
111
|
+
end
|
102
112
|
end
|
103
113
|
|
104
114
|
# GET /admin/initiatives/:id/send_to_technical_validation
|
@@ -167,6 +177,7 @@ module Decidim
|
|
167
177
|
format.pdf do
|
168
178
|
send_data(output, filename: "votes_#{current_initiative.id}.pdf", type: "application/pdf")
|
169
179
|
end
|
180
|
+
format.html
|
170
181
|
end
|
171
182
|
end
|
172
183
|
|
@@ -7,6 +7,9 @@ module Decidim
|
|
7
7
|
# permissions in the admin panel.
|
8
8
|
class InitiativesPermissionsController < Decidim::Admin::ResourcePermissionsController
|
9
9
|
include Decidim::Initiatives::NeedsInitiative
|
10
|
+
include Decidim::Admin::ParticipatorySpaceAdminBreadcrumb
|
11
|
+
|
12
|
+
add_breadcrumb_item_from_menu :admin_initiative_actions_menu
|
10
13
|
|
11
14
|
layout "decidim/admin/initiatives"
|
12
15
|
|
@@ -8,6 +8,8 @@ module Decidim
|
|
8
8
|
class InitiativesSettingsController < Decidim::Initiatives::Admin::ApplicationController
|
9
9
|
layout "decidim/admin/initiatives"
|
10
10
|
|
11
|
+
add_breadcrumb_item_from_menu :admin_initiatives_menu
|
12
|
+
|
11
13
|
# GET /admin/initiatives_settings/edit
|
12
14
|
def edit
|
13
15
|
enforce_permission_to :update, :initiatives_settings, initiatives_settings: current_initiatives_settings
|
@@ -5,6 +5,11 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# Controller used to manage the available initiative type scopes
|
7
7
|
class InitiativesTypeScopesController < Decidim::Initiatives::Admin::ApplicationController
|
8
|
+
include Decidim::TranslatableAttributes
|
9
|
+
|
10
|
+
before_action :set_controller_breadcrumb
|
11
|
+
add_breadcrumb_item_from_menu :admin_initiatives_menu
|
12
|
+
|
8
13
|
helper_method :current_initiative_type_scope
|
9
14
|
|
10
15
|
# GET /admin/initiatives_types/:initiatives_type_id/initiatives_type_scopes/new
|
@@ -68,10 +73,35 @@ module Decidim
|
|
68
73
|
|
69
74
|
private
|
70
75
|
|
76
|
+
def set_controller_breadcrumb
|
77
|
+
controller_breadcrumb_items.append(
|
78
|
+
{
|
79
|
+
label: translated_attribute(current_initiative_type.title),
|
80
|
+
url: edit_initiatives_type_path(current_initiative_type),
|
81
|
+
active: false
|
82
|
+
},
|
83
|
+
{
|
84
|
+
label: t("initiative_type_scopes", scope: "decidim.admin.menu"),
|
85
|
+
active: true
|
86
|
+
}
|
87
|
+
)
|
88
|
+
|
89
|
+
if params[:id].present?
|
90
|
+
controller_breadcrumb_items << {
|
91
|
+
label: translated_attribute(current_initiative_type_scope.scope_name),
|
92
|
+
active: true
|
93
|
+
}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
71
97
|
def current_initiative_type_scope
|
72
98
|
@current_initiative_type_scope ||= InitiativesTypeScope.joins(:type).where(decidim_initiatives_types: { organization: current_organization }).find(params[:id])
|
73
99
|
end
|
74
100
|
|
101
|
+
def current_initiative_type
|
102
|
+
@current_initiative_type ||= InitiativesType.find(params[:initiatives_type_id])
|
103
|
+
end
|
104
|
+
|
75
105
|
def initiative_type_scope_form
|
76
106
|
form(Decidim::Initiatives::Admin::InitiativeTypeScopeForm)
|
77
107
|
end
|
@@ -6,6 +6,11 @@ module Decidim
|
|
6
6
|
# Controller used to manage the available initiative types for the current
|
7
7
|
# organization.
|
8
8
|
class InitiativesTypesController < Decidim::Initiatives::Admin::ApplicationController
|
9
|
+
include Decidim::TranslatableAttributes
|
10
|
+
before_action :set_controller_breadcrumb, except: [:index, :new, :create]
|
11
|
+
|
12
|
+
add_breadcrumb_item_from_menu :admin_initiatives_menu
|
13
|
+
|
9
14
|
helper ::Decidim::Admin::ResourcePermissionsHelper
|
10
15
|
helper_method :current_initiative_type
|
11
16
|
|
@@ -83,6 +88,15 @@ module Decidim
|
|
83
88
|
|
84
89
|
private
|
85
90
|
|
91
|
+
def set_controller_breadcrumb
|
92
|
+
controller_breadcrumb_items <<
|
93
|
+
{
|
94
|
+
label: translated_attribute(current_initiative_type.title),
|
95
|
+
url: edit_initiatives_type_path(current_initiative_type),
|
96
|
+
active: true
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
86
100
|
def current_initiative_type
|
87
101
|
@current_initiative_type ||= InitiativesType.where(organization: current_organization).find(params[:id])
|
88
102
|
end
|
@@ -6,6 +6,11 @@ module Decidim
|
|
6
6
|
# Controller that allows managing initiatives types
|
7
7
|
# permissions in the admin panel.
|
8
8
|
class InitiativesTypesPermissionsController < Decidim::Admin::ResourcePermissionsController
|
9
|
+
include Decidim::TranslatableAttributes
|
10
|
+
|
11
|
+
before_action :set_controller_breadcrumb
|
12
|
+
add_breadcrumb_item_from_menu :admin_initiatives_menu
|
13
|
+
|
9
14
|
layout "decidim/admin/initiatives"
|
10
15
|
|
11
16
|
register_permissions(::Decidim::Initiatives::Admin::InitiativesTypesPermissionsController,
|
@@ -15,6 +20,22 @@ module Decidim
|
|
15
20
|
def permission_class_chain
|
16
21
|
::Decidim.permissions_registry.chain_for(::Decidim::Initiatives::Admin::InitiativesTypesPermissionsController)
|
17
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def set_controller_breadcrumb
|
27
|
+
controller_breadcrumb_items.append(
|
28
|
+
{
|
29
|
+
label: translated_attribute(resource.title),
|
30
|
+
url: edit_initiatives_type_path(resource),
|
31
|
+
active: false
|
32
|
+
},
|
33
|
+
{
|
34
|
+
label: t("permissions", scope: "decidim.admin.actions"),
|
35
|
+
active: true
|
36
|
+
}
|
37
|
+
)
|
38
|
+
end
|
18
39
|
end
|
19
40
|
end
|
20
41
|
end
|
@@ -4,12 +4,12 @@ module Decidim
|
|
4
4
|
module Initiatives
|
5
5
|
module Admin
|
6
6
|
module Moderations
|
7
|
-
# This controller allows admins to manage moderation reports in an
|
7
|
+
# This controller allows admins to manage moderation reports in an initiative.
|
8
8
|
class ReportsController < Decidim::Admin::Moderations::ReportsController
|
9
9
|
include InitiativeAdmin
|
10
10
|
|
11
11
|
def permissions_context
|
12
|
-
super.merge(current_participatory_space:
|
12
|
+
super.merge(current_participatory_space:)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,12 +3,14 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Initiatives
|
5
5
|
module Admin
|
6
|
-
# This controller allows admins to manage moderations in an
|
6
|
+
# This controller allows admins to manage moderations in an initiative.
|
7
7
|
class ModerationsController < Decidim::Admin::ModerationsController
|
8
8
|
include InitiativeAdmin
|
9
9
|
|
10
|
+
add_breadcrumb_item_from_menu :admin_initiative_menu
|
11
|
+
|
10
12
|
def permissions_context
|
11
|
-
super.merge(current_participatory_space:
|
13
|
+
super.merge(current_participatory_space:)
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -5,7 +5,6 @@ module Decidim
|
|
5
5
|
# The main admin application controller for initiatives
|
6
6
|
class ApplicationController < Decidim::ApplicationController
|
7
7
|
include NeedsPermission
|
8
|
-
|
9
8
|
register_permissions(::Decidim::Initiatives::ApplicationController,
|
10
9
|
::Decidim::Initiatives::Permissions,
|
11
10
|
::Decidim::Admin::Permissions,
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
class AuthorizationCreateModalsController < Decidim::Initiatives::ApplicationController
|
6
|
+
helper_method :authorizations, :authorize_action_path
|
7
|
+
layout false
|
8
|
+
|
9
|
+
def show
|
10
|
+
@initiative_type = Decidim::InitiativesType.find_by(id: params[:slug], organization: current_organization)
|
11
|
+
render template: "decidim/authorization_modals/show"
|
12
|
+
end
|
13
|
+
|
14
|
+
def authorize_action_path(handler_name)
|
15
|
+
authorizations.status_for(handler_name).current_path(redirect_url: URI(request.referer).path)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def authorizations
|
21
|
+
@authorizations ||= action_authorized_to("create", permissions_holder: @initiative_type)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -12,12 +12,12 @@ module Decidim
|
|
12
12
|
render template: "decidim/authorization_modals/show"
|
13
13
|
end
|
14
14
|
|
15
|
-
private
|
16
|
-
|
17
15
|
def authorize_action_path(handler_name)
|
18
16
|
authorizations.status_for(handler_name).current_path(redirect_url: URI(request.referer).path)
|
19
17
|
end
|
20
18
|
|
19
|
+
private
|
20
|
+
|
21
21
|
def authorizations
|
22
22
|
@authorizations ||= action_authorized_to("vote", resource: current_initiative, permissions_holder: current_initiative.type)
|
23
23
|
end
|
@@ -9,8 +9,6 @@ module Decidim
|
|
9
9
|
helper InitiativeHelper
|
10
10
|
helper Decidim::ActionAuthorizationHelper
|
11
11
|
|
12
|
-
layout "layouts/decidim/application"
|
13
|
-
|
14
12
|
# GET /initiatives/:initiative_id/committee_requests/new
|
15
13
|
def new
|
16
14
|
enforce_permission_to :request_membership, :initiative, initiative: current_initiative
|