decidim-meetings 0.23.5 → 0.24.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/decidim_meetings_manifest.js +1 -0
  3. data/app/assets/javascripts/decidim/meetings/admin/meetings_form.js.es6 +47 -0
  4. data/app/assets/javascripts/decidim/meetings/meetings_form.js.es6 +45 -0
  5. data/app/cells/decidim/meetings/content_blocks/highlighted_meetings/elements.erb +16 -0
  6. data/app/cells/decidim/meetings/content_blocks/highlighted_meetings/heading.erb +1 -0
  7. data/app/cells/decidim/meetings/content_blocks/highlighted_meetings_cell.rb +27 -0
  8. data/app/cells/decidim/meetings/join_meeting_button/show.erb +7 -0
  9. data/app/cells/decidim/meetings/meeting_cell.rb +2 -4
  10. data/app/cells/decidim/meetings/meeting_highlighted_list_item/show.erb +21 -0
  11. data/app/cells/decidim/meetings/meeting_highlighted_list_item_cell.rb +10 -0
  12. data/app/cells/decidim/meetings/meeting_m/address.erb +5 -1
  13. data/app/cells/decidim/meetings/meeting_m_cell.rb +2 -0
  14. data/app/cells/decidim/meetings/meeting_url/show.erb +15 -0
  15. data/app/cells/decidim/meetings/meeting_url_cell.rb +17 -0
  16. data/app/cells/decidim/meetings/reported_content/show.erb +3 -0
  17. data/app/cells/decidim/meetings/reported_content_cell.rb +13 -0
  18. data/app/commands/decidim/meetings/admin/create_meeting.rb +5 -0
  19. data/app/commands/decidim/meetings/admin/invite_user_to_join_meeting.rb +1 -1
  20. data/app/commands/decidim/meetings/admin/update_meeting.rb +5 -0
  21. data/app/commands/decidim/meetings/admin/validate_registration_code.rb +2 -0
  22. data/app/commands/decidim/meetings/close_meeting.rb +66 -0
  23. data/app/commands/decidim/meetings/create_meeting.rb +7 -1
  24. data/app/commands/decidim/meetings/leave_meeting.rb +2 -2
  25. data/app/commands/decidim/meetings/update_meeting.rb +8 -1
  26. data/app/controllers/decidim/meetings/admin/application_controller.rb +1 -1
  27. data/app/controllers/decidim/meetings/admin/meeting_closes_controller.rb +2 -2
  28. data/app/controllers/decidim/meetings/directory/meetings_controller.rb +2 -2
  29. data/app/controllers/decidim/meetings/meeting_closes_controller.rb +43 -0
  30. data/app/controllers/decidim/meetings/meetings_controller.rb +9 -5
  31. data/app/forms/decidim/meetings/admin/close_meeting_form.rb +4 -4
  32. data/app/forms/decidim/meetings/admin/meeting_form.rb +62 -4
  33. data/app/forms/decidim/meetings/admin/meeting_registrations_form.rb +14 -4
  34. data/app/forms/decidim/meetings/close_meeting_form.rb +31 -0
  35. data/app/forms/decidim/meetings/meeting_form.rb +71 -3
  36. data/app/helpers/decidim/meetings/application_helper.rb +20 -0
  37. data/app/helpers/decidim/meetings/map_helper.rb +1 -1
  38. data/app/models/decidim/meetings/agenda_item.rb +1 -1
  39. data/app/models/decidim/meetings/meeting.rb +52 -1
  40. data/app/permissions/decidim/meetings/permissions.rb +12 -2
  41. data/app/presenters/decidim/meetings/meeting_presenter.rb +33 -0
  42. data/app/services/decidim/meetings/meeting_search.rb +20 -0
  43. data/app/views/decidim/meetings/admin/invite_join_meeting_mailer/invite.html.erb +1 -1
  44. data/app/views/decidim/meetings/admin/invites/index.html.erb +1 -1
  45. data/app/views/decidim/meetings/admin/meetings/_form.html.erb +31 -1
  46. data/app/views/decidim/meetings/admin/meetings/edit.html.erb +2 -2
  47. data/app/views/decidim/meetings/admin/meetings/index.html.erb +23 -1
  48. data/app/views/decidim/meetings/admin/meetings/new.html.erb +2 -2
  49. data/app/views/decidim/meetings/admin/minutes/edit.html.erb +1 -1
  50. data/app/views/decidim/meetings/admin/registrations/edit.html.erb +20 -18
  51. data/app/views/decidim/meetings/directory/meetings/index.html.erb +1 -0
  52. data/app/views/decidim/meetings/directory/meetings/index.js.erb +0 -3
  53. data/app/views/decidim/meetings/meeting_closes/_form.html.erb +7 -0
  54. data/app/views/decidim/meetings/meeting_closes/edit.html.erb +25 -0
  55. data/app/views/decidim/meetings/meeting_closes/proposals_picker.html.erb +1 -0
  56. data/app/views/decidim/meetings/meetings/_filters.html.erb +6 -0
  57. data/app/views/decidim/meetings/meetings/_filters_small_view.html.erb +1 -1
  58. data/app/views/decidim/meetings/meetings/_form.html.erb +36 -2
  59. data/app/views/decidim/meetings/meetings/_online_meeting_link.html.erb +11 -0
  60. data/app/views/decidim/meetings/meetings/edit.html.erb +1 -1
  61. data/app/views/decidim/meetings/meetings/index.js.erb +0 -3
  62. data/app/views/decidim/meetings/meetings/new.html.erb +1 -1
  63. data/app/views/decidim/meetings/meetings/show.html.erb +28 -21
  64. data/app/views/decidim/meetings/registration_mailer/confirmation.html.erb +3 -1
  65. data/app/views/decidim/participatory_spaces/_upcoming_meeting_for_card.html.erb +1 -1
  66. data/config/locales/ar.yml +0 -7
  67. data/config/locales/ca.yml +47 -9
  68. data/config/locales/cs.yml +49 -11
  69. data/config/locales/de.yml +45 -7
  70. data/config/locales/el.yml +0 -10
  71. data/config/locales/en.yml +47 -9
  72. data/config/locales/es-MX.yml +47 -9
  73. data/config/locales/es-PY.yml +47 -9
  74. data/config/locales/es.yml +47 -9
  75. data/config/locales/eu.yml +0 -7
  76. data/config/locales/fi-plain.yml +45 -7
  77. data/config/locales/fi.yml +47 -9
  78. data/config/locales/fr-CA.yml +47 -9
  79. data/config/locales/fr.yml +47 -9
  80. data/config/locales/gl.yml +0 -11
  81. data/config/locales/hu.yml +0 -10
  82. data/config/locales/id-ID.yml +0 -7
  83. data/config/locales/is-IS.yml +0 -6
  84. data/config/locales/it.yml +0 -9
  85. data/config/locales/ja.yml +0 -9
  86. data/config/locales/lv.yml +0 -10
  87. data/config/locales/nl.yml +43 -8
  88. data/config/locales/no.yml +11 -10
  89. data/config/locales/pl.yml +47 -9
  90. data/config/locales/pt-BR.yml +0 -7
  91. data/config/locales/pt.yml +0 -9
  92. data/config/locales/ro-RO.yml +47 -9
  93. data/config/locales/ru.yml +0 -7
  94. data/config/locales/sk.yml +0 -10
  95. data/config/locales/sl.yml +0 -4
  96. data/config/locales/sv.yml +32 -7
  97. data/config/locales/tr-TR.yml +44 -9
  98. data/config/locales/uk.yml +0 -6
  99. data/config/locales/zh-CN.yml +0 -9
  100. data/db/migrate/20180809134748_add_upcoming_events_as_content_block.rb +1 -1
  101. data/db/migrate/20201006140511_add_online_meeting_url.rb +7 -0
  102. data/db/migrate/20201009124057_add_type_of_meeting.rb +7 -0
  103. data/db/migrate/20201016112641_add_registration_type_and_url_to_meetings.rb +19 -0
  104. data/db/migrate/20210310120731_add_followable_counter_cache_to_meetings.rb +16 -0
  105. data/lib/decidim/api/agenda_item_type.rb +22 -0
  106. data/lib/decidim/api/agenda_type.rb +19 -0
  107. data/lib/decidim/api/linked_resources_interface.rb +7 -6
  108. data/lib/decidim/api/meeting_type.rb +63 -0
  109. data/lib/decidim/api/meetings_type.rb +26 -0
  110. data/lib/decidim/api/minutes_type.rb +20 -0
  111. data/{app/types/decidim/meetings → lib/decidim/api}/service_type.rb +4 -4
  112. data/lib/decidim/api/services_interface.rb +3 -3
  113. data/lib/decidim/meetings.rb +1 -1
  114. data/lib/decidim/meetings/api.rb +6 -0
  115. data/lib/decidim/meetings/component.rb +53 -23
  116. data/lib/decidim/meetings/engine.rb +3 -17
  117. data/lib/decidim/meetings/test/factories.rb +16 -3
  118. data/lib/decidim/meetings/version.rb +1 -1
  119. metadata +42 -38
  120. data/app/types/decidim/meetings/agenda_item_type.rb +0 -28
  121. data/app/types/decidim/meetings/agenda_type.rb +0 -25
  122. data/app/types/decidim/meetings/meeting_type.rb +0 -65
  123. data/app/types/decidim/meetings/meetings_type.rb +0 -32
  124. data/app/types/decidim/meetings/minutes_type.rb +0 -26
  125. data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_meetings.html.erb +0 -15
  126. data/app/views/decidim/participatory_processes/participatory_process_groups/_meeting.html.erb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 357917fbe3271ca8f314fb22e3a423d284a339fd605cc8760fcefcfc4c84c29e
