decidim-initiatives 0.16.1 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/initiatives/scoped_type.js +13 -10
- data/app/assets/stylesheet/decidim/initiatives/initiatives-votes.css.scss +97 -0
- data/app/cells/decidim/initiatives/initiative_m_cell.rb +1 -1
- data/app/cells/decidim/initiatives_votes/vote/show.erb +29 -0
- data/app/cells/decidim/initiatives_votes/vote_cell.rb +51 -0
- data/app/commands/decidim/initiatives/admin/create_initiative_type.rb +8 -1
- data/app/commands/decidim/initiatives/admin/update_initiative.rb +7 -6
- data/app/commands/decidim/initiatives/admin/update_initiative_answer.rb +76 -0
- data/app/commands/decidim/initiatives/admin/update_initiative_type.rb +17 -1
- data/app/commands/decidim/initiatives/create_initiative.rb +12 -0
- data/app/commands/decidim/initiatives/spawn_committee_request.rb +8 -7
- data/app/commands/decidim/initiatives/validate_mobile_phone.rb +61 -0
- data/app/commands/decidim/initiatives/validate_sms_code.rb +40 -0
- data/app/commands/decidim/initiatives/vote_initiative.rb +23 -7
- data/app/controllers/concerns/decidim/initiatives/needs_initiative.rb +12 -1
- data/app/controllers/decidim/initiatives/admin/answers_controller.rb +46 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +31 -5
- data/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb +1 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_types_permissions_controller.rb +20 -0
- data/app/controllers/decidim/initiatives/admin/moderations_controller.rb +16 -0
- data/app/controllers/decidim/initiatives/application_controller.rb +0 -2
- data/app/controllers/decidim/initiatives/authorization_sign_modals_controller.rb +26 -0
- data/app/controllers/decidim/initiatives/committee_requests_controller.rb +4 -1
- data/app/controllers/decidim/initiatives/create_initiative_controller.rb +16 -5
- data/app/controllers/decidim/initiatives/initiative_signatures_controller.rb +207 -0
- data/app/controllers/decidim/initiatives/initiative_votes_controller.rb +3 -1
- data/app/controllers/decidim/initiatives/initiatives_type_signature_types_controller.rb +21 -0
- data/app/forms/decidim/initiatives/admin/initiative_answer_form.rb +29 -0
- data/app/forms/decidim/initiatives/admin/initiative_form.rb +25 -7
- data/app/forms/decidim/initiatives/admin/initiative_type_form.rb +14 -0
- data/app/forms/decidim/initiatives/committee_member_form.rb +30 -0
- data/app/forms/decidim/initiatives/initiative_form.rb +5 -0
- data/app/forms/decidim/initiatives/vote_form.rb +151 -0
- data/app/helpers/decidim/initiatives/create_initiative_helper.rb +25 -12
- data/app/helpers/decidim/initiatives/initiative_helper.rb +18 -0
- data/app/models/decidim/initiative.rb +54 -3
- data/app/models/decidim/initiatives_committee_member.rb +1 -0
- data/app/models/decidim/initiatives_type.rb +30 -0
- data/app/permissions/decidim/initiatives/admin/permissions.rb +12 -3
- data/app/permissions/decidim/initiatives/permissions.rb +37 -8
- data/app/queries/decidim/initiatives/admin/admin_users.rb +39 -0
- data/app/services/decidim/initiatives/data_encryptor.rb +26 -0
- data/app/services/decidim/initiatives/dummy_timestamp.rb +22 -0
- data/app/services/decidim/initiatives/pdf_signature_example.rb +121 -0
- data/app/views/decidim/initiatives/admin/answers/_info_initiative.html.erb +23 -0
- data/app/views/decidim/initiatives/admin/answers/edit.html.erb +35 -0
- data/app/views/decidim/initiatives/admin/initiatives/_form.html.erb +17 -16
- data/app/views/decidim/initiatives/admin/initiatives/edit.html.erb +10 -3
- data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.pdf.erb +35 -0
- data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +6 -0
- data/app/views/decidim/initiatives/admin/initiatives_types/_form.html.erb +36 -0
- data/app/views/decidim/initiatives/admin/initiatives_types/index.html.erb +2 -0
- data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +3 -3
- data/app/views/decidim/initiatives/create_initiative/finish.html.erb +2 -2
- data/app/views/decidim/initiatives/create_initiative/previous_form.html.erb +2 -2
- data/app/views/decidim/initiatives/create_initiative/promotal_committee.html.erb +3 -3
- data/app/views/decidim/initiatives/create_initiative/select_initiative_type.html.erb +37 -22
- data/app/views/decidim/initiatives/initiative_signatures/_wizard_steps.html.erb +19 -0
- data/app/views/decidim/initiatives/initiative_signatures/fill_personal_data.html.erb +43 -0
- data/app/views/decidim/initiatives/initiative_signatures/finish.html.erb +17 -0
- data/app/views/decidim/initiatives/initiative_signatures/sms_code.html.erb +22 -0
- data/app/views/decidim/initiatives/initiative_signatures/sms_phone_number.html.erb +22 -0
- data/app/views/decidim/initiatives/initiative_signatures/update_buttons_and_counters.js.erb +21 -0
- data/app/views/decidim/initiatives/initiative_votes/update_buttons_and_counters.js.erb +1 -1
- data/app/views/decidim/initiatives/initiatives/_author.html.erb +1 -1
- data/app/views/decidim/initiatives/initiatives/_interactions.html.erb +11 -0
- data/app/views/decidim/initiatives/initiatives/_progress_bar.html.erb +9 -0
- data/app/views/decidim/initiatives/initiatives/_result.html.erb +3 -3
- data/app/views/decidim/initiatives/initiatives/_vote_button.html.erb +39 -18
- data/app/views/decidim/initiatives/initiatives/_vote_cabin.html.erb +9 -9
- data/app/views/decidim/initiatives/initiatives/show.html.erb +12 -12
- data/app/views/decidim/initiatives/initiatives/signature_identities.html.erb +19 -9
- data/app/views/decidim/initiatives/initiatives_type_signature_types/search.html.erb +1 -0
- data/app/views/layouts/decidim/_initiative_creation_header.html.erb +24 -34
- data/app/views/layouts/decidim/_initiative_signature_creation_header.html.erb +27 -0
- data/app/views/layouts/decidim/admin/initiative.html.erb +22 -15
- data/app/views/layouts/decidim/admin/initiatives_votes.pdf.erb +11 -0
- data/app/views/layouts/decidim/initiative_creation.html.erb +15 -3
- data/app/views/layouts/decidim/initiative_signature_creation.html.erb +12 -0
- data/config/initializers/wicked_pdf.rb +23 -0
- data/config/locales/ar-SA.yml +138 -7
- data/config/locales/ca.yml +120 -28
- data/config/locales/cs-CZ.yml +103 -9
- data/config/locales/cs.yml +494 -0
- data/config/locales/de.yml +101 -9
- data/config/locales/en.yml +133 -40
- data/config/locales/es-MX.yml +101 -9
- data/config/locales/es-PY.yml +101 -9
- data/config/locales/es.yml +124 -32
- data/config/locales/eu.yml +101 -9
- data/config/locales/fi-pl.yml +101 -9
- data/config/locales/fi-plain.yml +478 -0
- data/config/locales/fi.yml +117 -25
- data/config/locales/fr.yml +102 -10
- data/config/locales/gl.yml +101 -9
- data/config/locales/hu.yml +102 -10
- data/config/locales/id-ID.yml +100 -9
- data/config/locales/it.yml +101 -9
- data/config/locales/nl.yml +101 -9
- data/config/locales/pl.yml +104 -10
- data/config/locales/pt-BR.yml +101 -9
- data/config/locales/pt.yml +101 -9
- data/config/locales/ru.yml +4 -9
- data/config/locales/sv.yml +101 -9
- data/config/locales/tr-TR.yml +101 -9
- data/config/locales/uk.yml +4 -9
- data/db/migrate/20181212154456_add_collect_extra_user_fields_to_initiatives_types.rb +7 -0
- data/db/migrate/20181212155125_add_online_signature_enabled_to_initiative_type.rb +7 -0
- data/db/migrate/20181212155740_add_extra_fields_legal_information_to_initiatives_types.rb +7 -0
- data/db/migrate/20181213184712_add_min_committee_members_to_initiative_type.rb +7 -0
- data/db/migrate/20181220134322_add_encrypted_metadata_to_decidim_initiatives_votes.rb +7 -0
- data/db/migrate/20181224100803_add_timestamp_to_decidim_initiatives_votes.rb +7 -0
- data/db/migrate/20181224101041_add_hash_id_to_decidim_initiatives_votes.rb +7 -0
- data/db/migrate/20190124170442_add_validate_sms_code_on_votes_to_initiatives_types.rb +7 -0
- data/db/migrate/20190125131847_add_document_number_authorization_handler_to_initiatives_types.rb +7 -0
- data/db/migrate/20190213184301_add_undo_online_signatures_enabled_to_initiatives_types.rb +7 -0
- data/lib/decidim/initiatives.rb +12 -0
- data/lib/decidim/initiatives/admin_engine.rb +12 -0
- data/lib/decidim/initiatives/engine.rb +3 -0
- data/lib/decidim/initiatives/participatory_space.rb +6 -1
- data/lib/decidim/initiatives/test/factories.rb +39 -0
- data/lib/decidim/initiatives/version.rb +1 -1
- metadata +115 -14
- data/app/views/decidim/initiatives/initiatives/_statistics.html.erb +0 -21
- data/app/views/decidim/initiatives/initiatives/_votes_count.html.erb +0 -12
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
# Command to check if mobile phone has an authorization and
|
6
|
+
# deliver sms code
|
7
|
+
class ValidateMobilePhone < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# form - A MobilePhoneForm.
|
11
|
+
# user - The user which mobile phone must be validated.
|
12
|
+
def initialize(form, user)
|
13
|
+
@form = form
|
14
|
+
@user = user
|
15
|
+
end
|
16
|
+
|
17
|
+
# Executes the command. Broadcasts these events:
|
18
|
+
#
|
19
|
+
# - :ok when everything is valid. Returns the verification metadata of
|
20
|
+
# the form.
|
21
|
+
# - :invalid if the user doesn't have an authorization for sms in ok
|
22
|
+
# status or the phone number associated with its
|
23
|
+
# authorization doesn't match the form number.
|
24
|
+
def call
|
25
|
+
return broadcast(:invalid) unless authorized? && phone_match?
|
26
|
+
|
27
|
+
generate_code
|
28
|
+
|
29
|
+
broadcast(:ok, @verification_metadata)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def generate_code
|
35
|
+
@verification_metadata = @form.verification_metadata
|
36
|
+
end
|
37
|
+
|
38
|
+
def authorizer
|
39
|
+
return unless authorization
|
40
|
+
|
41
|
+
Decidim::Verifications::Adapter.from_element(authorization_name).authorize(authorization, {}, nil, nil)
|
42
|
+
end
|
43
|
+
|
44
|
+
def authorization
|
45
|
+
@authorization ||= Verifications::Authorizations.new(organization: @user.organization, user: @user, name: authorization_name).first
|
46
|
+
end
|
47
|
+
|
48
|
+
def authorization_name
|
49
|
+
"sms"
|
50
|
+
end
|
51
|
+
|
52
|
+
def authorized?
|
53
|
+
authorizer&.first == :ok
|
54
|
+
end
|
55
|
+
|
56
|
+
def phone_match?
|
57
|
+
authorization.unique_id == @form.unique_id
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
# Command to check if sms code provided by user is valid
|
6
|
+
class ValidateSmsCode < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - form containing confirmation_code.
|
10
|
+
# verification_metadata - metadata containing the required code.
|
11
|
+
def initialize(form, verification_metadata)
|
12
|
+
@form = form
|
13
|
+
@verification_metadata = verification_metadata
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everithing is valid.
|
19
|
+
# - :invalid if verification_metadata is not present or the form code is
|
20
|
+
# invalid.
|
21
|
+
#
|
22
|
+
# Returns nothing.
|
23
|
+
def call
|
24
|
+
return broadcast(:invalid) unless verification_metadata_valid? && valid_code?
|
25
|
+
|
26
|
+
broadcast(:ok)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def verification_metadata_valid?
|
32
|
+
@verification_metadata && @verification_metadata["verification_code"].present?
|
33
|
+
end
|
34
|
+
|
35
|
+
def valid_code?
|
36
|
+
@verification_metadata["verification_code"] == @form.verification_code
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -6,13 +6,12 @@ module Decidim
|
|
6
6
|
class VoteInitiative < Rectify::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# form - A form object with the params.
|
10
10
|
# current_user - The current user.
|
11
|
-
|
12
|
-
|
13
|
-
@initiative = initiative
|
11
|
+
def initialize(form, current_user)
|
12
|
+
@form = form
|
13
|
+
@initiative = form.initiative
|
14
14
|
@current_user = current_user
|
15
|
-
@decidim_user_group_id = group_id
|
16
15
|
end
|
17
16
|
|
18
17
|
# Executes the command. Broadcasts these events:
|
@@ -22,8 +21,9 @@ module Decidim
|
|
22
21
|
#
|
23
22
|
# Returns nothing.
|
24
23
|
def call
|
24
|
+
return broadcast(:invalid) if form.invalid?
|
25
25
|
build_initiative_vote
|
26
|
-
|
26
|
+
set_vote_timestamp
|
27
27
|
|
28
28
|
percentage_before = @initiative.percentage
|
29
29
|
vote.save!
|
@@ -39,13 +39,29 @@ module Decidim
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
+
attr_reader :form, :current_user
|
43
|
+
|
42
44
|
def build_initiative_vote
|
43
45
|
@vote = @initiative.votes.build(
|
44
46
|
author: @current_user,
|
45
|
-
decidim_user_group_id:
|
47
|
+
decidim_user_group_id: form.group_id,
|
48
|
+
encrypted_metadata: form.encrypted_metadata,
|
49
|
+
hash_id: form.hash_id
|
46
50
|
)
|
47
51
|
end
|
48
52
|
|
53
|
+
def set_vote_timestamp
|
54
|
+
return unless timestamp_service
|
55
|
+
|
56
|
+
@vote.assign_attributes(
|
57
|
+
timestamp: timestamp_service.new(document: vote.encrypted_metadata).timestamp
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
def timestamp_service
|
62
|
+
@timestamp_service ||= Decidim.timestamp_service.to_s.safe_constantize
|
63
|
+
end
|
64
|
+
|
49
65
|
def send_notification
|
50
66
|
return if vote.user_group.present?
|
51
67
|
|
@@ -13,7 +13,7 @@ module Decidim
|
|
13
13
|
include NeedsOrganization
|
14
14
|
include InitiativeSlug
|
15
15
|
|
16
|
-
helper_method :current_initiative
|
16
|
+
helper_method :current_initiative, :current_participatory_space, :signature_has_steps?
|
17
17
|
|
18
18
|
# Public: Finds the current Initiative given this controller's
|
19
19
|
# context.
|
@@ -25,6 +25,17 @@ module Decidim
|
|
25
25
|
|
26
26
|
alias_method :current_participatory_space, :current_initiative
|
27
27
|
|
28
|
+
# Public: Wether the current initiative belongs to an initiative type
|
29
|
+
# which requires one or more step before creating a signature
|
30
|
+
#
|
31
|
+
# Returns nil if there is no current_initiative, true or false
|
32
|
+
def signature_has_steps?
|
33
|
+
return unless current_initiative
|
34
|
+
|
35
|
+
initiative_type = current_initiative.scoped_type.type
|
36
|
+
initiative_type.collect_user_extra_fields? || initiative_type.validate_sms_code_on_votes?
|
37
|
+
end
|
38
|
+
|
28
39
|
private
|
29
40
|
|
30
41
|
def detect_initiative
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
module Admin
|
6
|
+
# Controller used to manage the initiatives answers
|
7
|
+
class AnswersController < Decidim::Initiatives::Admin::ApplicationController
|
8
|
+
include Decidim::Initiatives::NeedsInitiative
|
9
|
+
|
10
|
+
helper Decidim::Initiatives::InitiativeHelper
|
11
|
+
layout "decidim/admin/initiatives"
|
12
|
+
|
13
|
+
# GET /admin/initiatives/:id/answer/edit
|
14
|
+
def edit
|
15
|
+
enforce_permission_to :answer, :initiative, initiative: current_initiative
|
16
|
+
@form = form(Decidim::Initiatives::Admin::InitiativeAnswerForm)
|
17
|
+
.from_model(
|
18
|
+
current_initiative,
|
19
|
+
initiative: current_initiative
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
# PUT /admin/initiatives/:id/answer
|
24
|
+
def update
|
25
|
+
enforce_permission_to :answer, :initiative, initiative: current_initiative
|
26
|
+
|
27
|
+
params[:id] = params[:slug]
|
28
|
+
@form = form(Decidim::Initiatives::Admin::InitiativeAnswerForm)
|
29
|
+
.from_params(params, initiative: current_initiative)
|
30
|
+
|
31
|
+
UpdateInitiativeAnswer.call(current_initiative, @form, current_user) do
|
32
|
+
on(:ok) do
|
33
|
+
flash[:notice] = I18n.t("initiatives.update.success", scope: "decidim.initiatives.admin")
|
34
|
+
redirect_to initiatives_path
|
35
|
+
end
|
36
|
+
|
37
|
+
on(:invalid) do
|
38
|
+
flash.now[:alert] = I18n.t("initiatives.update.error", scope: "decidim.initiatives.admin")
|
39
|
+
render :edit
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -74,7 +74,7 @@ module Decidim
|
|
74
74
|
|
75
75
|
PublishInitiative.call(current_initiative, current_user) do
|
76
76
|
on(:ok) do
|
77
|
-
redirect_to decidim_admin_initiatives.
|
77
|
+
redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -85,7 +85,7 @@ module Decidim
|
|
85
85
|
|
86
86
|
UnpublishInitiative.call(current_initiative, current_user) do
|
87
87
|
on(:ok) do
|
88
|
-
redirect_to decidim_admin_initiatives.
|
88
|
+
redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
@@ -94,21 +94,21 @@ module Decidim
|
|
94
94
|
def discard
|
95
95
|
enforce_permission_to :discard, :initiative, initiative: current_initiative
|
96
96
|
current_initiative.discarded!
|
97
|
-
redirect_to decidim_admin_initiatives.
|
97
|
+
redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
|
98
98
|
end
|
99
99
|
|
100
100
|
# POST /admin/initiatives/:id/accept
|
101
101
|
def accept
|
102
102
|
enforce_permission_to :accept, :initiative, initiative: current_initiative
|
103
103
|
current_initiative.accepted!
|
104
|
-
redirect_to decidim_admin_initiatives.
|
104
|
+
redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
|
105
105
|
end
|
106
106
|
|
107
107
|
# DELETE /admin/initiatives/:id/reject
|
108
108
|
def reject
|
109
109
|
enforce_permission_to :reject, :initiative, initiative: current_initiative
|
110
110
|
current_initiative.rejected!
|
111
|
-
redirect_to decidim_admin_initiatives.
|
111
|
+
redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
|
112
112
|
end
|
113
113
|
|
114
114
|
# GET /admin/initiatives/:id/send_to_technical_validation
|
@@ -142,6 +142,32 @@ module Decidim
|
|
142
142
|
format.csv { send_data csv_data, file_name: "votes.csv" }
|
143
143
|
end
|
144
144
|
end
|
145
|
+
|
146
|
+
# GET /admin/initiatives/:id/export_pdf_signatures.pdf
|
147
|
+
def export_pdf_signatures
|
148
|
+
enforce_permission_to :export_pdf_signatures, :initiative, initiative: current_initiative
|
149
|
+
|
150
|
+
@votes = current_initiative.votes.votes
|
151
|
+
|
152
|
+
output = render_to_string(
|
153
|
+
pdf: "votes_#{current_initiative.id}",
|
154
|
+
layout: "decidim/admin/initiatives_votes",
|
155
|
+
template: "decidim/initiatives/admin/initiatives/export_pdf_signatures.pdf.erb"
|
156
|
+
)
|
157
|
+
output = pdf_signature_service.new(pdf: output).signed_pdf if pdf_signature_service
|
158
|
+
|
159
|
+
respond_to do |format|
|
160
|
+
format.pdf do
|
161
|
+
send_data(output, filename: "votes_#{current_initiative.id}.pdf", type: "application/pdf")
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
private
|
167
|
+
|
168
|
+
def pdf_signature_service
|
169
|
+
@pdf_signature_service ||= Decidim.pdf_signature_service.to_s.safe_constantize
|
170
|
+
end
|
145
171
|
end
|
146
172
|
end
|
147
173
|
end
|
@@ -8,6 +8,7 @@ module Decidim
|
|
8
8
|
# Controller used to manage the available initiative types for the current
|
9
9
|
# organization.
|
10
10
|
class InitiativesTypesController < Decidim::Initiatives::Admin::ApplicationController
|
11
|
+
helper ::Decidim::Admin::ResourcePermissionsHelper
|
11
12
|
helper_method :current_initiative_type
|
12
13
|
|
13
14
|
# GET /admin/initiatives_types
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
module Admin
|
6
|
+
# Controller that allows managing initiatives types
|
7
|
+
# permissions in the admin panel.
|
8
|
+
class InitiativesTypesPermissionsController < Decidim::Admin::ResourcePermissionsController
|
9
|
+
layout "decidim/admin/initiatives"
|
10
|
+
|
11
|
+
def permission_class_chain
|
12
|
+
[
|
13
|
+
Decidim::Initiatives::Permissions,
|
14
|
+
Decidim::Admin::Permissions
|
15
|
+
]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
module Admin
|
6
|
+
# This controller allows admins to manage moderations in an conference.
|
7
|
+
class ModerationsController < Decidim::Admin::ModerationsController
|
8
|
+
include InitiativeAdmin
|
9
|
+
|
10
|
+
def permissions_context
|
11
|
+
super.merge(current_participatory_space: current_participatory_space)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
class AuthorizationSignModalsController < Decidim::Initiatives::ApplicationController
|
6
|
+
include Decidim::Initiatives::NeedsInitiative
|
7
|
+
|
8
|
+
helper_method :authorizations, :authorize_action_path
|
9
|
+
layout false
|
10
|
+
|
11
|
+
def show
|
12
|
+
render template: "decidim/authorization_modals/show"
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def authorize_action_path(handler_name)
|
18
|
+
authorizations.status_for(handler_name).current_path(redirect_url: URI(request.referer).path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def authorizations
|
22
|
+
@authorizations ||= action_authorized_to("vote", resource: current_initiative, permissions_holder: current_initiative.type)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -20,7 +20,10 @@ module Decidim
|
|
20
20
|
def spawn
|
21
21
|
enforce_permission_to :request_membership, :initiative, initiative: current_initiative
|
22
22
|
|
23
|
-
|
23
|
+
form = Decidim::Initiatives::CommitteeMemberForm
|
24
|
+
.from_params(initiative_id: current_initiative.id, user_id: current_user.id, state: "requested")
|
25
|
+
|
26
|
+
SpawnCommitteeRequest.call(form, current_user) do
|
24
27
|
on(:ok) do
|
25
28
|
redirect_to initiatives_path, flash: {
|
26
29
|
notice: I18n.t(
|
@@ -29,7 +29,7 @@ module Decidim
|
|
29
29
|
|
30
30
|
def show
|
31
31
|
enforce_permission_to :create, :initiative
|
32
|
-
send("#{step}_step", initiative:
|
32
|
+
send("#{step}_step", initiative: session_initiative)
|
33
33
|
end
|
34
34
|
|
35
35
|
def update
|
@@ -71,7 +71,9 @@ module Decidim
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def promotal_committee_step(parameters)
|
74
|
-
|
74
|
+
skip_step unless promotal_committee_required?
|
75
|
+
|
76
|
+
if session_initiative.has_key?(:id)
|
75
77
|
render_wizard
|
76
78
|
return
|
77
79
|
end
|
@@ -108,7 +110,7 @@ module Decidim
|
|
108
110
|
def build_form(klass, parameters)
|
109
111
|
@form = form(klass).from_params(parameters)
|
110
112
|
attributes = @form.attributes_with_values
|
111
|
-
session[:initiative] =
|
113
|
+
session[:initiative] = session_initiative.merge(attributes)
|
112
114
|
@form.valid? if params[:validate_form]
|
113
115
|
|
114
116
|
@form
|
@@ -119,13 +121,22 @@ module Decidim
|
|
119
121
|
end
|
120
122
|
|
121
123
|
def current_initiative
|
122
|
-
|
123
|
-
Initiative.find(initiative[:id]) if initiative.has_key?(:id)
|
124
|
+
Initiative.find(session_initiative[:id]) if session_initiative.has_key?(:id)
|
124
125
|
end
|
125
126
|
|
126
127
|
def initiative_type
|
127
128
|
@initiative_type ||= InitiativesType.find(@form&.type_id)
|
128
129
|
end
|
130
|
+
|
131
|
+
def session_initiative
|
132
|
+
session[:initiative]&.with_indifferent_access
|
133
|
+
end
|
134
|
+
|
135
|
+
def promotal_committee_required?
|
136
|
+
minimum_committee_members = InitiativesType.find(session_initiative[:type_id]).minimum_committee_members ||
|
137
|
+
Decidim::Initiatives.minimum_committee_members
|
138
|
+
minimum_committee_members.present? && minimum_committee_members.positive?
|
139
|
+
end
|
129
140
|
end
|
130
141
|
end
|
131
142
|
end
|