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
@@ -2,13 +2,10 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Initiatives
|
5
|
-
require "wicked"
|
6
|
-
|
7
5
|
# Controller in charge of managing the create initiative wizard.
|
8
6
|
class CreateInitiativeController < Decidim::Initiatives::ApplicationController
|
9
7
|
layout "layouts/decidim/initiative_creation"
|
10
8
|
|
11
|
-
include Wicked::Wizard
|
12
9
|
include Decidim::FormFactory
|
13
10
|
include InitiativeHelper
|
14
11
|
include TypeSelectorOptions
|
@@ -18,7 +15,6 @@ module Decidim
|
|
18
15
|
helper InitiativeHelper
|
19
16
|
helper SignatureTypeOptionsHelper
|
20
17
|
|
21
|
-
helper_method :similar_initiatives
|
22
18
|
helper_method :scopes
|
23
19
|
helper_method :areas
|
24
20
|
helper_method :current_initiative
|
@@ -26,136 +22,95 @@ module Decidim
|
|
26
22
|
helper_method :promotal_committee_required?
|
27
23
|
|
28
24
|
before_action :authenticate_user!
|
25
|
+
before_action :ensure_type_exists,
|
26
|
+
only: [:store_initiative_type, :fill_data, :store_data, :promotal_committee, :finish]
|
27
|
+
before_action :ensure_user_can_create_initiative,
|
28
|
+
only: [:fill_data, :store_data, :promotal_committee, :finish]
|
29
|
+
before_action :ensure_initiative_exists, only: [:promotal_committee, :finish]
|
30
|
+
|
31
|
+
def select_initiative_type
|
32
|
+
@form = form(Decidim::Initiatives::SelectInitiativeTypeForm).from_params(params)
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
:show_similar_initiatives,
|
33
|
-
:fill_data,
|
34
|
-
:promotal_committee,
|
35
|
-
:finish
|
34
|
+
redirect_to fill_data_create_initiative_index_path if single_initiative_type?
|
35
|
+
end
|
36
36
|
|
37
|
-
|
37
|
+
def store_initiative_type
|
38
|
+
@form = form(Decidim::Initiatives::SelectInitiativeTypeForm).from_params(params)
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
if @form.valid?
|
41
|
+
session[:type_id] = @form.type_id
|
42
|
+
redirect_to fill_data_create_initiative_index_path
|
43
|
+
else
|
44
|
+
render :select_initiative_type
|
45
|
+
end
|
42
46
|
end
|
43
47
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
48
|
+
def fill_data
|
49
|
+
@form = if session[:initiative_id].present?
|
50
|
+
form(Decidim::Initiatives::InitiativeForm).from_model(current_initiative, { initiative_type: })
|
51
|
+
else
|
52
|
+
extras = { type_id: initiative_type_id, signature_type: initiative_type.signature_type }
|
53
|
+
form(Decidim::Initiatives::InitiativeForm).from_params(params.merge(extras), { initiative_type: })
|
54
|
+
end
|
47
55
|
end
|
48
56
|
|
49
|
-
|
57
|
+
def store_data
|
58
|
+
@form = form(Decidim::Initiatives::InitiativeForm).from_params(params, { initiative_type: })
|
50
59
|
|
51
|
-
|
52
|
-
|
60
|
+
CreateInitiative.call(@form, current_user) do
|
61
|
+
on(:ok) do |initiative|
|
62
|
+
session[:initiative_id] = initiative.id
|
53
63
|
|
54
|
-
|
55
|
-
return if initiative_type_id.present? && initiative_type.present?
|
64
|
+
path = promotal_committee_required? ? "promotal_committee" : "finish"
|
56
65
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
def select_initiative_type_step(_parameters)
|
61
|
-
@form = form(Decidim::Initiatives::SelectInitiativeTypeForm).instance
|
62
|
-
session[:initiative] = {}
|
66
|
+
redirect_to send("#{path}_create_initiative_index_path".to_sym)
|
67
|
+
end
|
63
68
|
|
64
|
-
|
65
|
-
|
66
|
-
|
69
|
+
on(:invalid) do
|
70
|
+
render :fill_data
|
71
|
+
end
|
67
72
|
end
|
68
|
-
|
69
|
-
@form = form(Decidim::Initiatives::SelectInitiativeTypeForm).instance
|
70
|
-
render_wizard unless performed?
|
71
73
|
end
|
72
74
|
|
73
|
-
def
|
74
|
-
|
75
|
-
render_wizard
|
75
|
+
def promotal_committee
|
76
|
+
redirect_to finish_create_initiative_index_path unless promotal_committee_required?
|
76
77
|
end
|
77
78
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
return
|
83
|
-
end
|
84
|
-
|
85
|
-
if similar_initiatives.empty?
|
86
|
-
@form = build_form(Decidim::Initiatives::InitiativeForm, parameters)
|
87
|
-
redirect_to wizard_path(:fill_data)
|
88
|
-
end
|
89
|
-
|
90
|
-
render_wizard unless performed?
|
79
|
+
def finish
|
80
|
+
current_initiative.presence
|
81
|
+
session[:type_id] = nil
|
82
|
+
session[:initiative_id] = nil
|
91
83
|
end
|
92
84
|
|
93
|
-
|
94
|
-
@form = build_form(Decidim::Initiatives::InitiativeForm, parameters)
|
95
|
-
@form.attachment = form(AttachmentForm).from_params({})
|
85
|
+
private
|
96
86
|
|
97
|
-
|
87
|
+
def ensure_user_can_create_initiative
|
88
|
+
enforce_permission_to :create, :initiative, { initiative_type: }
|
98
89
|
end
|
99
90
|
|
100
|
-
def
|
101
|
-
@
|
102
|
-
unless @form.valid?
|
103
|
-
redirect_to previous_wizard_path(validate_form: true)
|
104
|
-
return
|
105
|
-
end
|
106
|
-
|
107
|
-
skip_step unless promotal_committee_required?
|
108
|
-
|
109
|
-
if session_initiative.has_key?(:id)
|
110
|
-
render_wizard
|
111
|
-
return
|
112
|
-
end
|
113
|
-
|
114
|
-
CreateInitiative.call(@form, current_user) do
|
115
|
-
on(:ok) do |initiative|
|
116
|
-
session[:initiative][:id] = initiative.id
|
117
|
-
if current_initiative.created_by_individual?
|
118
|
-
render_wizard
|
119
|
-
else
|
120
|
-
redirect_to wizard_path(:finish)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
on(:invalid) do |initiative|
|
125
|
-
logger.fatal "Failed creating initiative: #{initiative.errors.full_messages.join(", ")}" if initiative
|
126
|
-
redirect_to previous_wizard_path(validate_form: true)
|
127
|
-
end
|
128
|
-
end
|
91
|
+
def initiative_type_id
|
92
|
+
@initiative_type_id ||= fetch_initiative_type_id
|
129
93
|
end
|
130
94
|
|
131
|
-
def
|
132
|
-
|
133
|
-
|
95
|
+
def fetch_initiative_type_id
|
96
|
+
return current_organization_initiatives_type.first.id if single_initiative_type?
|
97
|
+
return params.dig(:initiative, :type_id) if params.dig(:initiative, :type_id).present?
|
98
|
+
return current_initiative&.type&.id if session[:initiative_id].present?
|
134
99
|
|
135
|
-
|
136
|
-
@similar_initiatives ||= Decidim::Initiatives::SimilarInitiatives
|
137
|
-
.for(current_organization, @form)
|
138
|
-
.all
|
100
|
+
session[:type_id]
|
139
101
|
end
|
140
102
|
|
141
|
-
def
|
142
|
-
|
143
|
-
form(klass).from_params(parameters.except(:id).merge(type_id: current_organization_initiatives_type.first.id), extra_context)
|
144
|
-
else
|
145
|
-
form(klass).from_params(parameters.except(:id), extra_context)
|
146
|
-
end
|
147
|
-
|
148
|
-
attributes = @form.attributes_with_values
|
149
|
-
session[:initiative] = session_initiative.merge(attributes)
|
150
|
-
@form.valid? if params[:validate_form]
|
151
|
-
|
152
|
-
@form
|
103
|
+
def ensure_initiative_exists
|
104
|
+
redirect_to fill_data_create_initiative_index_path if session[:initiative_id].blank?
|
153
105
|
end
|
154
106
|
|
155
|
-
def
|
156
|
-
|
107
|
+
def ensure_type_exists
|
108
|
+
destination_step = single_initiative_type? ? "fill_data" : "select_initiative_type"
|
109
|
+
|
110
|
+
return if action_name == destination_step
|
111
|
+
return if initiative_type_id.present? && initiative_type.present?
|
157
112
|
|
158
|
-
{
|
113
|
+
redirect_to send("#{destination_step}_create_initiative_index_path".to_sym)
|
159
114
|
end
|
160
115
|
|
161
116
|
def scopes
|
@@ -163,23 +118,15 @@ module Decidim
|
|
163
118
|
end
|
164
119
|
|
165
120
|
def current_initiative
|
166
|
-
Initiative.where(organization: current_organization).find_by(id:
|
121
|
+
@current_initiative ||= Initiative.where(organization: current_organization).find_by(id: session[:initiative_id] || nil)
|
167
122
|
end
|
168
123
|
|
169
124
|
def initiative_type
|
170
125
|
@initiative_type ||= InitiativesType.where(organization: current_organization).find_by(id: initiative_type_id)
|
171
126
|
end
|
172
127
|
|
173
|
-
def initiative_type_id
|
174
|
-
session_initiative[:type_id] || @form&.type_id
|
175
|
-
end
|
176
|
-
|
177
|
-
def session_initiative
|
178
|
-
session[:initiative] ||= {}
|
179
|
-
session[:initiative].with_indifferent_access
|
180
|
-
end
|
181
|
-
|
182
128
|
def promotal_committee_required?
|
129
|
+
return false if initiative_type.blank?
|
183
130
|
return false unless initiative_type.promoting_committee_enabled?
|
184
131
|
|
185
132
|
minimum_committee_members = initiative_type.minimum_committee_members ||
|
@@ -1,33 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# i18n-tasks-use t('layouts.decidim.initiative_signature_creation_header.fill_personal_data')
|
4
|
+
# i18n-tasks-use t('layouts.decidim.initiative_signature_creation_header.finish')
|
5
|
+
# i18n-tasks-use t('layouts.decidim.initiative_signature_creation_header.sms_code')
|
6
|
+
# i18n-tasks-use t('layouts.decidim.initiative_signature_creation_header.sms_phone_number')
|
7
|
+
# i18n-tasks-use t('layouts.decidim.initiative_signature_creation_header.finish')
|
3
8
|
module Decidim
|
4
9
|
module Initiatives
|
5
|
-
require "wicked"
|
6
|
-
|
7
10
|
class InitiativeSignaturesController < Decidim::Initiatives::ApplicationController
|
8
11
|
layout "layouts/decidim/initiative_signature_creation"
|
9
|
-
|
10
|
-
include Wicked::Wizard
|
11
12
|
include Decidim::Initiatives::NeedsInitiative
|
12
13
|
include Decidim::FormFactory
|
13
14
|
|
14
15
|
prepend_before_action :set_wizard_steps
|
15
16
|
before_action :authenticate_user!
|
17
|
+
before_action :authorize_wizard_step, only: [
|
18
|
+
:fill_personal_data,
|
19
|
+
:store_personal_data,
|
20
|
+
:sms_phone_number,
|
21
|
+
:store_sms_phone_number,
|
22
|
+
:sms_code,
|
23
|
+
:store_sms_code,
|
24
|
+
:finish
|
25
|
+
]
|
16
26
|
|
17
27
|
helper InitiativeHelper
|
18
28
|
|
19
|
-
helper_method :initiative_type, :extra_data_legal_information
|
20
|
-
|
21
|
-
# GET /initiatives/:initiative_id/initiative_signatures/:step
|
22
|
-
def show
|
23
|
-
enforce_permission_to :sign_initiative, :initiative, initiative: current_initiative, signature_has_steps: signature_has_steps?
|
24
|
-
send("#{step}_step", initiative_vote_form: session[:initiative_vote_form])
|
25
|
-
end
|
29
|
+
helper_method :initiative_type, :extra_data_legal_information, :sms_step?, :fill_personal_data_step?
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
enforce_permission_to :sign_initiative, :initiative, initiative: current_initiative, signature_has_steps: signature_has_steps?
|
30
|
-
send("#{step}_step", params)
|
31
|
+
def index
|
32
|
+
redirect_to send(fill_personal_data_step? ? :fill_personal_data_path : :sms_phone_number_path)
|
31
33
|
end
|
32
34
|
|
33
35
|
# POST /initiatives/:initiative_id/initiative_signatures
|
@@ -52,76 +54,86 @@ module Decidim
|
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
|
-
|
57
|
+
def fill_personal_data
|
58
|
+
redirect_to(sms_phone_number_path) && return unless fill_personal_data_step?
|
56
59
|
|
57
|
-
def fill_personal_data_step(_unused)
|
58
60
|
@form = form(Decidim::Initiatives::VoteForm)
|
59
61
|
.from_params(
|
60
62
|
initiative: current_initiative,
|
61
63
|
signer: current_user
|
62
64
|
)
|
63
|
-
|
64
|
-
session[:initiative_vote_form] = {}
|
65
|
-
skip_step unless initiative_type.collect_user_extra_fields
|
66
|
-
render_wizard
|
67
65
|
end
|
68
66
|
|
69
|
-
def
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
check_session_personal_data
|
74
|
-
end
|
75
|
-
clear_session_sms_code
|
67
|
+
def store_personal_data
|
68
|
+
redirect_to(sms_phone_number_path) && return unless fill_personal_data_step?
|
69
|
+
|
70
|
+
build_vote_form(params)
|
76
71
|
|
77
72
|
if @vote_form.invalid?
|
78
73
|
flash[:alert] = I18n.t("personal_data.invalid", scope: "decidim.initiatives.initiative_votes")
|
79
|
-
|
74
|
+
@form = @vote_form
|
75
|
+
|
76
|
+
render :fill_personal_data
|
77
|
+
else
|
78
|
+
redirect_to sms_phone_number_path
|
80
79
|
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def sms_phone_number
|
83
|
+
redirect_to(finish_path) && return unless sms_step?
|
81
84
|
|
82
85
|
@form = Decidim::Verifications::Sms::MobilePhoneForm.new
|
83
|
-
render_wizard
|
84
86
|
end
|
85
87
|
|
86
|
-
def
|
87
|
-
|
88
|
-
@phone_form = Decidim::Verifications::Sms::MobilePhoneForm.from_params(parameters.merge(user: current_user))
|
89
|
-
@form = Decidim::Verifications::Sms::ConfirmationForm.new
|
90
|
-
render_wizard && return if session_sms_code.present?
|
88
|
+
def store_sms_phone_number
|
89
|
+
redirect_to(finish_path) && return unless sms_step?
|
91
90
|
|
92
|
-
|
91
|
+
@form = Decidim::Verifications::Sms::MobilePhoneForm.from_params(params.merge(user: current_user))
|
92
|
+
|
93
|
+
ValidateMobilePhone.call(@form, current_user) do
|
93
94
|
on(:ok) do |metadata|
|
94
95
|
store_session_sms_code(metadata)
|
95
|
-
|
96
|
+
redirect_to sms_code_path
|
96
97
|
end
|
97
98
|
|
98
99
|
on(:invalid) do
|
99
100
|
flash[:alert] = I18n.t("sms_phone.invalid", scope: "decidim.initiatives.initiative_votes")
|
100
|
-
|
101
|
+
render :sms_phone_number
|
101
102
|
end
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
105
|
-
def
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
check_session_personal_data
|
110
|
-
end
|
106
|
+
def sms_code
|
107
|
+
redirect_to(finish_path) && return unless sms_step?
|
108
|
+
|
109
|
+
redirect_to sms_phone_number_path && return if session_sms_code.blank?
|
111
110
|
|
112
|
-
|
113
|
-
|
111
|
+
@form = Decidim::Verifications::Sms::ConfirmationForm.new
|
112
|
+
end
|
113
|
+
|
114
|
+
def store_sms_code
|
115
|
+
redirect_to(finish_path) && return unless sms_step?
|
114
116
|
|
115
|
-
|
116
|
-
|
117
|
+
@form = Decidim::Verifications::Sms::ConfirmationForm.from_params(params)
|
118
|
+
ValidateSmsCode.call(@form, session_sms_code) do
|
119
|
+
on(:ok) do
|
120
|
+
clear_session_sms_code
|
121
|
+
redirect_to finish_path
|
122
|
+
end
|
117
123
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
render_wizard && return
|
122
|
-
end
|
124
|
+
on(:invalid) do
|
125
|
+
flash[:alert] = I18n.t("sms_code.invalid", scope: "decidim.initiatives.initiative_votes")
|
126
|
+
render :sms_code
|
123
127
|
end
|
124
128
|
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def finish
|
132
|
+
if params.has_key?(:initiatives_vote) || !fill_personal_data_step?
|
133
|
+
build_vote_form(params)
|
134
|
+
else
|
135
|
+
check_session_personal_data
|
136
|
+
end
|
125
137
|
|
126
138
|
VoteInitiative.call(@vote_form) do
|
127
139
|
on(:ok) do
|
@@ -131,11 +143,29 @@ module Decidim
|
|
131
143
|
on(:invalid) do |vote|
|
132
144
|
logger.fatal "Failed creating signature: #{vote.errors.full_messages.join(", ")}" if vote
|
133
145
|
flash[:alert] = I18n.t("create.invalid", scope: "decidim.initiatives.initiative_votes")
|
134
|
-
|
146
|
+
send(sms_step? ? :sms_code_path : :fill_personal_data_path)
|
135
147
|
end
|
136
148
|
end
|
149
|
+
end
|
150
|
+
|
151
|
+
private
|
152
|
+
|
153
|
+
attr_reader :wizard_steps
|
154
|
+
|
155
|
+
def fill_personal_data_path
|
156
|
+
fill_personal_data_initiative_signatures_path(current_initiative)
|
157
|
+
end
|
137
158
|
|
138
|
-
|
159
|
+
def sms_code_path
|
160
|
+
sms_code_initiative_signatures_path(current_initiative)
|
161
|
+
end
|
162
|
+
|
163
|
+
def finish_path
|
164
|
+
finish_initiative_signatures_path(current_initiative)
|
165
|
+
end
|
166
|
+
|
167
|
+
def sms_phone_number_path
|
168
|
+
sms_phone_number_initiative_signatures_path(current_initiative)
|
139
169
|
end
|
140
170
|
|
141
171
|
def build_vote_form(parameters)
|
@@ -148,53 +178,55 @@ module Decidim
|
|
148
178
|
session[:initiative_vote_form] = session[:initiative_vote_form].merge(@vote_form.attributes_with_values.except(:initiative, :signer))
|
149
179
|
end
|
150
180
|
|
151
|
-
def
|
152
|
-
|
181
|
+
def initiative_type
|
182
|
+
@initiative_type ||= current_initiative&.scoped_type&.type
|
183
|
+
end
|
153
184
|
|
154
|
-
|
185
|
+
def sms_step?
|
186
|
+
current_initiative.validate_sms_code_on_votes?
|
155
187
|
end
|
156
188
|
|
157
|
-
def
|
158
|
-
|
189
|
+
def fill_personal_data_step?
|
190
|
+
initiative_type.collect_user_extra_fields?
|
191
|
+
end
|
192
|
+
|
193
|
+
def authorize_wizard_step
|
194
|
+
enforce_permission_to :sign_initiative, :initiative, initiative: current_initiative, signature_has_steps: signature_has_steps?
|
195
|
+
end
|
196
|
+
|
197
|
+
def set_wizard_steps
|
198
|
+
@wizard_steps = [:finish]
|
199
|
+
@wizard_steps.unshift(:sms_phone_number, :sms_code) if sms_step?
|
200
|
+
@wizard_steps.unshift(:fill_personal_data) if fill_personal_data_step?
|
159
201
|
end
|
160
202
|
|
161
203
|
def extra_data_legal_information
|
162
204
|
@extra_data_legal_information ||= initiative_type.extra_fields_legal_information
|
163
205
|
end
|
164
206
|
|
165
|
-
def
|
166
|
-
|
207
|
+
def session_vote_form
|
208
|
+
attributes = session[:initiative_vote_form].merge(initiative: current_initiative, signer: current_user)
|
167
209
|
|
168
|
-
|
169
|
-
jump_to(:fill_personal_data)
|
210
|
+
@vote_form = form(Decidim::Initiatives::VoteForm).from_params(attributes)
|
170
211
|
end
|
171
212
|
|
172
|
-
def
|
173
|
-
session[:
|
174
|
-
end
|
213
|
+
def check_session_personal_data
|
214
|
+
return if session[:initiative_vote_form].present? && session_vote_form&.valid?
|
175
215
|
|
176
|
-
|
177
|
-
|
216
|
+
flash[:alert] = I18n.t("create.error", scope: "decidim.initiatives.initiative_votes")
|
217
|
+
redirect_to fill_personal_data_path
|
178
218
|
end
|
179
219
|
|
180
220
|
def clear_session_sms_code
|
181
221
|
session[:initiative_sms_code] = {}
|
182
222
|
end
|
183
223
|
|
184
|
-
def
|
185
|
-
|
186
|
-
end
|
187
|
-
|
188
|
-
def fill_personal_data_step?
|
189
|
-
initiative_type.collect_user_extra_fields?
|
224
|
+
def store_session_sms_code(metadata)
|
225
|
+
session[:initiative_sms_code] = metadata
|
190
226
|
end
|
191
227
|
|
192
|
-
def
|
193
|
-
|
194
|
-
initial_wizard_steps.unshift(:sms_phone_number, :sms_code) if sms_step?
|
195
|
-
initial_wizard_steps.unshift(:fill_personal_data) if fill_personal_data_step?
|
196
|
-
|
197
|
-
self.steps = initial_wizard_steps
|
228
|
+
def session_sms_code
|
229
|
+
session[:initiative_sms_code]
|
198
230
|
end
|
199
231
|
end
|
200
232
|
end
|
@@ -1,5 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# i18n-tasks-use t('decidim.initiatives.show.badge_name.accepted')
|
4
|
+
# i18n-tasks-use t('decidim.initiatives.show.badge_name.created')
|
5
|
+
# i18n-tasks-use t('decidim.initiatives.show.badge_name.discarded')
|
6
|
+
# i18n-tasks-use t('decidim.initiatives.show.badge_name.published')
|
7
|
+
# i18n-tasks-use t('decidim.initiatives.show.badge_name.rejected')
|
8
|
+
# i18n-tasks-use t('decidim.initiatives.show.badge_name.validating')
|
9
|
+
#
|
3
10
|
module Decidim
|
4
11
|
module Initiatives
|
5
12
|
# Exposes the initiative type text search so users can choose a type writing its name.
|
@@ -5,9 +5,7 @@ module Decidim
|
|
5
5
|
# This controller contains the logic regarding participants initiatives
|
6
6
|
class InitiativesController < Decidim::Initiatives::ApplicationController
|
7
7
|
include ParticipatorySpaceContext
|
8
|
-
participatory_space_layout only: [:show]
|
9
8
|
|
10
|
-
helper Decidim::WidgetUrlsHelper
|
11
9
|
helper Decidim::AttachmentsHelper
|
12
10
|
helper Decidim::FiltersHelper
|
13
11
|
helper Decidim::OrdersHelper
|
@@ -28,9 +26,12 @@ module Decidim
|
|
28
26
|
include TypeSelectorOptions
|
29
27
|
include NeedsInitiative
|
30
28
|
include SingleInitiativeType
|
29
|
+
include Decidim::IconHelper
|
31
30
|
|
32
|
-
helper_method :collection, :initiatives, :filter, :stats
|
33
|
-
helper_method :initiative_type
|
31
|
+
helper_method :collection, :initiatives, :filter, :stats, :tabs, :panels
|
32
|
+
helper_method :initiative_type, :available_initiative_types
|
33
|
+
|
34
|
+
before_action :authorize_participatory_space, only: [:show]
|
34
35
|
|
35
36
|
# GET /initiatives
|
36
37
|
def index
|
@@ -51,6 +52,8 @@ module Decidim
|
|
51
52
|
# GET /initiatives/:id
|
52
53
|
def show
|
53
54
|
enforce_permission_to :read, :initiative, initiative: current_initiative
|
55
|
+
|
56
|
+
render layout: "decidim/initiative_head"
|
54
57
|
end
|
55
58
|
|
56
59
|
# GET /initiatives/:id/send_to_technical_validation
|
@@ -79,8 +82,6 @@ module Decidim
|
|
79
82
|
initiative: current_initiative
|
80
83
|
)
|
81
84
|
@form.attachment = form_attachment_model
|
82
|
-
|
83
|
-
render layout: "decidim/initiative"
|
84
85
|
end
|
85
86
|
|
86
87
|
# PUT /initiatives/:id
|
@@ -114,6 +115,8 @@ module Decidim
|
|
114
115
|
alias current_initiative current_participatory_space
|
115
116
|
|
116
117
|
def current_participatory_space
|
118
|
+
return unless params["slug"]
|
119
|
+
|
117
120
|
@current_participatory_space ||= Initiative.find(id_from_slug(params[:slug]))
|
118
121
|
end
|
119
122
|
|
@@ -140,27 +143,44 @@ module Decidim
|
|
140
143
|
{
|
141
144
|
search_text_cont: "",
|
142
145
|
with_any_state: %w(open),
|
143
|
-
with_any_type:
|
146
|
+
with_any_type: nil,
|
144
147
|
author: "any",
|
145
|
-
with_any_scope:
|
146
|
-
with_any_area:
|
148
|
+
with_any_scope: nil,
|
149
|
+
with_any_area: nil
|
147
150
|
}
|
148
151
|
end
|
149
152
|
|
150
|
-
def
|
151
|
-
|
153
|
+
def stats
|
154
|
+
@stats ||= InitiativeStatsPresenter.new(initiative: current_initiative)
|
152
155
|
end
|
153
156
|
|
154
|
-
def
|
155
|
-
|
157
|
+
def tabs
|
158
|
+
@tabs ||= items.map { |item| item.slice(:id, :text, :icon) }
|
156
159
|
end
|
157
160
|
|
158
|
-
def
|
159
|
-
|
161
|
+
def panels
|
162
|
+
@panels ||= items.map { |item| item.slice(:id, :method, :args) }
|
160
163
|
end
|
161
164
|
|
162
|
-
def
|
163
|
-
@
|
165
|
+
def items
|
166
|
+
@items ||= [
|
167
|
+
{
|
168
|
+
enabled: @current_initiative.photos.present?,
|
169
|
+
id: "images",
|
170
|
+
text: t("decidim.application.photos.photos"),
|
171
|
+
icon: resource_type_icon_key("images"),
|
172
|
+
method: :cell,
|
173
|
+
args: ["decidim/images_panel", @current_initiative]
|
174
|
+
},
|
175
|
+
{
|
176
|
+
enabled: @current_initiative.documents.present?,
|
177
|
+
id: "documents",
|
178
|
+
text: t("decidim.application.documents.documents"),
|
179
|
+
icon: resource_type_icon_key("documents"),
|
180
|
+
method: :cell,
|
181
|
+
args: ["decidim/documents_panel", @current_initiative]
|
182
|
+
}
|
183
|
+
].select { |item| item[:enabled] }
|
164
184
|
end
|
165
185
|
end
|
166
186
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Initiatives
|
@@ -13,7 +13,7 @@ module Decidim
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def admin_initiative_url
|
16
|
-
|
16
|
+
decidim_admin_initiatives.edit_initiative_url(resource, resource.mounted_params)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|