4
- data.tar.gz: 627bfe46ab90b44789cae4fb3947130130ed49546be934445909fbb02d810901
3
+ metadata.gz: c36cff3bea211752e4d1bdfb5070643a7c919f706c221fcfe88a2a5e3e56b13b
4
+ data.tar.gz: 43365d712eb6554991ec5cb2e00be137aa5d0ac36598aa0aad5c655ce2c1d8e3
5
5
  SHA512:
6
- metadata.gz: c02f37fd6a135b4d8b18da3f7c3b313502a3fcfa1bc323666ce02ae2ab1923f357421c19ba3798b2df80eefcf985a93b0da52df49d184106d468a707efeb5957
7
- data.tar.gz: b4c202e74211e390f175f04a7ea36fea5ac6b2439f06d6b04a62cefa32014bcd7bf0c803679222ff58a3260d25afd0c14f1fa8e3e89e5949a5bd33aa13319ff1
6
+ metadata.gz: 3effb2caf62c99dd52d8bbb9bb5164b54e7c532fac968ecf1e9c0aa62cec93065681458dd54ebaccfec80fe332b2030ac4b073c9802ad0208c38f629237d4220
7
+ data.tar.gz: ac519d675189089a50af1af99ae09971a655a397862c46cf01c3a8cf83ae4d49d6219c380545559b39c3f4b0629e2179c74f1980866c1b355e76bd891917cc6b
@@ -3,6 +3,7 @@
3
3
  //= link decidim/meetings/admin/registrations_form.js
