decidim-meetings 0.22.0 → 0.23.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) 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 +3 -0
  4. data/app/assets/javascripts/decidim/meetings/meetings_form.js.es6 +9 -0
  5. data/app/cells/decidim/meetings/content_blocks/upcoming_events_cell.rb +2 -1
  6. data/app/cells/decidim/meetings/highlighted_meetings_for_component_cell.rb +1 -1
  7. data/app/cells/decidim/meetings/meeting_cell.rb +1 -1
  8. data/app/cells/decidim/meetings/meeting_list_item_cell.rb +2 -2
  9. data/app/cells/decidim/meetings/meeting_m_cell.rb +9 -1
  10. data/app/cells/decidim/meetings/meetings_map/show.erb +0 -2
  11. data/app/cells/decidim/meetings/meetings_map_cell.rb +3 -1
  12. data/app/commands/decidim/meetings/admin/close_meeting.rb +1 -2
  13. data/app/commands/decidim/meetings/admin/copy_meeting.rb +38 -28
  14. data/app/commands/decidim/meetings/admin/create_meeting.rb +36 -24
  15. data/app/commands/decidim/meetings/admin/invite_user_to_join_meeting.rb +2 -1
  16. data/app/commands/decidim/meetings/admin/update_meeting.rb +9 -3
  17. data/app/commands/decidim/meetings/create_meeting.rb +78 -0
  18. data/app/commands/decidim/meetings/update_meeting.rb +94 -0
  19. data/app/controllers/decidim/meetings/admin/application_controller.rb +1 -1
  20. data/app/controllers/decidim/meetings/admin/meetings_controller.rb +11 -7
  21. data/app/controllers/decidim/meetings/admin/registration_form_controller.rb +4 -0
  22. data/app/controllers/decidim/meetings/meetings_controller.rb +76 -13
  23. data/app/controllers/decidim/meetings/registrations_controller.rb +1 -1
  24. data/app/controllers/decidim/meetings/versions_controller.rb +14 -0
  25. data/app/controllers/decidim/meetings/{meeting_widgets_controller.rb → widgets_controller.rb} +2 -2
  26. data/app/forms/decidim/meetings/admin/meeting_copy_form.rb +2 -8
  27. data/app/forms/decidim/meetings/admin/meeting_form.rb +24 -23
  28. data/app/forms/decidim/meetings/meeting_form.rb +78 -0
  29. data/app/helpers/decidim/meetings/admin/application_helper.rb +1 -6
  30. data/app/helpers/decidim/meetings/application_helper.rb +25 -0
  31. data/app/helpers/decidim/meetings/meetings_helper.rb +12 -0
  32. data/app/models/decidim/meetings/agenda.rb +3 -0
  33. data/app/models/decidim/meetings/agenda_item.rb +3 -0
  34. data/app/models/decidim/meetings/meeting.rb +69 -23
  35. data/app/models/decidim/meetings/minutes.rb +3 -0
  36. data/app/models/decidim/meetings/service.rb +13 -0
  37. data/app/permissions/decidim/meetings/admin/permissions.rb +2 -0
  38. data/app/permissions/decidim/meetings/permissions.rb +20 -0
  39. data/app/presenters/decidim/meetings/admin_log/invite_presenter.rb +5 -1
  40. data/app/presenters/decidim/meetings/admin_log/meeting_presenter.rb +3 -4
  41. data/app/presenters/decidim/meetings/meeting_presenter.rb +7 -3
  42. data/app/presenters/decidim/meetings/official_author_presenter.rb +14 -0
  43. data/app/queries/decidim/meetings/filtered_meetings.rb +1 -1
  44. data/app/services/decidim/meetings/diff_renderer.rb +21 -0
  45. data/app/services/decidim/meetings/meeting_search.rb +3 -25
  46. data/app/types/decidim/meetings/meeting_type.rb +1 -1
  47. data/app/views/decidim/meetings/admin/meeting_copies/_form.html.erb +2 -9
  48. data/app/views/decidim/meetings/admin/meetings/_form.html.erb +4 -11
  49. data/app/views/decidim/meetings/admin/meetings/edit.html.erb +1 -1
  50. data/app/views/decidim/meetings/admin/meetings/index.html.erb +4 -2
  51. data/app/views/decidim/meetings/directory/meetings/index.js.erb +11 -4
  52. data/app/views/decidim/meetings/meetings/_count.html.erb +1 -0
  53. data/app/views/decidim/meetings/meetings/_filters.html.erb +8 -10
  54. data/app/views/decidim/meetings/meetings/_form.html.erb +51 -0
  55. data/app/views/decidim/meetings/meetings/edit.html.erb +25 -0
  56. data/app/views/decidim/meetings/meetings/index.html.erb +15 -0
  57. data/app/views/decidim/meetings/meetings/index.js.erb +13 -4
  58. data/app/views/decidim/meetings/meetings/new.html.erb +25 -0
  59. data/app/views/decidim/meetings/meetings/show.html.erb +24 -9
  60. data/app/views/decidim/meetings/versions/index.html.erb +8 -0
  61. data/app/views/decidim/meetings/versions/show.html.erb +10 -0
  62. data/config/locales/am-ET.yml +1 -0
  63. data/config/locales/ar.yml +0 -8
  64. data/config/locales/bg-BG.yml +0 -8
  65. data/config/locales/bg.yml +21 -0
  66. data/config/locales/ca.yml +49 -7
  67. data/config/locales/cs.yml +57 -13
  68. data/config/locales/da.yml +1 -0
  69. data/config/locales/de.yml +113 -71
  70. data/config/locales/el.yml +2 -7
  71. data/config/locales/en.yml +49 -7
  72. data/config/locales/eo.yml +1 -0
  73. data/config/locales/es-MX.yml +49 -7
  74. data/config/locales/es-PY.yml +50 -8
  75. data/config/locales/es.yml +50 -8
  76. data/config/locales/et.yml +1 -0
  77. data/config/locales/eu.yml +0 -8
  78. data/config/locales/fi-plain.yml +49 -7
  79. data/config/locales/fi.yml +168 -126
  80. data/config/locales/fr-CA.yml +57 -7
  81. data/config/locales/fr.yml +57 -7
  82. data/config/locales/gl.yml +3 -7
  83. data/config/locales/hr.yml +1 -0
  84. data/config/locales/hu.yml +2 -7
  85. data/config/locales/id-ID.yml +0 -8
  86. data/config/locales/is-IS.yml +0 -7
  87. data/config/locales/is.yml +228 -0
  88. data/config/locales/it.yml +47 -7
  89. data/config/locales/ja-JP.yml +48 -9
  90. data/config/locales/ja.yml +496 -0
  91. data/config/locales/ko-KR.yml +1 -0
  92. data/config/locales/ko.yml +1 -0
  93. data/config/locales/lt.yml +1 -0
  94. data/config/locales/{lv-LV.yml → lv.yml} +2 -2
  95. data/config/locales/mt.yml +1 -0
  96. data/config/locales/nl.yml +49 -7
  97. data/config/locales/no.yml +34 -8
  98. data/config/locales/om-ET.yml +1 -0
  99. data/config/locales/pl.yml +193 -149
  100. data/config/locales/pt-BR.yml +1 -9
  101. data/config/locales/pt.yml +47 -7
  102. data/config/locales/ro-RO.yml +48 -7
  103. data/config/locales/ru.yml +0 -8
  104. data/config/locales/si-LK.yml +1 -0
  105. data/config/locales/sk.yml +2 -7
  106. data/config/locales/sl.yml +25 -2
  107. data/config/locales/so-SO.yml +1 -0
  108. data/config/locales/sv.yml +56 -8
  109. data/config/locales/sw-KE.yml +1 -0
  110. data/config/locales/ti-ER.yml +1 -0
  111. data/config/locales/tr-TR.yml +154 -98
  112. data/config/locales/uk.yml +0 -7
  113. data/config/locales/vi-VN.yml +1 -0
  114. data/config/locales/vi.yml +1 -0
  115. data/config/locales/zh-CN.yml +496 -0
  116. data/config/locales/zh-TW.yml +1 -0
  117. data/db/migrate/20200526110940_add_author_to_meetings.rb +30 -0
  118. data/db/migrate/20200702123209_create_meeting_services_table.rb +13 -0
  119. data/db/migrate/20200702123210_move_meeting_services_to_own_model.rb +31 -0
  120. data/db/migrate/20200827153856_add_commentable_counter_cache_to_meetings.rb +9 -0
  121. data/db/migrate/20201016065302_fix_meetings_registration_terms.rb +29 -0
  122. data/db/migrate/20201111133246_add_salt_to_decidim_meetings.rb +8 -0
  123. data/lib/decidim/api/services_interface.rb +1 -7
  124. data/lib/decidim/meetings/admin_engine.rb +2 -0
  125. data/lib/decidim/meetings/component.rb +63 -11
  126. data/lib/decidim/meetings/engine.rb +3 -2
  127. data/lib/decidim/meetings/meeting_serializer.rb +1 -1
  128. data/lib/decidim/meetings/test/factories.rb +45 -8
  129. data/lib/decidim/meetings/version.rb +1 -1
  130. metadata +62 -22
  131. data/app/presenters/decidim/meetings/admin_log/value_types/organizer_presenter.rb +0 -70
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cf71231fe2e852a9101945044108cb1b3ae06a9ae7b952db3b0e895fed6e96e
4
- data.tar.gz: b191dbff11d2168da9e8535992f2005a3fbb55021a4e36df40948adca6c9b946
3
+ metadata.gz: 22df53220678ed19fc0fcdaace75d4eeeb176359964ee0e33a05272bac17d585
4
+ data.tar.gz: e8632ee7f75734cdae00df1f082e6ac2ac3f851213ca86f70fb08c638e21a2a3
5
5
  SHA512:
6
- metadata.gz: dfa66b38d9f02d3f9e71be17d6920deee816100e572a73e80f2c42a722f1de28cf8041cacc434c533b0bde954eebc4da9594f979d220e0801d3d7ccccb06eb52
7
- data.tar.gz: 6907691fd0d7f9c626acbbcb81bcb561967d82ba23967d50b6589950acaf4a749a8ba658fd432b9a25c6b928aab01615baa1471b80565fce8a8c1ffe554a528c
6
+ metadata.gz: be2f3d7da0855204ea210b3bf3c22a3b9b350b0ad3bb43a16d334d114c0cd226bdffa26f61797a26c89644caed05b8b006c4bb0ed2809ce68ad89b3ca44a1924
7
+ data.tar.gz: bebecedc4b34d8730f2c2963e3dc697e4ddb78d8c93207c04fd82833c1f1fe780207ede45a0d36a2cf6e31338b02e42d6d1d696c2c6cff512b3be8b8bb00f55f
@@ -1,3 +1,4 @@
1
+ //= link decidim/meetings/meetings_form.js
1
2
  //= link decidim/meetings/admin/meetings_form.js
2
3
  //= link decidim/meetings/admin/registrations_form.js
3
4
  //= link decidim/meetings/admin/registrations_invite_form.js
