decidim-initiatives 0.23.6 → 0.24.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/stylesheet/decidim/initiatives/initiatives.scss +6 -0
  4. data/app/assets/stylesheet/decidim/initiatives/print-initiative.css.scss +22 -0
  5. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +4 -8
  6. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_cell.rb +5 -1
  7. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_settings_form/show.erb +2 -1
  8. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_settings_form_cell.rb +12 -1
  9. data/app/commands/decidim/initiatives/admin/update_initiative.rb +3 -3
  10. data/app/commands/decidim/initiatives/admin/update_initiative_answer.rb +3 -3
  11. data/app/commands/decidim/initiatives/approve_membership_request.rb +40 -0
  12. data/app/commands/decidim/initiatives/create_initiative.rb +5 -4
  13. data/app/commands/decidim/initiatives/revoke_membership_request.rb +40 -0
  14. data/app/commands/decidim/initiatives/send_initiative_to_technical_validation.rb +57 -0
  15. data/app/commands/decidim/initiatives/spawn_committee_request.rb +18 -0
  16. data/app/commands/decidim/initiatives/update_initiative.rb +74 -0
  17. data/app/controllers/decidim/initiatives/admin/committee_requests_controller.rb +15 -4
  18. data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +1 -1
  19. data/app/controllers/decidim/initiatives/admin/moderations/reports_controller.rb +18 -0
  20. data/app/controllers/decidim/initiatives/committee_requests_controller.rb +32 -0
  21. data/app/controllers/decidim/initiatives/initiatives_controller.rb +58 -1
  22. data/app/events/decidim/initiatives/approve_membership_request_event.rb +61 -0
  23. data/app/events/decidim/initiatives/initiative_sent_to_technical_validation_event.rb +19 -0
  24. data/app/events/decidim/initiatives/revoke_membership_request_event.rb +61 -0
  25. data/app/events/decidim/initiatives/spawn_committee_request_event.rb +61 -0
  26. data/app/forms/decidim/initiatives/admin/initiative_form.rb +8 -4
  27. data/app/forms/decidim/initiatives/admin/initiative_type_form.rb +3 -0
  28. data/app/forms/decidim/initiatives/initiative_form.rb +25 -2
  29. data/app/forms/decidim/initiatives/vote_form.rb +1 -1
  30. data/app/helpers/decidim/initiatives/admin/initiative_admin_menu_helper.rb +15 -0
  31. data/app/helpers/decidim/initiatives/create_initiative_helper.rb +3 -2
  32. data/app/models/concerns/decidim/initiatives/has_area.rb +1 -1
  33. data/app/models/decidim/initiative.rb +0 -1
  34. data/app/permissions/decidim/initiatives/admin/permissions.rb +5 -4
  35. data/app/permissions/decidim/initiatives/permissions.rb +47 -20
  36. data/app/queries/decidim/initiatives/initiatives_promoted.rb +1 -1
  37. data/app/queries/decidim/initiatives/organization_prioritized_initiatives.rb +13 -2
  38. data/app/serializers/decidim/initiatives/initiative_serializer.rb +3 -0
  39. data/app/services/decidim/initiatives/dummy_timestamp.rb +1 -1
  40. data/app/services/decidim/initiatives/initiative_search.rb +15 -13
  41. data/app/services/decidim/initiatives/pdf_signature_example.rb +27 -27
  42. data/app/views/decidim/initiatives/admin/initiatives/edit.html.erb +1 -1
  43. data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +6 -0
  44. data/app/views/decidim/initiatives/admin/initiatives_type_scopes/edit.html.erb +24 -17
  45. data/app/views/decidim/initiatives/admin/initiatives_type_scopes/new.html.erb +17 -11
  46. data/app/views/decidim/initiatives/admin/initiatives_types/index.html.erb +1 -1
  47. data/app/views/decidim/initiatives/create_initiative/_finish_help.html.erb +2 -7
  48. data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +4 -17
  49. data/app/views/decidim/initiatives/create_initiative/finish.html.erb +11 -11
  50. data/app/views/decidim/initiatives/initiatives/_committee_members.html.erb +73 -0
  51. data/app/views/decidim/initiatives/initiatives/_form.html.erb +112 -0
  52. data/app/views/decidim/initiatives/initiatives/_result.html.erb +1 -1
  53. data/app/views/decidim/initiatives/initiatives/_send_to_technical_validation.html.erb +8 -0
  54. data/app/views/decidim/initiatives/initiatives/edit.html.erb +78 -0
  55. data/app/views/decidim/initiatives/initiatives/print.html.erb +156 -0
  56. data/app/views/decidim/initiatives/initiatives/show.html.erb +19 -7
  57. data/app/views/layouts/decidim/admin/initiative.html.erb +0 -1
  58. data/app/views/layouts/decidim/admin/initiatives.html.erb +2 -15
  59. data/config/locales/ar.yml +3 -28
  60. data/config/locales/ca.yml +62 -32
  61. data/config/locales/cs.yml +112 -52
  62. data/config/locales/de.yml +91 -31
  63. data/config/locales/el.yml +3 -34
  64. data/config/locales/en.yml +94 -34
  65. data/config/locales/es-MX.yml +9 -36
  66. data/config/locales/es-PY.yml +9 -36
  67. data/config/locales/es.yml +10 -37
  68. data/config/locales/eu.yml +3 -28
  69. data/config/locales/fi-plain.yml +94 -34
  70. data/config/locales/fi.yml +94 -34
  71. data/config/locales/fr-CA.yml +96 -36
  72. data/config/locales/fr.yml +96 -36
  73. data/config/locales/gl.yml +3 -36
  74. data/config/locales/hu.yml +3 -32
  75. data/config/locales/id-ID.yml +3 -28
  76. data/config/locales/is-IS.yml +3 -13
  77. data/config/locales/it.yml +3 -34
  78. data/config/locales/ja.yml +2 -35
  79. data/config/locales/lv.yml +3 -32
  80. data/config/locales/nl.yml +31 -34
  81. data/config/locales/no.yml +2 -32
  82. data/config/locales/pl.yml +78 -33
  83. data/config/locales/pt-BR.yml +3 -28
  84. data/config/locales/pt.yml +4 -35
  85. data/config/locales/ro-RO.yml +3 -35
  86. data/config/locales/ru.yml +3 -21
  87. data/config/locales/sk.yml +3 -30
  88. data/config/locales/sr-CS.yml +0 -7
  89. data/config/locales/sv.yml +2 -37
  90. data/config/locales/tr-TR.yml +68 -34
  91. data/config/locales/uk.yml +3 -21
  92. data/config/locales/zh-CN.yml +2 -35
  93. data/db/migrate/20171017095143_update_initiative_scoped_type.rb +0 -1
  94. data/db/migrate/20191107134847_add_scopes_to_initiatives_votes.rb +1 -1
  95. data/db/migrate/20191118105634_allow_multiple_offline_votes.rb +1 -1
  96. data/lib/decidim/api/initiative_api_type.rb +26 -0
  97. data/lib/decidim/api/initiative_committee_member_type.rb +18 -0
  98. data/lib/decidim/api/initiative_type.rb +49 -0
  99. data/lib/decidim/api/initiative_type_interface.rb +8 -3
  100. data/lib/decidim/initiatives/admin_engine.rb +23 -1
  101. data/lib/decidim/initiatives/api.rb +3 -0
  102. data/lib/decidim/initiatives/engine.rb +14 -9
  103. data/lib/decidim/initiatives/initiatives_filter_form_builder.rb +19 -12
  104. data/lib/decidim/initiatives/participatory_space.rb +6 -6
  105. data/lib/decidim/initiatives/query_extensions.rb +42 -19
  106. data/lib/decidim/initiatives/test/factories.rb +36 -0
  107. data/lib/decidim/initiatives/version.rb +1 -1
  108. data/lib/decidim/initiatives.rb +1 -0
  109. metadata +34 -19
  110. data/app/types/decidim/initiatives/initiative_api_type.rb +0 -26
  111. data/app/types/decidim/initiatives/initiative_committee_member_type.rb +0 -18
  112. 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: 3c11295256da49795faf3139e2c50e896349f2cafc6dce633fcb439e34d21d90