4
4
  //= link decidim/meetings/admin/registrations_invite_form.js
5
5
  //= link decidim/meetings/admin/meetings_form.js
6
+ //= link decidim/meetings/meetings_form.js
6
7
  //= link decidim/meetings/admin/agendas.js
7
8
  //= link decidim/meetings/admin/destroy_meeting_alert.js
8
9
  //= link_tree ../images/decidim
@@ -96,5 +96,52 @@
96
96
  toggleDisabledHiddenFields();
97
97
 
98
98
  attachGeocoding($form.find("#meeting_address"));
99
+
100
+ const $meetingRegistrationType = $form.find("#meeting_registration_type");
101
+ const $meetingRegistrationTerms = $form.find("#meeting_registration_terms");
102
+ const $meetingRegistrationUrl = $form.find("#meeting_registration_url");
103
+ const $meetingAvailableSlots = $form.find("#meeting_available_slots");
104
+
105
+ const toggleDependsOnSelect = ($target, $showDiv, type) => {
106
+ const value = $target.val();
107
+ $showDiv.toggle(value === type);
108
+ };
109
+
110
+ $meetingRegistrationType.on("change", (ev) => {
111
+ const $target = $(ev.target);
112
+ toggleDependsOnSelect($target, $meetingAvailableSlots, "on_this_platform");
113
+ toggleDependsOnSelect($target, $meetingRegistrationTerms, "on_this_platform");
114
+ toggleDependsOnSelect($target, $meetingRegistrationUrl, "on_different_platform");
115
+ });
116
+
117
+ $meetingRegistrationType.trigger("change");
118
+ }
119
+
120
+ const $meetingForm = $(".meetings_form");
121
+ if ($meetingForm.length > 0) {
122
+ const $meetingTypeOfMeeting = $meetingForm.find("#meeting_type_of_meeting");
123
+ const $meetingOnlineFields = $meetingForm.find(".field[data-meeting-type='online']");
124
+ const $meetingInPersonFields = $meetingForm.find(".field[data-meeting-type='in_person']");
125
+
126
+ const toggleDependsOnSelect = ($target, $showDiv, type) => {
127
+ const value = $target.val();
128
+ if (value === "hybrid") {
129
+ $showDiv.show();
130
+ } else {
131
+ $showDiv.hide();
132
+ if (value === type) {
133
+ $showDiv.show();
134
+ }
135
+ }
136
+ };
137
+
138
+ $meetingTypeOfMeeting.on("change", (ev) => {
139
+ const $target = $(ev.target);
140
+ toggleDependsOnSelect($target, $meetingOnlineFields, "online");
141
+ toggleDependsOnSelect($target, $meetingInPersonFields, "in_person");
142
+ });
143
+
144
+ toggleDependsOnSelect($meetingTypeOfMeeting, $meetingOnlineFields, "online");
145
+ toggleDependsOnSelect($meetingTypeOfMeeting, $meetingInPersonFields, "in_person");
99
146
  }