@@ -1,5 +1,6 @@
1
1
  ((exports) => {
2
2
  const { AutoLabelByPositionComponent, AutoButtonsByPositionComponent, createDynamicFields, createSortList } = exports.DecidimAdmin;
3
+ const { attachGeocoding } = window.Decidim;
3
4
 
4
5
  const wrapperSelector = ".meeting-services";
5
6
  const fieldSelector = ".meeting-service";
@@ -93,5 +94,7 @@
93
94
 
94
95
  $privateMeeting.on("change", toggleDisabledHiddenFields);
95
96
  toggleDisabledHiddenFields();
97
+
98
+ attachGeocoding($form.find("#meeting_address"));
96
99
  }
97
100
  })(window);
@@ -0,0 +1,9 @@
1
+ ((exports) => {
2
+ const $ = exports.$; // eslint-disable-line
3
+ const { attachGeocoding } = exports.Decidim;
4
+
5
+ $(() => {
6
+ // Adds the latitude/longitude inputs after the geocoding is done
7
+ attachGeocoding($("#meeting_address"));
8
+ });
9
+ })(window);
@@ -16,13 +16,14 @@ module Decidim
16
16
  @upcoming_events ||= Decidim::Meetings::Meeting
17
17
  .includes(component: :participatory_space)
18
18
  .where(component: meeting_components)
