decidim-initiatives 0.23.5 → 0.24.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/stylesheet/decidim/initiatives/initiatives.scss +6 -0
- data/app/assets/stylesheet/decidim/initiatives/print-initiative.css.scss +22 -0
- data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +4 -8
- data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_cell.rb +5 -1
- data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_settings_form/show.erb +2 -1
- data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_settings_form_cell.rb +12 -1
- data/app/commands/decidim/initiatives/admin/update_initiative.rb +3 -3
- data/app/commands/decidim/initiatives/admin/update_initiative_answer.rb +3 -3
- data/app/commands/decidim/initiatives/approve_membership_request.rb +40 -0
- data/app/commands/decidim/initiatives/create_initiative.rb +5 -4
- data/app/commands/decidim/initiatives/revoke_membership_request.rb +40 -0
- data/app/commands/decidim/initiatives/send_initiative_to_technical_validation.rb +57 -0
- data/app/commands/decidim/initiatives/spawn_committee_request.rb +18 -0
- data/app/commands/decidim/initiatives/update_initiative.rb +74 -0
- data/app/controllers/decidim/initiatives/admin/committee_requests_controller.rb +15 -4
- data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +1 -1
- data/app/controllers/decidim/initiatives/admin/moderations/reports_controller.rb +18 -0
- data/app/controllers/decidim/initiatives/committee_requests_controller.rb +32 -0
- data/app/controllers/decidim/initiatives/initiatives_controller.rb +58 -1
- data/app/events/decidim/initiatives/approve_membership_request_event.rb +61 -0
- data/app/events/decidim/initiatives/initiative_sent_to_technical_validation_event.rb +19 -0
- data/app/events/decidim/initiatives/revoke_membership_request_event.rb +61 -0
- data/app/events/decidim/initiatives/spawn_committee_request_event.rb +61 -0
- data/app/forms/decidim/initiatives/admin/initiative_form.rb +8 -4
- data/app/forms/decidim/initiatives/admin/initiative_type_form.rb +3 -0
- data/app/forms/decidim/initiatives/initiative_form.rb +25 -2
- data/app/forms/decidim/initiatives/vote_form.rb +1 -1
- data/app/helpers/decidim/initiatives/admin/initiative_admin_menu_helper.rb +15 -0
- data/app/helpers/decidim/initiatives/create_initiative_helper.rb +3 -2
- data/app/models/concerns/decidim/initiatives/has_area.rb +1 -1
- data/app/models/decidim/initiative.rb +0 -1
- data/app/permissions/decidim/initiatives/admin/permissions.rb +5 -4
- data/app/permissions/decidim/initiatives/permissions.rb +47 -20
- data/app/queries/decidim/initiatives/initiatives_promoted.rb +1 -1
- data/app/queries/decidim/initiatives/organization_prioritized_initiatives.rb +13 -2
- data/app/serializers/decidim/initiatives/initiative_serializer.rb +3 -0
- data/app/services/decidim/initiatives/dummy_timestamp.rb +1 -1
- data/app/services/decidim/initiatives/initiative_search.rb +15 -13
- data/app/services/decidim/initiatives/pdf_signature_example.rb +27 -27
- data/app/views/decidim/initiatives/admin/initiatives/edit.html.erb +1 -1
- data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +6 -0
- data/app/views/decidim/initiatives/admin/initiatives_type_scopes/edit.html.erb +24 -17
- data/app/views/decidim/initiatives/admin/initiatives_type_scopes/new.html.erb +17 -11
- data/app/views/decidim/initiatives/create_initiative/_finish_help.html.erb +2 -7
- data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +4 -17
- data/app/views/decidim/initiatives/create_initiative/finish.html.erb +11 -11
- data/app/views/decidim/initiatives/initiatives/_committee_members.html.erb +73 -0
- data/app/views/decidim/initiatives/initiatives/_form.html.erb +112 -0
- data/app/views/decidim/initiatives/initiatives/_result.html.erb +1 -1
- data/app/views/decidim/initiatives/initiatives/_send_to_technical_validation.html.erb +8 -0
- data/app/views/decidim/initiatives/initiatives/edit.html.erb +78 -0
- data/app/views/decidim/initiatives/initiatives/print.html.erb +156 -0
- data/app/views/decidim/initiatives/initiatives/show.html.erb +19 -7
- data/app/views/layouts/decidim/admin/initiative.html.erb +0 -1
- data/app/views/layouts/decidim/admin/initiatives.html.erb +2 -15
- data/config/locales/ar.yml +3 -28
- data/config/locales/ca.yml +62 -32
- data/config/locales/cs.yml +108 -48
- data/config/locales/de.yml +91 -31
- data/config/locales/el.yml +3 -34
- data/config/locales/en.yml +94 -34
- data/config/locales/es-MX.yml +9 -36
- data/config/locales/es-PY.yml +9 -36
- data/config/locales/es.yml +10 -37
- data/config/locales/eu.yml +3 -28
- data/config/locales/fi-plain.yml +94 -34
- data/config/locales/fi.yml +94 -34
- data/config/locales/fr-CA.yml +96 -36
- data/config/locales/fr.yml +96 -36
- data/config/locales/gl.yml +3 -36
- data/config/locales/hu.yml +3 -32
- data/config/locales/id-ID.yml +3 -28
- data/config/locales/is-IS.yml +3 -13
- data/config/locales/it.yml +3 -34
- data/config/locales/ja.yml +2 -35
- data/config/locales/lv.yml +3 -32
- data/config/locales/nl.yml +31 -34
- data/config/locales/no.yml +2 -32
- data/config/locales/pl.yml +78 -33
- data/config/locales/pt-BR.yml +3 -28
- data/config/locales/pt.yml +4 -35
- data/config/locales/ro-RO.yml +3 -35
- data/config/locales/ru.yml +3 -21
- data/config/locales/sk.yml +3 -30
- data/config/locales/sr-CS.yml +0 -7
- data/config/locales/sv.yml +2 -37
- data/config/locales/tr-TR.yml +68 -34
- data/config/locales/uk.yml +3 -21
- data/config/locales/zh-CN.yml +2 -35
- data/db/migrate/20171017095143_update_initiative_scoped_type.rb +0 -1
- data/db/migrate/20191107134847_add_scopes_to_initiatives_votes.rb +1 -1
- data/db/migrate/20191118105634_allow_multiple_offline_votes.rb +1 -1
- data/lib/decidim/api/initiative_api_type.rb +26 -0
- data/lib/decidim/api/initiative_committee_member_type.rb +18 -0
- data/lib/decidim/api/initiative_type.rb +49 -0
- data/lib/decidim/api/initiative_type_interface.rb +8 -3
- data/lib/decidim/initiatives.rb +1 -0
- data/lib/decidim/initiatives/admin_engine.rb +23 -1
- data/lib/decidim/initiatives/api.rb +3 -0
- data/lib/decidim/initiatives/engine.rb +14 -9
- data/lib/decidim/initiatives/initiatives_filter_form_builder.rb +19 -12
- data/lib/decidim/initiatives/participatory_space.rb +6 -6
- data/lib/decidim/initiatives/query_extensions.rb +42 -19
- data/lib/decidim/initiatives/test/factories.rb +36 -0
- data/lib/decidim/initiatives/version.rb +1 -1
- metadata +34 -19
- data/app/types/decidim/initiatives/initiative_api_type.rb +0 -26
- data/app/types/decidim/initiatives/initiative_committee_member_type.rb +0 -18
- data/app/types/decidim/initiatives/initiative_type.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 309f109451d280c9b81e7cbd45d029f362719d74ee45828b6703f7e194df81a2
|
4
|
+
data.tar.gz: 7ea66fb898519ef7f5bcba6ff4f1655bf8dd0a08727c7002445f2a81776c3e66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a00f4b05f5d6f52d021b5199e62f481dc0d5940f478a4d72190558be21e166e602d3c9b2d3778696d649f13a58b3480156c055176c1d3a2315a5a4a4e16e157c
|
7
|
+
data.tar.gz: 4c4870bf5f8de74122276425cf90b0cb15d10d8731bcff841ceabf9603c9a7c9fe07bec28ae3b22ceea97452ffb9690aed932670c8e58e86c6a5e03a7959a7cb
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ Just use the following line:
|
|
53
53
|
Decidim::Initiatives.do_not_require_authorization = true
|
54
54
|
```
|
55
55
|
|
56
|
-
All the settings and their default values which can be overriden can be found in the file [`lib/decidim/initiatives.rb`](https://github.com/decidim/decidim/blob/
|
56
|
+
All the settings and their default values which can be overriden can be found in the file [`lib/decidim/initiatives.rb`](https://github.com/decidim/decidim/blob/develop/decidim-initiatives/lib/decidim/initiatives.rb).
|
57
57
|
|
58
58
|
For example, you can also change the minimum number of required committee members to 1 (default is 2) by adding this line:
|
59
59
|
```
|
@@ -1,4 +1,10 @@
|
|
1
1
|
@media all{
|
2
|
+
.printable{
|
3
|
+
width: 80%;
|
4
|
+
margin-left: auto;
|
5
|
+
margin-right: auto;
|
6
|
+
}
|
7
|
+
|
2
8
|
.initiative-letterhead{
|
3
9
|
font-size: 14pt;
|
4
10
|
font-weight: bold;
|
@@ -104,6 +110,14 @@
|
|
104
110
|
}
|
105
111
|
|
106
112
|
@media print{
|
113
|
+
.process-header{
|
114
|
+
display: none;
|
115
|
+
}
|
116
|
+
|
117
|
+
.main-nav{
|
118
|
+
display: none;
|
119
|
+
}
|
120
|
+
|
107
121
|
.title-bar{
|
108
122
|
display: none;
|
109
123
|
}
|
@@ -119,4 +133,12 @@
|
|
119
133
|
.page-break{
|
120
134
|
page-break-before: auto;
|
121
135
|
}
|
136
|
+
|
137
|
+
.main-footer{
|
138
|
+
display: none;
|
139
|
+
}
|
140
|
+
|
141
|
+
.mini-footer{
|
142
|
+
display: none;
|
143
|
+
}
|
122
144
|
}
|
@@ -5,16 +5,12 @@
|
|
5
5
|
<div class="row small-up-1 smallmedium-up-2 mediumlarge-up-3 large-up-4 card-grid">
|
6
6
|
<% highlighted_initiatives.each do |initiative| %>
|
7
7
|
<div class="column">
|
8
|
-
|
9
|
-
|
10
|
-
<span class="show-for-sr"><%= translated_attribute initiative.title %></span>
|
11
|
-
<% end %>
|
8
|
+
<%= link_to decidim_initiatives.initiative_path(initiative), class: "card card--initiative card--mini" do %>
|
9
|
+
<span class="show-for-sr"><%= translated_attribute initiative.title %></span>
|
12
10
|
<div class="card__content">
|
13
|
-
|
14
|
-
<span class="card__title"><%= decidim_html_escape(translated_attribute(initiative.title)) %></span>
|
15
|
-
<% end %>
|
11
|
+
<span class="card__title card__link"><%= decidim_html_escape(translated_attribute(initiative.title)) %></span>
|
16
12
|
</div>
|
17
|
-
|
13
|
+
<% end %>
|
18
14
|
</div>
|
19
15
|
<% end %>
|
20
16
|
</div>
|
@@ -16,9 +16,13 @@ module Decidim
|
|
16
16
|
model.settings.max_results
|
17
17
|
end
|
18
18
|
|
19
|
+
def order
|
20
|
+
model.settings.order
|
21
|
+
end
|
22
|
+
|
19
23
|
def highlighted_initiatives
|
20
24
|
@highlighted_initiatives ||= OrganizationPrioritizedInitiatives
|
21
|
-
.new(current_organization)
|
25
|
+
.new(current_organization, order)
|
22
26
|
.query
|
23
27
|
.limit(max_results)
|
24
28
|
end
|
data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_settings_form/show.erb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
1
|
<% form.fields_for :settings, form.object.settings do |settings_fields| %>
|
2
|
-
<%= settings_fields.select :max_results, [4, 8, 12], prompt: "", label:
|
2
|
+
<%= settings_fields.select :max_results, [4, 8, 12], prompt: "", label: max_results_label %>
|
3
|
+
<%= settings_fields.select :order, order_select, prompt: "", label: order_label %>
|
3
4
|
<% end %>
|
data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_settings_form_cell.rb
CHANGED
@@ -10,9 +10,20 @@ module Decidim
|
|
10
10
|
options[:content_block]
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def max_results_label
|
14
14
|
I18n.t("decidim.initiatives.admin.content_blocks.highlighted_initiatives.max_results")
|
15
15
|
end
|
16
|
+
|
17
|
+
def order_label
|
18
|
+
I18n.t("decidim.initiatives.admin.content_blocks.highlighted_initiatives.order.label")
|
19
|
+
end
|
20
|
+
|
21
|
+
def order_select
|
22
|
+
[
|
23
|
+
[I18n.t("decidim.initiatives.admin.content_blocks.highlighted_initiatives.order.default"), "default"],
|
24
|
+
[I18n.t("decidim.initiatives.admin.content_blocks.highlighted_initiatives.order.most_recent"), "most_recent"]
|
25
|
+
]
|
26
|
+
end
|
16
27
|
end
|
17
28
|
end
|
18
29
|
end
|
@@ -80,9 +80,9 @@ module Decidim
|
|
80
80
|
attrs[:state] = form.state if form.state
|
81
81
|
attrs[:decidim_area_id] = form.area_id
|
82
82
|
|
83
|
-
if initiative.published?
|
84
|
-
|
85
|
-
|
83
|
+
if initiative.published? && form.signature_end_date != initiative.signature_end_date &&
|
84
|
+
form.signature_end_date > initiative.signature_end_date
|
85
|
+
@notify_extended = true
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -53,9 +53,9 @@ module Decidim
|
|
53
53
|
attrs[:signature_start_date] = form.signature_start_date
|
54
54
|
attrs[:signature_end_date] = form.signature_end_date
|
55
55
|
|
56
|
-
if initiative.published?
|
57
|
-
|
58
|
-
|
56
|
+
if initiative.published? && form.signature_end_date != initiative.signature_end_date &&
|
57
|
+
form.signature_end_date > initiative.signature_end_date
|
58
|
+
@notify_extended = true
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
# A command with all the business logic that creates a new initiative.
|
6
|
+
class ApproveMembershipRequest < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# membership_request - A pending committee member
|
10
|
+
def initialize(membership_request)
|
11
|
+
@membership_request = membership_request
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes the command. Broadcasts these events:
|
15
|
+
#
|
16
|
+
# - :ok when everything is valid.
|
17
|
+
#
|
18
|
+
# Returns nothing.
|
19
|
+
def call
|
20
|
+
@membership_request.accepted!
|
21
|
+
notify_applicant
|
22
|
+
|
23
|
+
broadcast(:ok, @membership_request)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def notify_applicant
|
29
|
+
Decidim::EventsManager.publish(
|
30
|
+
event: "decidim.events.initiatives.approve_membership_request",
|
31
|
+
event_class: Decidim::Initiatives::ApproveMembershipRequestEvent,
|
32
|
+
resource: @membership_request.initiative,
|
33
|
+
affected_users: [@membership_request.user],
|
34
|
+
force_send: true,
|
35
|
+
extra: { author: @membership_request.initiative.author }
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
# A command with all the business logic that creates a new initiative.
|
6
6
|
class CreateInitiative < Rectify::Command
|
7
7
|
include CurrentLocale
|
8
|
-
include
|
8
|
+
include ::Decidim::MultipleAttachmentsMethods
|
9
9
|
|
10
10
|
# Public: Initializes the command.
|
11
11
|
#
|
@@ -26,8 +26,8 @@ module Decidim
|
|
26
26
|
return broadcast(:invalid) if form.invalid?
|
27
27
|
|
28
28
|
if process_attachments?
|
29
|
-
|
30
|
-
return broadcast(:invalid) if
|
29
|
+
build_attachments
|
30
|
+
return broadcast(:invalid) if attachments_invalid?
|
31
31
|
end
|
32
32
|
|
33
33
|
initiative = create_initiative
|
@@ -51,7 +51,8 @@ module Decidim
|
|
51
51
|
initiative.transaction do
|
52
52
|
initiative.save!
|
53
53
|
@attached_to = initiative
|
54
|
-
|
54
|
+
create_attachments if process_attachments?
|
55
|
+
|
55
56
|
create_components_for(initiative)
|
56
57
|
send_notification(initiative)
|
57
58
|
add_author_as_follower(initiative)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
# A command with all the business logic that creates a new initiative.
|
6
|
+
class RevokeMembershipRequest < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# membership_request - A pending committee member
|
10
|
+
def initialize(membership_request)
|
11
|
+
@membership_request = membership_request
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes the command. Broadcasts these events:
|
15
|
+
#
|
16
|
+
# - :ok when everything is valid.
|
17
|
+
#
|
18
|
+
# Returns nothing.
|
19
|
+
def call
|
20
|
+
@membership_request.rejected!
|
21
|
+
notify_applicant
|
22
|
+
|
23
|
+
broadcast(:ok, @membership_request)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def notify_applicant
|
29
|
+
Decidim::EventsManager.publish(
|
30
|
+
event: "decidim.events.initiatives.revoke_membership_request",
|
31
|
+
event_class: Decidim::Initiatives::RevokeMembershipRequestEvent,
|
32
|
+
resource: @membership_request.initiative,
|
33
|
+
affected_users: [@membership_request.user],
|
34
|
+
force_send: true,
|
35
|
+
extra: { author: @membership_request.initiative.author }
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
# A command with all the business logic that sends an
|
6
|
+
# existing initiative to technical validation.
|
7
|
+
class SendInitiativeToTechnicalValidation < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# initiative - Decidim::Initiative
|
11
|
+
# current_user - the user performing the action
|
12
|
+
def initialize(initiative, current_user)
|
13
|
+
@initiative = initiative
|
14
|
+
@current_user = current_user
|
15
|
+
end
|
16
|
+
|
17
|
+
# Executes the command. Broadcasts these events:
|
18
|
+
#
|
19
|
+
# - :ok when everything is valid.
|
20
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
21
|
+
#
|
22
|
+
# Returns nothing.
|
23
|
+
def call
|
24
|
+
@initiative = Decidim.traceability.perform_action!(
|
25
|
+
:send_to_technical_validation,
|
26
|
+
initiative,
|
27
|
+
current_user
|
28
|
+
) do
|
29
|
+
initiative.validating!
|
30
|
+
initiative
|
31
|
+
end
|
32
|
+
|
33
|
+
notify_admins
|
34
|
+
|
35
|
+
broadcast(:ok, initiative)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
attr_reader :initiative, :current_user
|
41
|
+
|
42
|
+
def notify_admins
|
43
|
+
affected_users = Decidim::User.org_admins_except_me(current_user).all
|
44
|
+
|
45
|
+
data = {
|
46
|
+
event: "decidim.events.initiatives.initiative_sent_to_technical_validation",
|
47
|
+
event_class: Decidim::Initiatives::InitiativeSentToTechnicalValidationEvent,
|
48
|
+
resource: initiative,
|
49
|
+
affected_users: affected_users,
|
50
|
+
force_send: true
|
51
|
+
}
|
52
|
+
|
53
|
+
Decidim::EventsManager.publish(data)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -26,6 +26,7 @@ module Decidim
|
|
26
26
|
request = create_request
|
27
27
|
|
28
28
|
if request.persisted?
|
29
|
+
notify_author
|
29
30
|
broadcast(:ok, request)
|
30
31
|
else
|
31
32
|
broadcast(:invalid, request)
|
@@ -47,6 +48,23 @@ module Decidim
|
|
47
48
|
request.save
|
48
49
|
request
|
49
50
|
end
|
51
|
+
|
52
|
+
def notify_author
|
53
|
+
return if initiative.author == current_user
|
54
|
+
|
55
|
+
Decidim::EventsManager.publish(
|
56
|
+
event: "decidim.events.initiatives.spawn_committee_request",
|
57
|
+
event_class: Decidim::Initiatives::SpawnCommitteeRequestEvent,
|
58
|
+
resource: initiative,
|
59
|
+
affected_users: [initiative.author],
|
60
|
+
force_send: true,
|
61
|
+
extra: { applicant: current_user }
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def initiative
|
66
|
+
@initiative ||= Decidim::Initiative.find(form.initiative_id)
|
67
|
+
end
|
50
68
|
end
|
51
69
|
end
|
52
70
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Initiatives
|
5
|
+
# A command with all the business logic that updates an
|
6
|
+
# existing initiative.
|
7
|
+
class UpdateInitiative < Rectify::Command
|
8
|
+
include ::Decidim::MultipleAttachmentsMethods
|
9
|
+
include CurrentLocale
|
10
|
+
|
11
|
+
# Public: Initializes the command.
|
12
|
+
#
|
13
|
+
# initiative - Decidim::Initiative
|
14
|
+
# form - A form object with the params.
|
15
|
+
def initialize(initiative, form, current_user)
|
16
|
+
@form = form
|
17
|
+
@initiative = initiative
|
18
|
+
@current_user = current_user
|
19
|
+
@attached_to = initiative
|
20
|
+
end
|
21
|
+
|
22
|
+
# Executes the command. Broadcasts these events:
|
23
|
+
#
|
24
|
+
# - :ok when everything is valid.
|
25
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
26
|
+
#
|
27
|
+
# Returns nothing.
|
28
|
+
def call
|
29
|
+
return broadcast(:invalid) if form.invalid?
|
30
|
+
|
31
|
+
if process_attachments?
|
32
|
+
@initiative.attachments.where(id: form.documents).destroy_all
|
33
|
+
|
34
|
+
build_attachments
|
35
|
+
return broadcast(:invalid) if attachments_invalid?
|
36
|
+
end
|
37
|
+
@initiative = Decidim.traceability.update!(
|
38
|
+
initiative,
|
39
|
+
current_user,
|
40
|
+
attributes
|
41
|
+
)
|
42
|
+
|
43
|
+
create_attachments if process_attachments?
|
44
|
+
broadcast(:ok, initiative)
|
45
|
+
rescue ActiveRecord::RecordInvalid
|
46
|
+
broadcast(:invalid, initiative)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
attr_reader :form, :initiative, :current_user
|
52
|
+
|
53
|
+
def attributes
|
54
|
+
attrs = {
|
55
|
+
title: { current_locale => form.title },
|
56
|
+
description: { current_locale => form.description },
|
57
|
+
hashtag: form.hashtag
|
58
|
+
}
|
59
|
+
|
60
|
+
if form.signature_type_updatable?
|
61
|
+
attrs[:signature_type] = form.signature_type
|
62
|
+
attrs[:scoped_type_id] = form.scoped_type_id if form.scoped_type_id
|
63
|
+
end
|
64
|
+
|
65
|
+
if initiative.created?
|
66
|
+
attrs[:signature_end_date] = form.signature_end_date if initiative.custom_signature_end_date_enabled?
|
67
|
+
attrs[:decidim_area_id] = form.area_id if initiative.area_enabled?
|
68
|
+
end
|
69
|
+
|
70
|
+
attrs
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|