100
147
  })(window);
@@ -5,5 +5,50 @@
5
5
  $(() => {
6
6
  // Adds the latitude/longitude inputs after the geocoding is done
7
7
  attachGeocoding($("#meeting_address"));
8
+
9
+ const $form = $(".meetings_form");
10
+ if ($form.length > 0) {
11
+ const $meetingTypeOfMeeting = $form.find("#meeting_type_of_meeting");
12
+ const $meetingOnlineFields = $form.find(".field[data-meeting-type='online']");
13
+ const $meetingInPersonFields = $form.find(".field[data-meeting-type='in_person']");
14
+
15
+ const toggleDependsOnSelect = ($target, $showDiv, type) => {
16
+ const value = $target.val();
17
+ if (value === "hybrid") {
18
+ $showDiv.show();
19
+ } else {
20
+ $showDiv.hide();
21
+ if (value === type) {
22
+ $showDiv.show();
23
+ }
24
+ }
25
+ };
26
+
27
+ $meetingTypeOfMeeting.on("change", (ev) => {
28
+ const $target = $(ev.target);
29
+ toggleDependsOnSelect($target, $meetingOnlineFields, "online");
30
+ toggleDependsOnSelect($target, $meetingInPersonFields, "in_person");
31
+ });
32
+
33
+ toggleDependsOnSelect($meetingTypeOfMeeting, $meetingOnlineFields, "online");
34
+ toggleDependsOnSelect($meetingTypeOfMeeting, $meetingInPersonFields, "in_person");
35
+
36
+
37
+ const $meetingRegistrationType = $form.find("#meeting_registration_type");
38
+ const $meetingRegistrationTerms = $form.find("#meeting_registration_terms");
39
+ const $meetingRegistrationUrl = $form.find("#meeting_registration_url");
40
+ const $meetingAvailableSlots = $form.find("#meeting_available_slots");
41
+
42
+ $meetingRegistrationType.on("change", (ev) => {
43
+ const $target = $(ev.target);
44
+ toggleDependsOnSelect($target, $meetingAvailableSlots, "on_this_platform");
45
+ toggleDependsOnSelect($target, $meetingRegistrationTerms, "on_this_platform");
46
+ toggleDependsOnSelect($target, $meetingRegistrationUrl, "on_different_platform");
47
+ });
48
+
49
+ toggleDependsOnSelect($meetingRegistrationType, $meetingAvailableSlots, "on_this_platform");
50
+ toggleDependsOnSelect($meetingRegistrationType, $meetingRegistrationTerms, "on_this_platform");
51
+ toggleDependsOnSelect($meetingRegistrationType, $meetingRegistrationUrl, "on_different_platform");
52
+ }
8
53
  });