19
+ .visible_meeting_for(current_user)
19
20
  .where("end_time >= ?", Time.current)
20
21
  .order(start_time: :asc)
21
22
  .limit(limit)
22
23
  end
23
24
 
24
25
  def geolocation_enabled?
25
- Decidim.geocoder.present?
26
+ Decidim::Map.available?(:geocoding)
26
27
  end
27
28
 
28
29
  def meetings_directory_path
@@ -18,7 +18,7 @@ module Decidim
18
18
  private
19
19
 
20
20
  def meetings
21
- @meetings ||= Decidim::Meetings::Meeting.where(component: model)
21
+ @meetings ||= Decidim::Meetings::Meeting.where(component: model).visible_meeting_for(current_user)
22
22
  end
23
23
 
24
24
  def past_meetings
@@ -28,7 +28,7 @@ module Decidim
28
28
  end
29
29
 
30
30
  def title
31
- decidim_html_escape(present(model).title)
31
+ present(model).title
32
32
  end
33
33
 
34
34
  def resource_icon
@@ -14,11 +14,11 @@ module Decidim
14
14
  private
15
15
 
16
16
  def resource_path
17
- resource_locator(model).path
17
+ resource_locator(model).path(filter_link_params)
18
18
  end
19
19
 
20
20
  def title
21
- decidim_html_escape(present(model).title)
21
+ present(model).title
22
22
  end
23
23
 
24
24
  def resource_date_time
@@ -7,6 +7,14 @@ module Decidim
7
7
  class MeetingMCell < Decidim::CardMCell
8
8
  include MeetingCellsHelper
9
9
 
10
+ def has_authors?
11
+ true
12
+ end
13
+
14
+ def render_authorship
15
+ cell "decidim/author", author_presenter_for(model.normalized_author)
16
+ end
17
+
10
18
  def date
11
19
  render
12
20
  end
@@ -16,7 +24,7 @@ module Decidim
16
24
  end
17
25
 
18
26
  def title
19
- decidim_html_escape(present(model).title)
27
+ present(model).title
20
28
  end
21
29
 
22
30
  private
@@ -28,6 +28,4 @@
28
28
  </div>
29
29
  </div>
30
30
  </template>
31
- <%= stylesheet_link_tag "decidim/map" %>
32
- <%= javascript_include_tag "decidim/map" %>
33
31
  <% end.html_safe %>
@@ -6,8 +6,10 @@ module Decidim
6
6
  include Decidim::MapHelper
7
7
  include Decidim::Meetings::MapHelper
8
8
 
9
+ delegate :snippets, to: :controller
10
+
9
11
  def show
10
- return if Decidim.geocoder.blank?
12
+ return unless Decidim::Map.available?(:geocoding, :dynamic)
11
13
 
12
14
  render
13
15
  end
@@ -52,8 +52,7 @@ module Decidim
52
52
  event: "decidim.events.meetings.meeting_closed",
