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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4c9012119c5a0b6e11fccdc1f9677fc52d978be5f851e0f3964a98dafacd791
|
4
|
+
data.tar.gz: 838154148f64d7e43f874cd63cc08202c5c53ca076dcaaf8cf15f8a4303ad7b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03d2fbf7e6d4926257938862c341968508c2dfaf61d05fba34f01c077027b4c724340692f536f76f90d766e61dc08f43ca2014dc201166039eb826c91683d02d
|
7
|
+
data.tar.gz: 5582c16363e8e6ba7c9e298eb01705095990268af934baa5ac6cf77eb56400b0e2a2ee22a5c8dde8ac3745b35408b53902264a7a573fb0db76a596b436d6cdc2
|
@@ -1,12 +1,9 @@
|
|
1
1
|
/* eslint-disable camelcase */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
let currentValue = typeSelector.data("scope-id"),
|
8
|
-
searchUrl = typeSelector.data("scope-search-url"),
|
9
|
-
targetElement = $(`#${typeSelector.data("scope-selector")}`);
|
2
|
+
let controlSelector = function(source, prefix, currentValueKey) {
|
3
|
+
if (source.length) {
|
4
|
+
let currentValue = source.data(currentValueKey),
|
5
|
+
searchUrl = source.data(`${prefix}-search-url`),
|
6
|
+
targetElement = $(`#${source.data(`${prefix}-selector`)}`);
|
10
7
|
|
11
8
|
if (targetElement.length) {
|
12
9
|
let refresh = function () {
|
@@ -15,7 +12,7 @@ $(document).ready(function () {
|
|
15
12
|
cache: false,
|
16
13
|
dataType: "html",
|
17
14
|
data: {
|
18
|
-
type_id:
|
15
|
+
type_id: source.val(),
|
19
16
|
selected: currentValue
|
20
17
|
},
|
21
18
|
success: function (data) {
|
@@ -24,8 +21,14 @@ $(document).ready(function () {
|
|
24
21
|
});
|
25
22
|
};
|
26
23
|
|
27
|
-
|
24
|
+
source.change(refresh);
|
28
25
|
refresh();
|
29
26
|
}
|
30
27
|
}
|
28
|
+
};
|
29
|
+
|
30
|
+
$(document).ready(function () {
|
31
|
+
let typeSelector = $("[data-scope-selector]");
|
32
|
+
controlSelector(typeSelector, "scope", "scope-id");
|
33
|
+
controlSelector(typeSelector, "signature-types", "signature-type");
|
31
34
|
});
|
@@ -0,0 +1,97 @@
|
|
1
|
+
@media all{
|
2
|
+
.initiative-title{
|
3
|
+
border: 1pt solid black;
|
4
|
+
margin: 15pt 0;
|
5
|
+
font-size: 12pt;
|
6
|
+
font-weight: bold;
|
7
|
+
text-transform: uppercase;
|
8
|
+
text-align: center;
|
9
|
+
}
|
10
|
+
|
11
|
+
.initiatives-votes-table{
|
12
|
+
width: 100%;
|
13
|
+
display: block;
|
14
|
+
border: 1pt solid black;
|
15
|
+
|
16
|
+
.initiatives-votes-table-header{
|
17
|
+
background-color: lightgray;
|
18
|
+
display: inline-block;
|
19
|
+
width: 100%;
|
20
|
+
font-size: 12pt;
|
21
|
+
font-weight: bold;
|
22
|
+
border-bottom: 1pt solid black;
|
23
|
+
}
|
24
|
+
|
25
|
+
.initiatives-votes-table-row{
|
26
|
+
width: 100%;
|
27
|
+
display: inline-block;
|
28
|
+
min-height: 33pt;
|
29
|
+
}
|
30
|
+
|
31
|
+
.initiatives-votes-table-row::after{
|
32
|
+
content: '';
|
33
|
+
display: inline-block;
|
34
|
+
clear: both;
|
35
|
+
}
|
36
|
+
|
37
|
+
.initiatives-votes-table-row:last-child{
|
38
|
+
border-bottom: 0;
|
39
|
+
}
|
40
|
+
|
41
|
+
.initiatives-votes-table-cell{
|
42
|
+
padding-left: 5pt;
|
43
|
+
word-wrap: break-word;
|
44
|
+
display: inline-block;
|
45
|
+
float: left;
|
46
|
+
min-height: 36pt;
|
47
|
+
|
48
|
+
.cell-content{
|
49
|
+
font-size: 10pt;
|
50
|
+
word-wrap: break-word;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
.checkbox-cell{
|
55
|
+
width: 36pt;
|
56
|
+
}
|
57
|
+
|
58
|
+
.initiatives-votes-table-cell:last-child{
|
59
|
+
border-right: 0;
|
60
|
+
}
|
61
|
+
|
62
|
+
.w11{
|
63
|
+
width: 10.8%;
|
64
|
+
}
|
65
|
+
|
66
|
+
.w20{
|
67
|
+
width: 19%;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
.no-border{
|
72
|
+
border: none !important;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
@page{
|
77
|
+
size: A4;
|
78
|
+
margin: 17mm 17mm 11mm 11mm;
|
79
|
+
}
|
80
|
+
|
81
|
+
@media print{
|
82
|
+
.title-bar{
|
83
|
+
display: none;
|
84
|
+
}
|
85
|
+
|
86
|
+
.layout-nav{
|
87
|
+
display: none;
|
88
|
+
}
|
89
|
+
|
90
|
+
.button.expanded{
|
91
|
+
display: none;
|
92
|
+
}
|
93
|
+
|
94
|
+
.page-break{
|
95
|
+
page-break-before: auto;
|
96
|
+
}
|
97
|
+
}
|
@@ -38,7 +38,7 @@ module Decidim
|
|
38
38
|
|
39
39
|
def authors
|
40
40
|
[present(model).author] +
|
41
|
-
model.committee_members.approved.non_deleted.map { |member| present(member.user) }
|
41
|
+
model.committee_members.approved.non_deleted.excluding_author.map { |member| present(member.user) }
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<div class="initiatives-votes-table-row">
|
2
|
+
<div class="initiatives-votes-table-cell w11">
|
3
|
+
<%= initiative_id %>
|
4
|
+
</div>
|
5
|
+
<div class="initiatives-votes-table-cell w11">
|
6
|
+
<%= initiative_title %>
|
7
|
+
</div>
|
8
|
+
<div class="initiatives-votes-table-cell w11">
|
9
|
+
<%= name_and_surname %>
|
10
|
+
</div>
|
11
|
+
<div class="initiatives-votes-table-cell w11">
|
12
|
+
<%= document_number %>
|
13
|
+
</div>
|
14
|
+
<div class="initiatives-votes-table-cell w11">
|
15
|
+
<%= date_of_birth %>
|
16
|
+
</div>
|
17
|
+
<div class="initiatives-votes-table-cell w11">
|
18
|
+
<%= postal_code %>
|
19
|
+
</div>
|
20
|
+
<div class="initiatives-votes-table-cell w11">
|
21
|
+
<%= time_and_date %>
|
22
|
+
</div>
|
23
|
+
<div class="initiatives-votes-table-cell w11">
|
24
|
+
<%= timestamp %>
|
25
|
+
</div>
|
26
|
+
<div class="initiatives-votes-table-cell w11">
|
27
|
+
<%= hash_id %>
|
28
|
+
</div>
|
29
|
+
</div>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module InitiativesVotes
|
5
|
+
class VoteCell < Decidim::ViewModel
|
6
|
+
delegate :timestamp, :hash_id, to: :model
|
7
|
+
|
8
|
+
def show
|
9
|
+
render
|
10
|
+
end
|
11
|
+
|
12
|
+
def initiative_id
|
13
|
+
model.initiative.reference
|
14
|
+
end
|
15
|
+
|
16
|
+
def initiative_title
|
17
|
+
translated_attribute(model.initiative.title)
|
18
|
+
end
|
19
|
+
|
20
|
+
def name_and_surname
|
21
|
+
metadata[:name_and_surname]
|
22
|
+
end
|
23
|
+
|
24
|
+
def document_number
|
25
|
+
metadata[:document_number]
|
26
|
+
end
|
27
|
+
|
28
|
+
def date_of_birth
|
29
|
+
metadata[:date_of_birth]
|
30
|
+
end
|
31
|
+
|
32
|
+
def postal_code
|
33
|
+
metadata[:postal_code]
|
34
|
+
end
|
35
|
+
|
36
|
+
def time_and_date
|
37
|
+
model.created_at
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
def encryptor
|
43
|
+
@encryptor ||= Decidim::Initiatives::DataEncryptor.new(secret: "personal user metadata")
|
44
|
+
end
|
45
|
+
|
46
|
+
def metadata
|
47
|
+
@metadata ||= model.encrypted_metadata ? encryptor.decrypt(model.encrypted_metadata) : {}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -39,7 +39,14 @@ module Decidim
|
|
39
39
|
organization: form.current_organization,
|
40
40
|
title: form.title,
|
41
41
|
description: form.description,
|
42
|
-
|
42
|
+
online_signature_enabled: form.online_signature_enabled,
|
43
|
+
undo_online_signatures_enabled: form.undo_online_signatures_enabled,
|
44
|
+
minimum_committee_members: form.minimum_committee_members,
|
45
|
+
banner_image: form.banner_image,
|
46
|
+
collect_user_extra_fields: form.collect_user_extra_fields,
|
47
|
+
extra_fields_legal_information: form.extra_fields_legal_information,
|
48
|
+
validate_sms_code_on_votes: form.validate_sms_code_on_votes,
|
49
|
+
document_number_authorization_handler: form.document_number_authorization_handler
|
43
50
|
)
|
44
51
|
|
45
52
|
return initiative_type unless initiative_type.valid?
|
@@ -44,18 +44,19 @@ module Decidim
|
|
44
44
|
attrs = {
|
45
45
|
title: form.title,
|
46
46
|
description: form.description,
|
47
|
-
|
48
|
-
hashtag: form.hashtag,
|
49
|
-
answer: form.answer,
|
50
|
-
answer_url: form.answer_url
|
47
|
+
hashtag: form.hashtag
|
51
48
|
}
|
52
49
|
|
53
|
-
|
50
|
+
if form.signature_type_updatable?
|
51
|
+
attrs[:signature_type] = form.signature_type
|
52
|
+
attrs[:scoped_type_id] = form.scoped_type_id if form.scoped_type_id
|
53
|
+
end
|
54
54
|
|
55
55
|
if current_user.admin?
|
56
56
|
attrs[:signature_start_date] = form.signature_start_date
|
57
57
|
attrs[:signature_end_date] = form.signature_end_date
|
58
|
-
attrs[:offline_votes] = form.offline_votes
|
58
|
+
attrs[:offline_votes] = form.offline_votes if form.offline_votes
|
59
|
+
attrs[:state] = form.state if form.state
|
59
60
|
|
60
61
|
if initiative.published?
|
61
62
|
@notify_extended = true if form.signature_end_date != initiative.signature_end_date &&
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
module Admin
|
6
|
+
# A command with all the business logic to answer
|
7
|
+
# initiatives.
|
8
|
+
class UpdateInitiativeAnswer < Rectify::Command
|
9
|
+
# Public: Initializes the command.
|
10
|
+
#
|
11
|
+
# initiative - Decidim::Initiative
|
12
|
+
# form - A form object with the params.
|
13
|
+
# current_user - Decidim::User
|
14
|
+
def initialize(initiative, form, current_user)
|
15
|
+
@form = form
|
16
|
+
@initiative = initiative
|
17
|
+
@current_user = current_user
|
18
|
+
end
|
19
|
+
|
20
|
+
# Executes the command. Broadcasts these events:
|
21
|
+
#
|
22
|
+
# - :ok when everything is valid.
|
23
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
24
|
+
#
|
25
|
+
# Returns nothing.
|
26
|
+
def call
|
27
|
+
return broadcast(:invalid) if form.invalid?
|
28
|
+
|
29
|
+
@initiative = Decidim.traceability.update!(
|
30
|
+
initiative,
|
31
|
+
current_user,
|
32
|
+
attributes
|
33
|
+
)
|
34
|
+
notify_initiative_is_extended if @notify_extended
|
35
|
+
broadcast(:ok, initiative)
|
36
|
+
rescue ActiveRecord::RecordInvalid
|
37
|
+
broadcast(:invalid, initiative)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
attr_reader :form, :initiative, :current_user
|
43
|
+
|
44
|
+
def attributes
|
45
|
+
attrs = {
|
46
|
+
answer: form.answer,
|
47
|
+
answer_url: form.answer_url
|
48
|
+
}
|
49
|
+
|
50
|
+
attrs[:answered_at] = Time.current if form.answer.present?
|
51
|
+
|
52
|
+
if form.signature_dates_required?
|
53
|
+
attrs[:signature_start_date] = form.signature_start_date
|
54
|
+
attrs[:signature_end_date] = form.signature_end_date
|
55
|
+
|
56
|
+
if initiative.published?
|
57
|
+
@notify_extended = true if form.signature_end_date != initiative.signature_end_date &&
|
58
|
+
form.signature_end_date > initiative.signature_end_date
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
attrs
|
63
|
+
end
|
64
|
+
|
65
|
+
def notify_initiative_is_extended
|
66
|
+
Decidim::EventsManager.publish(
|
67
|
+
event: "decidim.events.initiatives.initiative_extended",
|
68
|
+
event_class: Decidim::Initiatives::ExtendInitiativeEvent,
|
69
|
+
resource: initiative,
|
70
|
+
followers: initiative.followers - [initiative.author]
|
71
|
+
)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -26,6 +26,7 @@ module Decidim
|
|
26
26
|
initiative_type.update(attributes)
|
27
27
|
|
28
28
|
if initiative_type.valid?
|
29
|
+
upate_initiatives_signature_type
|
29
30
|
broadcast(:ok, initiative_type)
|
30
31
|
else
|
31
32
|
broadcast(:invalid)
|
@@ -39,12 +40,27 @@ module Decidim
|
|
39
40
|
def attributes
|
40
41
|
result = {
|
41
42
|
title: form.title,
|
42
|
-
description: form.description
|
43
|
+
description: form.description,
|
44
|
+
online_signature_enabled: form.online_signature_enabled,
|
45
|
+
undo_online_signatures_enabled: form.undo_online_signatures_enabled,
|
46
|
+
minimum_committee_members: form.minimum_committee_members,
|
47
|
+
collect_user_extra_fields: form.collect_user_extra_fields,
|
48
|
+
extra_fields_legal_information: form.extra_fields_legal_information,
|
49
|
+
validate_sms_code_on_votes: form.validate_sms_code_on_votes,
|
50
|
+
document_number_authorization_handler: form.document_number_authorization_handler
|
43
51
|
}
|
44
52
|
|
45
53
|
result[:banner_image] = form.banner_image unless form.banner_image.nil?
|
46
54
|
result
|
47
55
|
end
|
56
|
+
|
57
|
+
def upate_initiatives_signature_type
|
58
|
+
unless initiative_type.online_signature_enabled
|
59
|
+
initiative_type.initiatives.signature_type_updatable.each do |initiative|
|
60
|
+
initiative.update!(signature_type: Initiative.signature_types["offline"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
48
64
|
end
|
49
65
|
end
|
50
66
|
end
|
@@ -46,6 +46,7 @@ module Decidim
|
|
46
46
|
create_components_for(initiative)
|
47
47
|
send_notification(initiative)
|
48
48
|
add_author_as_follower(initiative)
|
49
|
+
add_author_as_committee_member(initiative)
|
49
50
|
end
|
50
51
|
|
51
52
|
initiative
|
@@ -109,6 +110,17 @@ module Decidim
|
|
109
110
|
|
110
111
|
Decidim::CreateFollow.new(form, current_user).call
|
111
112
|
end
|
113
|
+
|
114
|
+
def add_author_as_committee_member(initiative)
|
115
|
+
form = Decidim::Initiatives::CommitteeMemberForm
|
116
|
+
.from_params(initiative_id: initiative.id, user_id: initiative.decidim_author_id, state: "accepted")
|
117
|
+
.with_context(
|
118
|
+
current_organization: initiative.organization,
|
119
|
+
current_user: current_user
|
120
|
+
)
|
121
|
+
|
122
|
+
Decidim::Initiatives::SpawnCommitteeRequest.new(form, current_user).call
|
123
|
+
end
|
112
124
|
end
|
113
125
|
end
|
114
126
|
end
|
@@ -7,10 +7,10 @@ module Decidim
|
|
7
7
|
class SpawnCommitteeRequest < Rectify::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# form - Decidim::Initiative::CommitteeMemberForm
|
11
11
|
# current_user - Decidim::User
|
12
|
-
def initialize(
|
13
|
-
@
|
12
|
+
def initialize(form, current_user)
|
13
|
+
@form = form
|
14
14
|
@current_user = current_user
|
15
15
|
end
|
16
16
|
|
@@ -21,6 +21,7 @@ module Decidim
|
|
21
21
|
#
|
22
22
|
# Returns nothing.
|
23
23
|
def call
|
24
|
+
return broadcast(:invalid) if form.invalid?
|
24
25
|
request = create_request
|
25
26
|
|
26
27
|
if request.persisted?
|
@@ -32,13 +33,13 @@ module Decidim
|
|
32
33
|
|
33
34
|
private
|
34
35
|
|
35
|
-
attr_reader :
|
36
|
+
attr_reader :form, :current_user
|
36
37
|
|
37
38
|
def create_request
|
38
39
|
request = InitiativesCommitteeMember.new(
|
39
|
-
decidim_initiatives_id:
|
40
|
-
decidim_users_id:
|
41
|
-
state:
|
40
|
+
decidim_initiatives_id: form.initiative_id,
|
41
|
+
decidim_users_id: form.user_id,
|
42
|
+
state: form.state
|
42
43
|
)
|
43
44
|
return request unless request.valid?
|
44
45
|
|