9
54
  })(window);
@@ -0,0 +1,16 @@
1
+ <div class="row">
2
+ <div class="column medium-6">
3
+ <% elements.first(4).each do |element| %>
4
+ <%= card_for element, size: :highlighted_list_item %>
5
+ <% end %>
6
+ </div>
7
+ <div class="columns medium-6">
8
+ <% if geolocation_enabled? %>
9
+ <%= cell "decidim/meetings/meetings_map", elements %>
10
+ <% else %>
11
+ <% elements.offset(4).first(4).each do |element| %>
12
+ <%= card_for element, size: :highlighted_list_item %>
13
+ <% end %>
14
+ <% end %>
15
+ </div>
16
+ </div>
@@ -0,0 +1 @@
1
+ <h2 class="section-heading"><%= t("decidim.meetings.content_blocks.upcoming_events.upcoming_events") %></h2>
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ module ContentBlocks
6
+ class HighlightedMeetingsCell < Decidim::ContentBlocks::HighlightedElementsCell
7
+ def base_relation
8
+ Decidim::Meetings::Meeting.where(component: published_components)
9
+ end
10
+
11
+ def elements
12
+ @elements ||= base_relation.order(start_time: :asc).limit(limit)
13
+ end
14
+
15
+ def geolocation_enabled?
16
+ Decidim::Map.available?(:geocoding)
17
+ end
18
+
19
+ private
20
+
21
+ def limit
22
+ geolocation_enabled? ? 4 : 8
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -35,4 +35,11 @@
35
35
  <% if shows_remaining_slots? %>
36
36
  <span><%= t("remaining_slots", scope: "decidim.meetings.meetings.show", count: model.remaining_slots) %></span>
37
37
  <% end %>
38
+ <% elsif model.on_different_platform? %>
39
+ <%= action_authorized_link_to(
40
+ :join,
41
+ i18n_join_text,
42
+ model.registration_url,
43
+ class: button_classes
44
+ ) %>
38
45
  <% end %>
@@ -18,6 +18,8 @@ module Decidim
18
18
 
19
19
  def card_size
20
20
  case @options[:size]
21
+ when :highlighted_list_item
22
+ "decidim/meetings/meeting_highlighted_list_item"
21
23
  when :list_item
22
24
  "decidim/meetings/meeting_list_item"