53
53
  event_class: Decidim::Meetings::CloseMeetingEvent,
54
54
  resource: meeting,
55
- affected_users: [meeting.organizer],
56
- followers: meeting.followers - [meeting.organizer]
55
+ followers: meeting.followers
57
56
  )
58
57
  end
59
58
 
@@ -26,61 +26,71 @@ module Decidim
26
26
 
27
27
  transaction do
28
28
  copy_meeting!
29
+ copy_services!
29
30
  schedule_upcoming_meeting_notification
30
31
  send_notification
31
32
  end
32
33
 
33
- broadcast(:ok, @copied_meeting)
34
+ broadcast(:ok, copied_meeting)
34
35
  end
35
36
 
36
37
  private
37
38
 
38
- attr_reader :form, :meeting
39
+ attr_reader :form, :meeting, :copied_meeting
39
40
 
40
41
  def copy_meeting!
41
- parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, @form.title, current_organization: @meeting.organization).rewrite
42
- parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, @form.description, current_organization: @meeting.organization).rewrite
42
+ parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: meeting.organization).rewrite
43
+ parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: meeting.organization).rewrite
43
44
 
44
45
  @copied_meeting = Decidim.traceability.create!(
45
46
  Meeting,
46
- @form.current_user,
47
- scope: @meeting.scope,
48
- category: @meeting.category,
47
+ form.current_user,
48
+ scope: meeting.scope,
49
+ category: meeting.category,
49
50
  title: parsed_title,
50
51
  description: parsed_description,
51
- end_time: @form.end_time,
52
- start_time: @form.start_time,
53
- address: @form.address,
54
- latitude: @form.latitude,
55
- longitude: @form.longitude,
56
- location: @form.location,
57
- location_hints: @form.location_hints,
58
- services: @form.services_to_persist.map { |service| { "title" => service.title, "description" => service.description } },
59
- component: @meeting.component,
60
- private_meeting: @form.private_meeting,
61
- transparent: @form.transparent,
62
- organizer: @form.organizer,
63
- questionnaire: @form.questionnaire,
64
- registrations_enabled: @meeting.registrations_enabled,
65
- available_slots: @meeting.available_slots,
66
- registration_terms: @meeting.registration_terms
52
+ end_time: form.end_time,
53
+ start_time: form.start_time,
54
+ address: form.address,
55
+ latitude: form.latitude,
56
+ longitude: form.longitude,
57
+ location: form.location,
58
+ location_hints: form.location_hints,
59
+ component: meeting.component,
60
+ private_meeting: form.private_meeting,
61
+ transparent: form.transparent,
62
+ author: form.current_organization,
63
+ questionnaire: form.questionnaire,
64
+ registrations_enabled: meeting.registrations_enabled,
65
+ available_slots: meeting.available_slots,
66
+ registration_terms: meeting.registration_terms
67
67
  )
68
68
  end
69
69
 
70
+ def copy_services!
71
+ form.services_to_persist.map do |service|
72
+ Decidim::Meetings::Service.create!(
73
+ meeting: copied_meeting,
74
+ "title" => service.title,
75
+ "description" => service.description
76
+ )
77
+ end
78
+ end
79
+
70
80
  def schedule_upcoming_meeting_notification
71
- checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(@copied_meeting)
81
+ checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(copied_meeting)
72
82
 
73
83
  Decidim::Meetings::UpcomingMeetingNotificationJob
74
- .set(wait_until: @copied_meeting.start_time - 2.days)
75
- .perform_later(@copied_meeting.id, checksum)
84
+ .set(wait_until: copied_meeting.start_time - 2.days)
85
+ .perform_later(copied_meeting.id, checksum)
76
86
  end
77
87
 
78
88
  def send_notification