4
- data.tar.gz: d4a2fd6edbe53bb93850243ebf2fb055b6d61e799bfba7204e3a44af6bd86c52
3
+ metadata.gz: 309f109451d280c9b81e7cbd45d029f362719d74ee45828b6703f7e194df81a2
4
+ data.tar.gz: 7ea66fb898519ef7f5bcba6ff4f1655bf8dd0a08727c7002445f2a81776c3e66
5
5
  SHA512:
6
- metadata.gz: 13af4b676b7a6baed12e40aee1bac41cb5b43fe85bd5de5ec1e2449a77a7597ceb9e1ac9d83dc6e2235a82cf2c142cab8d621409cbd65290d2a4bf305e7d686d
7
- data.tar.gz: 5642d94ecef34874b9ac82e098010f6a7b4c82856bc7ec5ea33a3b5174eb3d56fc11f1b3c23226c8747be54e555638d166eccf3c9ffa51c94f6d15318ad2443e
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/master/decidim-initiatives/lib/decidim/initiatives.rb).
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
  ```
@@ -57,3 +57,9 @@
57
57
  margin-bottom: 1.5rem;
58
58
  }
59
59
  }
60
+
61
+ fieldset{
62
+ border: 1px solid #e8e8e8;
63
+ padding: .5em;
64
+ margin-bottom: 1em;
65
+ }
@@ -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
- <div class="card card--initiative card--mini">
9
- <%= link_to decidim_initiatives.initiative_path(initiative), class: "card__link" do %>
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
- <%= link_to decidim_initiatives.initiative_path(initiative), class: "card__link" do %>
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
- </div>
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
@@ -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: 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 %>
@@ -10,9 +10,20 @@ module Decidim
10
10
  options[:content_block]
11
11
  end
12
12
 
13
- def label
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
- @notify_extended = true if form.signature_end_date != initiative.signature_end_date &&
85
- form.signature_end_date > initiative.signature_end_date
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
- @notify_extended = true if form.signature_end_date != initiative.signature_end_date &&
58
- form.signature_end_date > initiative.signature_end_date
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 AttachmentMethods
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
- build_attachment
30
- return broadcast(:invalid) if attachment_invalid?
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
- create_attachment if process_attachments?
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
@@ -15,16 +15,27 @@ module Decidim
15
15
  # GET /initiatives/:initiative_id/committee_requests/:id/approve
16
16
  def approve
17
17
  enforce_permission_to :approve, :initiative_committee_member, request: membership_request
18
- membership_request.accepted!
19
18
 
20
- redirect_to initiative_committee_requests_path(membership_request.initiative)
19
+ ApproveMembershipRequest.call(membership_request) do
20
+ on(:ok) do
21
+ redirect_to edit_initiative_path(current_initiative), flash: {
22
+ notice: I18n.t("success", scope: "decidim.initiatives.committee_requests.approve")
23
+ }
24
+ end
25
+ end
21
26
  end
22
27
 
23
28
  # DELETE /initiatives/:initiative_id/committee_requests/:id/revoke
24
29
  def revoke
25
30
  enforce_permission_to :revoke, :initiative_committee_member, request: membership_request
26
- membership_request.rejected!
27
- redirect_to initiative_committee_requests_path(membership_request.initiative)
31
+
32
+ RevokeMembershipRequest.call(membership_request) do
33
+ on(:ok) do
34
+ redirect_to edit_initiative_path(current_initiative), flash: {
35
+ notice: I18n.t("success", scope: "decidim.initiatives.committee_requests.revoke")
36
+ }
37
+ end
38
+ end
28
39
  end
29
40
 
30
41
  private
@@ -49,7 +49,7 @@ module Decidim
49
49
  @form = form(Decidim::Initiatives::Admin::InitiativeForm)
50
50
  .from_params(params, initiative: current_initiative)
51
51
 
52
- UpdateInitiative.call(current_initiative, @form, current_user) do
52
+ Decidim::Initiatives::Admin::UpdateInitiative.call(current_initiative, @form, current_user) do
53
53
  on(:ok) do |initiative|
54
54
  flash[:notice] = I18n.t("initiatives.update.success", scope: "decidim.initiatives.admin")
55
55
  redirect_to edit_initiative_path(initiative)
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ module Admin
6
+ module Moderations
7
+ # This controller allows admins to manage moderation reports in an conference.
8
+ class ReportsController < Decidim::Admin::Moderations::ReportsController
9
+ include InitiativeAdmin
10
+
11
+ def permissions_context
12
+ super.merge(current_participatory_space: current_participatory_space)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -40,6 +40,38 @@ module Decidim
40
40
  end
41
41
  end
42
42
  end
43
+
44
+ # GET /initiatives/:initiative_id/committee_requests/:id/approve
45
+ def approve
46
+ enforce_permission_to :approve, :initiative_committee_member, request: membership_request
47
+
48
+ ApproveMembershipRequest.call(membership_request) do
49
+ on(:ok) do
50
+ redirect_to edit_initiative_path(current_initiative), flash: {
51
+ notice: I18n.t("success", scope: "decidim.initiatives.committee_requests.approve")
52
+ }
53
+ end
54
+ end
55
+ end
56
+
57
+ # DELETE /initiatives/:initiative_id/committee_requests/:id/revoke
58
+ def revoke
59
+ enforce_permission_to :revoke, :initiative_committee_member, request: membership_request
60
+
61
+ RevokeMembershipRequest.call(membership_request) do
62
+ on(:ok) do
63
+ redirect_to edit_initiative_path(current_initiative), flash: {
64
+ notice: I18n.t("success", scope: "decidim.initiatives.committee_requests.revoke")
65
+ }
66
+ end
67
+ end
68
+ end
69
+
70
+ private
71
+
72
+ def membership_request
73
+ @membership_request ||= InitiativesCommitteeMember.find(params[:id])
74
+ end
43
75
  end
44
76
  end
45
77
  end
@@ -21,17 +21,18 @@ module Decidim
21
21
  include InitiativeSlug
22
22
  include FilterResource
23
23
  include Paginable
24
+ include Decidim::FormFactory
24
25
  include Decidim::Initiatives::Orderable
25
26
  include TypeSelectorOptions
26
27
  include NeedsInitiative
27
28
  include SingleInitiativeType
28
29
 
29
30
  helper_method :collection, :initiatives, :filter, :stats
31
+ helper_method :initiative_type
30
32
 
31
33
  # GET /initiatives
32
34
  def index
33
35
  enforce_permission_to :list, :initiative
34
-
35
36
  return unless search.results.blank? && params.dig("filter", "state") != %w(closed)
36
37
 
37
38
  @closed_initiatives = search_klass.new(search_params.merge(state: %w(closed)))
@@ -40,6 +41,7 @@ module Decidim
40
41
  params[:filter] ||= {}
41
42
  params[:filter][:date] = %w(closed)
42
43
  @forced_closed_initiatives = true
44
+
43
45
  @search = @closed_initiatives
44
46
  end
45
47
  end
@@ -49,6 +51,61 @@ module Decidim
49
51
  enforce_permission_to :read, :initiative, initiative: current_initiative
50
52
  end
51
53
 
54
+ # GET /initiatives/:id/send_to_technical_validation
55
+ def send_to_technical_validation
56
+ enforce_permission_to :send_to_technical_validation, :initiative, initiative: current_initiative
57
+
58
+ SendInitiativeToTechnicalValidation.call(current_initiative, current_user) do
59
+ on(:ok) do
60
+ redirect_to EngineRouter.main_proxy(current_initiative).initiatives_path(initiative_slug: nil), flash: {
61
+ notice: I18n.t(
62
+ "success",
63
+ scope: %w(decidim initiatives admin initiatives edit)
64
+ )
65
+ }
66
+ end
67
+ end
68
+ end
69
+
70
+ # GET /initiatives/:slug/edit
71
+ def edit
72
+ enforce_permission_to :edit, :initiative, initiative: current_initiative
73
+ form_attachment_model = form(AttachmentForm).from_model(current_initiative.attachments.first)
74
+ @form = form(Decidim::Initiatives::InitiativeForm)
75
+ .from_model(
76
+ current_initiative,
77
+ initiative: current_initiative
78
+ )
79
+ @form.attachment = form_attachment_model
80
+
81
+ render layout: "decidim/initiative"
82
+ end
83
+
84
+ # PUT /initiatives/:id
85
+ def update
86
+ enforce_permission_to :update, :initiative, initiative: current_initiative
87
+
88
+ params[:id] = params[:slug]
89
+ @form = form(Decidim::Initiatives::InitiativeForm)
90
+ .from_params(params, initiative_type: current_initiative.type, initiative: current_initiative)
91
+
92
+ UpdateInitiative.call(current_initiative, @form, current_user) do
93
+ on(:ok) do |initiative|
94
+ flash[:notice] = I18n.t("success", scope: "decidim.initiatives.update")
95
+ redirect_to initiative_path(initiative)
96
+ end
97
+
98
+ on(:invalid) do
99
+ flash.now[:alert] = I18n.t("error", scope: "decidim.initiatives.update")
100
+ render :edit, layout: "decidim/initiative"
101
+ end
102
+ end
103
+ end
104
+
105
+ def print
106
+ enforce_permission_to :read, :initiative, initiative: current_initiative
107
+ end
108
+
52
109
  private
53
110
 
54
111
  alias current_initiative current_participatory_space