23
25
  when :s
@@ -27,10 +29,6 @@ module Decidim
27
29
  end
28
30
  end
29
31
 
30
- def title
31
- present(model).title
32
- end
33
-
34
32
  def resource_icon
35
33
  icon "meetings", remove_icon_class: true, width: 40, height: 70
36
34
  end
@@ -0,0 +1,21 @@
1
+ <article class="card">
2
+ <div class="card__content">
3
+ <div class="card__header">
4
+ <%= link_to meeting_path, class: "card__link" do %>
5
+ <h5 class="card__title">
6
+ <%= title %>
7
+ </h5>
8
+ <% end %>
9
+ </div>
10
+ <div class="row">
11
+ <time datetime="<%= l(model.start_time, format: :long_dashed) %>" class="column medium-4 text-muted">
12
+ <%= icon "datetime", class: "mr-xs", role: "img", "aria-hidden": true %>
13
+ <%= l start_date, format: :decidim_with_month_name %>
14
+ </time>
15
+ <div class="column medium-8 text-muted">
16
+ <%= participatory_space_class_name %>
17
+ <%= link_to participatory_space_title, participatory_space_path %>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </article>
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ # This cell renders the Highlighted List Item Card (:highlighted_list_item)
6
+ # meeting card for an instance of a Meeting. This card is used in the
7
+ # content block of Highlighted Meetings and is based on :s size card
8
+ class MeetingHighlightedListItemCell < MeetingSCell; end
9
+ end
10
+ end
@@ -1 +1,5 @@
1
- <%= cell "decidim/address", model %>
1
+ <% if online_meeting? %>
2
+ <%= cell "decidim/meetings/meeting_url", model %>
3
+ <% else %>
4
+ <%= cell "decidim/address", model %>
5
+ <% end %>
@@ -27,6 +27,8 @@ module Decidim
27
27
  present(model).title
28
28
  end
29
29
 
30
+ delegate :online_meeting?, to: :model
31
+
30
32
  private
31
33
 
32
34
  def spans_multiple_dates?
@@ -0,0 +1,15 @@
1
+ <div class="card__icondata">
2
+ <ul class="card-data">
3
+ <li class="card-data__item">
4
+ <%= resource_icon %>
5
+ </li>
6
+ <li class="card-data__item">
7
+ <div class="text-left">
8
+ <div class="card__icondata--address">
9
+ <span><%= link_to(model.online_meeting_url, model.online_meeting_url, target: "_blank") %></span><br>
10
+ <span><%= translated_attribute model.location_hints %></span>
11
+ </div>
12
+ </div>
13
+ </li>
14
+ </ul>
15
+ </div>
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ # This cell renders the URL address of an online meeting.
6
+ class MeetingUrlCell < Decidim::ViewModel
7
+ include Cell::ViewModel::Partial
8
+ include LayoutHelper
9
+
10
+ private
11
+
12
+ def resource_icon
13
+ icon "video", class: "icon--big", role: "img", "aria-hidden": true
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ <blockquote>
2
+ <%= render_value model.description %>
3
+ </blockquote>
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ # This cells renders a small preview of the `Meeting` that is
6
+ # used in the moderations panel.
7
+ class ReportedContentCell < Decidim::ReportedContentCell
8
+ def show
9
+ render :show
10
+ end
11
+ end
12
+ end
13
+ end
@@ -40,6 +40,11 @@ module Decidim
40
40
  description: parsed_description,
41
41
  end_time: form.end_time,
42
42
  start_time: form.start_time,
43
+ online_meeting_url: form.online_meeting_url,
44
+ registration_type: form.registration_type,
45
+ registration_url: form.registration_url,
46
+ available_slots: form.available_slots,
47
+ type_of_meeting: form.clean_type_of_meeting,
43
48
  address: form.address,
44
49
  latitude: form.latitude,
45
50
  longitude: form.longitude,