79
89
  Decidim::EventsManager.publish(
80
90
  event: "decidim.events.meetings.meeting_created",
81
91
  event_class: Decidim::Meetings::CreateMeetingEvent,
82
- resource: @copied_meeting,
83
- followers: @copied_meeting.participatory_space.followers
92
+ resource: copied_meeting,
93
+ followers: copied_meeting.participatory_space.followers
84
94
  )
85
95
  end
86
96
  end
@@ -18,61 +18,73 @@ module Decidim
18
18
 
19
19
  transaction do
20
20
  create_meeting!
21
+ create_services!
21
22
  schedule_upcoming_meeting_notification
22
23
  send_notification
23
24
  end
24
25
 
25
- broadcast(:ok, @meeting)
26
+ broadcast(:ok, meeting)
26
27
  end
27
28
 
28
29
  private
29
30
 
31
+ attr_reader :form, :meeting
32
+
30
33
  def create_meeting!
31
- parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, @form.title, current_organization: @form.current_organization).rewrite
32
- parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, @form.description, current_organization: @form.current_organization).rewrite
34
+ parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
35
+ parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite
33
36
  params = {
34
- scope: @form.scope,
35
- category: @form.category,
37
+ scope: form.scope,
38
+ category: form.category,
36
39
  title: parsed_title,
37
40
  description: parsed_description,
38
- services: @form.services_to_persist.map { |service| { "title" => service.title, "description" => service.description } },
39
- end_time: @form.end_time,
40
- start_time: @form.start_time,
41
- address: @form.address,
42
- latitude: @form.latitude,
43
- longitude: @form.longitude,
44
- location: @form.location,
45
- location_hints: @form.location_hints,
46
- private_meeting: @form.private_meeting,
47
- transparent: @form.transparent,
48
- organizer: @form.organizer,
49
- registration_terms: @form.current_component.settings.default_registration_terms,
50
- component: @form.current_component,
41
+ end_time: form.end_time,
42
+ start_time: form.start_time,
43
+ address: form.address,
44
+ latitude: form.latitude,
45
+ longitude: form.longitude,
46
+ location: form.location,
47
+ location_hints: form.location_hints,
48
+ private_meeting: form.private_meeting,
49
+ transparent: form.transparent,
50
+ author: form.current_organization,
51
+ registration_terms: form.current_component.settings.default_registration_terms,
52
+ component: form.current_component,
51
53
  questionnaire: Decidim::Forms::Questionnaire.new
52
54
  }
53
55
 
54
56
  @meeting = Decidim.traceability.create!(
55
57
  Meeting,
56
- @form.current_user,
58
+ form.current_user,
57
59
  params,
58
60
  visibility: "all"
59
61
  )
60
62
  end
61
63
 
64
+ def create_services!
65
+ form.services_to_persist.each do |service|
66
+ Decidim::Meetings::Service.create!(
67
+ meeting: meeting,
68
+ "title" => service.title,
69
+ "description" => service.description
70
+ )
71
+ end
72
+ end
73
+
62
74
  def schedule_upcoming_meeting_notification
63
- checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(@meeting)
75
+ checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(meeting)
64
76
 
65
77
  Decidim::Meetings::UpcomingMeetingNotificationJob
66
- .set(wait_until: @meeting.start_time - 2.days)
67
- .perform_later(@meeting.id, checksum)
78
+ .set(wait_until: meeting.start_time - 2.days)
79
+ .perform_later(meeting.id, checksum)
68
80
  end
69
81
 
70
82
  def send_notification
71
83
  Decidim::EventsManager.publish(
72
84
  event: "decidim.events.meetings.meeting_created",
73
85
  event_class: Decidim::Meetings::CreateMeetingEvent,
74
- resource: @meeting,
75
- followers: @meeting.participatory_space.followers
86
+ resource: meeting,
87
+ followers: meeting.participatory_space.followers
76
88
  )
77
89
  end
78
90
  end
@@ -50,7 +50,8 @@ module Decidim
50
50
  },