@@ -37,7 +37,7 @@ module Decidim
37
37
 
38
38
  def already_invited?
39
39
  return false unless user.persisted?
40
- return false unless meeting.invites.where(user: user).exists?
40
+ return false unless meeting.invites.exists?(user: user)
41
41
 
42
42
  form.errors.add(:email, :already_invited)
43
43
  true
@@ -48,6 +48,11 @@ module Decidim
48
48
  description: parsed_description,
49
49
  end_time: form.end_time,
50
50
  start_time: form.start_time,
51
+ online_meeting_url: form.online_meeting_url,
52
+ registration_type: form.registration_type,
53
+ registration_url: form.registration_url,
54
+ available_slots: form.available_slots,
55
+ type_of_meeting: form.clean_type_of_meeting,
51
56
  address: form.address,
52
57
  latitude: form.latitude,
53
58
  longitude: form.longitude,
@@ -35,6 +35,8 @@ module Decidim
35
35
  end
36
36
 
37
37
  def send_notification
38
+ return unless meeting.component.settings.registration_code_enabled
39
+
38
40
  Decidim::EventsManager.publish(
39
41
  event: "decidim.events.meetings.registration_code_validated",
40
42
  event_class: Decidim::Meetings::RegistrationCodeValidatedEvent,
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ # This command is executed when the user closes a Meeting from the public
6
+ # views.
7
+ class CloseMeeting < Rectify::Command
8
+ # Initializes a CloseMeeting Command.
9
+ #
10
+ # form - The form from which to get the data.
11
+ # meeting - The current instance of the page to be closed.
12
+ def initialize(form, meeting)
13
+ @form = form
14
+ @meeting = meeting
15
+ end
16
+
17
+ # Closes the meeting if valid.
18
+ #
19
+ # Broadcasts :ok if successful, :invalid otherwise.
20
+ def call
21
+ return broadcast(:invalid) if form.invalid?
22
+
23
+ transaction do
24
+ close_meeting
25
+ link_proposals
26
+ end
27
+
28
+ broadcast(:ok)
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :form, :meeting
34
+
35
+ def close_meeting
36
+ parsed_closing_report = Decidim::ContentProcessor.parse(form.closing_report, current_organization: form.current_organization).rewrite
37
+
38
+ Decidim.traceability.perform_action!(
39
+ :close,
40
+ meeting,
41
+ form.current_user
42
+ ) do
43
+ meeting.update!(
44
+ closed_at: form.closed_at,
45
+ closing_report: { I18n.locale => parsed_closing_report }
46
+ )
47
+ end
48
+
49
+ Decidim::EventsManager.publish(
50
+ event: "decidim.events.meetings.meeting_closed",
51
+ event_class: Decidim::Meetings::CloseMeetingEvent,
52
+ resource: meeting,
53
+ followers: meeting.followers
54
+ )
55
+ end
56
+
57
+ def proposals
58
+ meeting.sibling_scope(:proposals).where(id: @form.proposal_ids)
59
+ end
60
+
61
+ def link_proposals
62
+ meeting.link_resources(proposals, "proposals_from_meeting")
63
+ end
64
+ end
65
+ end
66
+ end
@@ -45,7 +45,13 @@ module Decidim
45
45
  location_hints: { I18n.locale => form.location_hints },
46
46
  author: form.current_user,
47
47
  decidim_user_group_id: form.user_group_id,
48
- registration_terms: form.current_component.settings.default_registration_terms,
48
+ online_meeting_url: form.online_meeting_url,
49
+ registration_type: form.registration_type,
50
+ registration_url: form.registration_url,
51
+ available_slots: form.available_slots,
52
+ registration_terms: { I18n.locale => form.registration_terms },
53
+ registrations_enabled: form.registrations_enabled,
54
+ type_of_meeting: form.clean_type_of_meeting,
49
55
  component: form.current_component
50
56
  }
51
57