51
51
  participatory_space: {
52
52
  title: meeting.participatory_space.title
53
- }
53
+ },
54
+ attendee_name: user.name
54
55
  }
55
56
 
56
57
  @invite = Decidim.traceability.create!(
@@ -25,6 +25,7 @@ module Decidim
25
25
  update_meeting!
26
26
  send_notification if should_notify_followers?
27
27
  schedule_upcoming_meeting_notification if start_time_changed?
28
+ update_services!
28
29
  end
29
30
 
30
31
  broadcast(:ok, meeting)
@@ -45,7 +46,6 @@ module Decidim
45
46
  category: form.category,
46
47
  title: parsed_title,
47
48
  description: parsed_description,
48
- services: form.services_to_persist.map { |service| { "title" => service.title, "description" => service.description } },
49
49
  end_time: form.end_time,
50
50
  start_time: form.start_time,
51
51
  address: form.address,
@@ -54,11 +54,17 @@ module Decidim
54
54
  location: form.location,
55
55
  location_hints: form.location_hints,
56
56
  private_meeting: form.private_meeting,
57
- transparent: form.transparent,
58
- organizer: form.organizer
57
+ transparent: form.transparent
59
58
  )
60
59
  end
61
60
 
61
+ def update_services!
62
+ meeting.services = form.services_to_persist.map do |service|
63
+ Decidim::Meetings::Service.new("title" => service.title, "description" => service.description)
64
+ end
65
+ meeting.save!
66
+ end
67
+
62
68
  def send_notification
63
69
  Decidim::EventsManager.publish(
64
70
  event: "decidim.events.meetings.meeting_updated",
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ # This command is executed when a participant or user group creates a Meeting from the public
6
+ # views.
7
+ class CreateMeeting < Rectify::Command
8
+ def initialize(form)
9
+ @form = form
10
+ end
11
+
12
+ # Creates the meeting if valid.
13
+ #
14
+ # Broadcasts :ok if successful, :invalid otherwise.
15
+ def call
16
+ return broadcast(:invalid) if form.invalid?
17
+
18
+ transaction do
19
+ create_meeting!
20
+ schedule_upcoming_meeting_notification
21
+ send_notification
22
+ end
23
+
24
+ broadcast(:ok, meeting)
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :meeting, :form
30
+
31
+ def create_meeting!
32
+ parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
33
+ parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite
34
+ params = {
35
+ scope: form.scope,
36
+ category: form.category,
37
+ title: { I18n.locale => parsed_title },
38
+ description: { I18n.locale => parsed_description },
39
+ end_time: form.end_time,
40
+ start_time: form.start_time,
41
+ address: form.address,
42
+ latitude: form.latitude,
43
+ longitude: form.longitude,
44
+ location: { I18n.locale => form.location },
45
+ location_hints: { I18n.locale => form.location_hints },
46
+ author: form.current_user,
47
+ decidim_user_group_id: form.user_group_id,
48
+ registration_terms: form.current_component.settings.default_registration_terms,
49
+ component: form.current_component
50
+ }
51
+
52
+ @meeting = Decidim.traceability.create!(
53
+ Meeting,
54
+ form.current_user,
55
+ params,
56
+ visibility: "public-only"
57
+ )
58
+ end
59
+
60
+ def schedule_upcoming_meeting_notification
61
+ checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(meeting)
62
+
63
+ Decidim::Meetings::UpcomingMeetingNotificationJob
64
+ .set(wait_until: meeting.start_time - 2.days)
65
+ .perform_later(meeting.id, checksum)
66
+ end
67
+
68
+ def send_notification
69
+ Decidim::EventsManager.publish(
70
+ event: "decidim.events.meetings.meeting_created",
71
+ event_class: Decidim::Meetings::CreateMeetingEvent,
72
+ resource: meeting,
73
+ followers: meeting.participatory_space.followers
74
+ )
75
+ end
76
+ end
77
+ end
78
+ end