decidim-meetings 0.28.2 → 0.29.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim-meetings might be problematic. Click here for more details.

Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/meetings/attending_organizations_list_cell.rb +1 -1
  3. data/app/cells/decidim/meetings/cancel_registration_meeting_button_cell.rb +1 -2
  4. data/app/cells/decidim/meetings/highlighted_meetings_for_component_cell.rb +1 -2
  5. data/app/cells/decidim/meetings/join_meeting_button/remaining_slots.erb +1 -0
  6. data/app/cells/decidim/meetings/join_meeting_button_cell.rb +0 -3
  7. data/app/cells/decidim/meetings/meeting_card_metadata_cell.rb +0 -3
  8. data/app/cells/decidim/meetings/meeting_cell.rb +0 -1
  9. data/app/cells/decidim/meetings/meeting_l_cell.rb +0 -2
  10. data/app/cells/decidim/meetings/meeting_url/show.erb +5 -5
  11. data/app/cells/decidim/meetings/meeting_url_cell.rb +0 -1
  12. data/app/cells/decidim/meetings/online_meeting_link_cell.rb +0 -2
  13. data/app/cells/decidim/meetings/question_responses/show.erb +7 -3
  14. data/app/cells/decidim/meetings/question_responses_cell.rb +0 -2
  15. data/app/commands/decidim/meetings/admin/copy_meeting.rb +2 -2
  16. data/app/commands/decidim/meetings/admin/create_agenda.rb +9 -37
  17. data/app/commands/decidim/meetings/admin/create_meeting.rb +28 -61
  18. data/app/commands/decidim/meetings/admin/destroy_meeting.rb +4 -33
  19. data/app/commands/decidim/meetings/admin/update_agenda.rb +7 -35
  20. data/app/commands/decidim/meetings/admin/update_meeting.rb +30 -68
  21. data/app/commands/decidim/meetings/admin/update_question_status.rb +1 -1
  22. data/app/commands/decidim/meetings/admin/update_questionnaire.rb +19 -11
  23. data/app/commands/decidim/meetings/admin/update_registrations.rb +20 -46
  24. data/app/commands/decidim/meetings/create_answer.rb +5 -4
  25. data/app/commands/decidim/meetings/create_meeting.rb +38 -62
  26. data/app/commands/decidim/meetings/join_meeting.rb +18 -19
  27. data/app/commands/decidim/meetings/update_meeting.rb +6 -7
  28. data/app/commands/decidim/meetings/withdraw_meeting.rb +1 -1
  29. data/app/controllers/concerns/decidim/meetings/admin/invites/filterable.rb +33 -0
  30. data/app/controllers/decidim/meetings/admin/agenda_controller.rb +1 -1
  31. data/app/controllers/decidim/meetings/admin/invites_controller.rb +6 -6
  32. data/app/controllers/decidim/meetings/admin/meetings_controller.rb +2 -2
  33. data/app/controllers/decidim/meetings/admin/meetings_poll_controller.rb +12 -0
  34. data/app/controllers/decidim/meetings/application_controller.rb +1 -1
  35. data/app/controllers/decidim/meetings/live_events_controller.rb +1 -1
  36. data/app/controllers/decidim/meetings/meetings_controller.rb +3 -33
  37. data/app/controllers/decidim/meetings/polls/answers_controller.rb +10 -2
  38. data/app/controllers/decidim/meetings/registrations_controller.rb +3 -3
  39. data/app/forms/decidim/meetings/admin/meeting_registrations_form.rb +1 -1
  40. data/app/forms/decidim/meetings/admin/question_form.rb +8 -4
  41. data/app/forms/decidim/meetings/answer_form.rb +4 -4
  42. data/app/forms/decidim/meetings/meeting_form.rb +1 -1
  43. data/app/mailers/decidim/meetings/close_meeting_reminder_mailer.rb +1 -1
  44. data/app/models/decidim/meetings/meeting.rb +10 -4
  45. data/app/models/decidim/meetings/poll.rb +8 -0
  46. data/app/models/decidim/meetings/question.rb +1 -0
  47. data/app/models/decidim/meetings/questionnaire.rb +0 -6
  48. data/app/packs/src/decidim/meetings/admin/meetings_form.js +3 -3
  49. data/app/packs/src/decidim/meetings/meetings_form.js +3 -3
  50. data/app/packs/src/decidim/meetings/meetings_polls.js +5 -0
  51. data/app/packs/src/decidim/meetings/poll.component.js +32 -4
  52. data/app/packs/stylesheets/decidim/meetings/_item.scss +109 -1
  53. data/app/packs/stylesheets/decidim/meetings/_live_event.scss +0 -94
  54. data/app/permissions/decidim/meetings/permissions.rb +20 -0
  55. data/app/services/decidim/meetings/calendar/component_calendar.rb +1 -1
  56. data/app/services/decidim/meetings/calendar/meeting_to_event.rb +1 -1
  57. data/app/services/decidim/meetings/close_meeting_reminder_generator.rb +1 -1
  58. data/app/services/decidim/meetings/meeting_iframe_embedder.rb +2 -2
  59. data/app/views/decidim/meetings/admin/agenda/_agenda_item.html.erb +3 -3
  60. data/app/views/decidim/meetings/admin/agenda/_agenda_item_child.html.erb +3 -3
  61. data/app/views/decidim/meetings/admin/agenda/_agenda_item_fields.html.erb +3 -3
  62. data/app/views/decidim/meetings/admin/invite_join_meeting_mailer/invite.html.erb +3 -1
  63. data/app/views/decidim/meetings/admin/invites/_form.html.erb +4 -4
  64. data/app/views/decidim/meetings/admin/invites/index.html.erb +4 -34
  65. data/app/views/decidim/meetings/admin/meetings/_form.html.erb +8 -8
  66. data/app/views/decidim/meetings/admin/meetings/_service.html.erb +3 -3
  67. data/app/views/decidim/meetings/admin/meetings/index.html.erb +2 -2
  68. data/app/views/decidim/meetings/admin/poll/_answer_option.html.erb +1 -1
  69. data/app/views/decidim/meetings/admin/poll/_answer_option_template.html.erb +1 -1
  70. data/app/views/decidim/meetings/admin/poll/_form.html.erb +26 -25
  71. data/app/views/decidim/meetings/admin/poll/_question.html.erb +18 -16
  72. data/app/views/decidim/meetings/admin/poll/edit.html.erb +4 -6
  73. data/app/views/decidim/meetings/admin/registrations/edit.html.erb +1 -1
  74. data/app/views/decidim/meetings/close_meeting_reminder_mailer/close_meeting_reminder.html.erb +1 -1
  75. data/app/views/decidim/meetings/layouts/live_event.html.erb +1 -15
  76. data/app/views/decidim/meetings/meetings/_datetime.html.erb +4 -4
  77. data/app/views/decidim/meetings/meetings/_form.html.erb +17 -17
  78. data/app/views/decidim/meetings/meetings/_meeting.html.erb +2 -1
  79. data/app/views/decidim/meetings/meetings/_meeting_agenda.html.erb +2 -2
  80. data/app/views/decidim/meetings/meetings/_meeting_aside.html.erb +3 -1
  81. data/app/views/decidim/meetings/meetings/_meeting_poll_actions.html.erb +15 -0
  82. data/app/views/decidim/meetings/polls/answers/_multiple_option.html.erb +6 -10
  83. data/app/views/decidim/meetings/polls/answers/_single_option.html.erb +4 -10
  84. data/app/views/decidim/meetings/polls/answers/admin.html.erb +34 -0
  85. data/app/views/decidim/meetings/polls/answers/index.html.erb +36 -0
  86. data/app/views/decidim/meetings/polls/questions/_closed_question.html.erb +8 -2
  87. data/app/views/decidim/meetings/polls/questions/_index_admin.html.erb +27 -24
  88. data/app/views/decidim/meetings/polls/questions/_published_question.html.erb +14 -11
  89. data/app/views/decidim/meetings/polls/questions/_question.html.erb +1 -1
  90. data/app/views/decidim/meetings/polls/questions/index.js.erb +3 -3
  91. data/app/views/decidim/meetings/polls/questions/index_admin.js.erb +3 -3
  92. data/app/views/devise/mailer/join_meeting.html.erb +3 -1
  93. data/app/views/devise/mailer/join_meeting.text.erb +3 -1
  94. data/config/locales/ar.yml +0 -10
  95. data/config/locales/bg.yml +44 -12
  96. data/config/locales/ca.yml +44 -12
  97. data/config/locales/cs.yml +24 -11
  98. data/config/locales/de.yml +44 -12
  99. data/config/locales/el.yml +0 -10
  100. data/config/locales/en.yml +44 -12
  101. data/config/locales/es-MX.yml +44 -12
  102. data/config/locales/es-PY.yml +44 -12
  103. data/config/locales/es.yml +44 -12
  104. data/config/locales/eu.yml +44 -12
  105. data/config/locales/fi-plain.yml +44 -12
  106. data/config/locales/fi.yml +44 -12
  107. data/config/locales/fr-CA.yml +44 -12
  108. data/config/locales/fr.yml +44 -12
  109. data/config/locales/ga-IE.yml +0 -5
  110. data/config/locales/gl.yml +0 -4
  111. data/config/locales/hu.yml +0 -7
  112. data/config/locales/id-ID.yml +0 -3
  113. data/config/locales/is-IS.yml +0 -3
  114. data/config/locales/it.yml +0 -8
  115. data/config/locales/ja.yml +44 -12
  116. data/config/locales/lb.yml +0 -3
  117. data/config/locales/lt.yml +0 -10
  118. data/config/locales/lv.yml +0 -3
  119. data/config/locales/nl.yml +0 -10
  120. data/config/locales/no.yml +0 -9
  121. data/config/locales/pl.yml +44 -12
  122. data/config/locales/pt-BR.yml +17 -12
  123. data/config/locales/pt.yml +0 -8
  124. data/config/locales/ro-RO.yml +0 -10
  125. data/config/locales/ru.yml +0 -3
  126. data/config/locales/sk.yml +0 -3
  127. data/config/locales/sv.yml +0 -9
  128. data/config/locales/tr-TR.yml +0 -4
  129. data/config/locales/uk.yml +0 -3
  130. data/config/locales/zh-CN.yml +0 -4
  131. data/config/locales/zh-TW.yml +0 -10
  132. data/db/migrate/20240130135858_add_withdrawn_fields_on_meetings.rb +23 -0
  133. data/decidim-meetings.gemspec +1 -1
  134. data/lib/decidim/api/meeting_type.rb +3 -0
  135. data/lib/decidim/meetings/component.rb +2 -2
  136. data/lib/decidim/meetings/engine.rb +5 -1
  137. data/lib/decidim/meetings/meeting_serializer.rb +3 -1
  138. data/lib/decidim/meetings/seeds.rb +25 -15
  139. data/lib/decidim/meetings/test/factories.rb +1 -1
  140. data/lib/decidim/meetings/test/notifications_handling.rb +1 -1
  141. data/lib/decidim/meetings/version.rb +1 -1
  142. data/lib/tasks/decidim_meetings.rake +1 -1
  143. metadata +22 -18
  144. data/app/views/decidim/meetings/admin/agenda/show.html.erb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b39a9cc837cdf7ceb50a11600d77bf52bc43b826f59904a547ded94bd4ff4748
4
- data.tar.gz: 87830a9f87a179d747f8fd14749abe9774f124778b5ba6bdc98591bc42f39c5f
3
+ metadata.gz: a07c1e309dc8767ecc6e3c9183fbdb6f10ef675ba02ad373d7dccb94d845232a
4
+ data.tar.gz: 2b161c273f6c5e2027eb43b64dda0bae2bb485c9315e46ac2d90390fac2ea81c
5
5
  SHA512:
6
- metadata.gz: f9376c59d4176d0df307fa963890ed3c35dd5bf3b4469087e6972348cdd08d78f2f705e820ee19cba564cc70566f6cc999e80cb65dd8fcbbd49cbdad405d283d
7
- data.tar.gz: 1bffbca3121562dcb32af901f743817e004ab5dff16ec2f5dba433910cfb130d87947db7fd4f2cef00c9f0825d0e57111cca66e41a7bbb3745c10124b6586b1f
6
+ metadata.gz: fb2448350839344f4a982b9de72c59631eb7abfdd1752d334e4712b28af5b01b5303af4a868723ab73c5701044e174c8721150394333c0a342420b5913011126
7
+ data.tar.gz: 6775dd6bef7fb50a450223202be2c72b497bd981bc5b45c8494df5b340cacfcab1fea88476a433442d0a9c643c78d9389df6fa4a25cab25f4a67d6f14f66036b
@@ -4,7 +4,7 @@ require "cell/partial"
4
4
 
5
5
  module Decidim
6
6
  module Meetings
7
- # This cell renders the list of public participanting
7
+ # This cell renders the list of public participating
8
8
  # organizations of a meeting.
9
9
  #
10
10
  # Example:
@@ -2,9 +2,8 @@
2
2
 
3
3
  module Decidim
4
4
  module Meetings
5
- # This cell renders the button to cancel a meeting registation.
5
+ # This cell renders the button to cancel a meeting registration.
6
6
  class CancelRegistrationMeetingButtonCell < Decidim::ViewModel
7
- include Decidim::IconHelper
8
7
  include MeetingCellsHelper
9
8
 
10
9
  def show
@@ -11,7 +11,6 @@ module Decidim
11
11
  include Decidim::Meetings::ApplicationHelper
12
12
  include Decidim::ComponentPathHelper
13
13
  include Decidim::CardHelper
14
- include Decidim::LayoutHelper
15
14
 
16
15
  delegate :snippets, to: :controller
17
16
 
@@ -31,7 +30,7 @@ module Decidim
31
30
 
32
31
  def base_relation
33
32
  @base_relation ||= Decidim::Meetings::Meeting.where(component: model)
34
- .except_withdrawn
33
+ .not_withdrawn
35
34
  .published
36
35
  .not_hidden
37
36
  .visible_for(current_user)
@@ -1,4 +1,5 @@
1
1
  <div class="meeting__aside-progress">
2
2
  <span><%= t("remaining_slots", scope: "decidim.meetings.meetings.show", count: model.remaining_slots) %></span>
3
3
  <progress value="<%= model.remaining_slots %>" max="<%= model.available_slots %>"></progress>
4
+ <span class="meeting__aside-progress-label"><%= model.remaining_slots %> / <%= model.available_slots %></span>
4
5
  </div>
@@ -5,9 +5,6 @@ module Decidim
5
5
  # This cell renders the button to join a meeting.
6
6
  class JoinMeetingButtonCell < Decidim::ViewModel
7
7
  include MeetingCellsHelper
8
- include Decidim::SanitizeHelper
9
- include ActionView::Helpers::FormTagHelper
10
- include ActionView::Helpers::FormOptionsHelper
11
8
 
12
9
  def show
13
10
  return unless model.can_be_joined_by?(current_user) || model.on_different_platform?
@@ -4,9 +4,6 @@ module Decidim
4
4
  module Meetings
5
5
  # This cell renders metadata for an instance of a Meeting
6
6
  class MeetingCardMetadataCell < Decidim::CardMetadataCell
7
- include Decidim::LayoutHelper
8
- include ActionView::Helpers::DateHelper
9
-
10
7
  alias meeting model
11
8
 
12
9
  delegate :type_of_meeting, :start_time, :end_time, :category, :withdrawn?, to: :meeting
@@ -6,7 +6,6 @@ module Decidim
6
6
  # the default size is the List Card (:l)
7
7
  # also available the List Item Card (:list_item)
8
8
  class MeetingCell < Decidim::ViewModel
9
- include Decidim::SanitizeHelper
10
9
  include MeetingCellsHelper
11
10
  include Cell::ViewModel::Partial
12
11
 
@@ -7,8 +7,6 @@ module Decidim
7
7
  # This cell renders the List (:l) meeting card
8
8
  # for an instance of a Meeting
9
9
  class MeetingLCell < Decidim::CardLCell
10
- delegate :component_settings, to: :controller
11
-
12
10
  alias meeting model
13
11
 
14
12
  def has_image?
@@ -1,11 +1,11 @@
1
- <div class="card__icondata">
2
- <ul class="card-data">
3
- <li class="card-data__item">
1
+ <div>
2
+ <ul>
3
+ <li>
4
4
  <%= resource_icon %>
5
5
  </li>
6
- <li class="card-data__item">
6
+ <li>
7
7
  <div class="text-left">
8
- <div class="card__icondata--address">
8
+ <div>
9
9
  <% if future? %>
10
10
  <span><%= t("link_available_soon", scope: "decidim.meetings.meetings.show") %></span>
11
11
  <% elsif live? %>
@@ -5,7 +5,6 @@ module Decidim
5
5
  # This cell renders the URL address of an online meeting.
6
6
  class MeetingUrlCell < Decidim::Meetings::OnlineMeetingCell
7
7
  include Cell::ViewModel::Partial
8
- include LayoutHelper
9
8
 
10
9
  private
11
10
 
@@ -5,8 +5,6 @@ module Decidim
5
5
  # This cell renders the online meeting link section
6
6
  # of a online or both type of meeting.
7
7
  class OnlineMeetingLinkCell < Decidim::Meetings::OnlineMeetingCell
8
- include Decidim::LayoutHelper
9
-
10
8
  def online_meeting_url?
11
9
  model.online_meeting_url.present?
12
10
  end
@@ -1,7 +1,11 @@
1
1
  <% answer_options_with_percentages.each do |(answer_option_body, answer_percentage)| %>
2
- <label><%= translated_attribute(answer_option_body) %></label>
3
2
  <div class="meeting-polls__answer">
4
- <div class="meeting-polls__answer--value"><%= answer_percentage %></div>
5
- <div class="meeting-polls__answer--bar"><div style="width: <%= answer_percentage %>"></div></div>
3
+ <div class="meeting-polls__answer--bar">
4
+ <div style="width: <%= answer_percentage %>"></div>
5
+ </div>
6
+ <div class="meeting-polls__answer--value">
7
+ <span><%= translated_attribute(answer_option_body) %></span>
8
+ <span><%= answer_percentage %></span>
9
+ </div>
6
10
  </div>
7
11
  <% end %>
@@ -5,8 +5,6 @@ module Decidim
5
5
  # This cell renders the percentage of responses which chose
6
6
  # the given answer option in a meeting poll question
7
7
  class QuestionResponsesCell < Decidim::ViewModel
8
- include ActionView::Helpers::NumberHelper
9
-
10
8
  def show
11
9
  render
12
10
  end
@@ -89,8 +89,8 @@ module Decidim
89
89
  form.services_to_persist.map do |service|
90
90
  Decidim::Meetings::Service.create!(
91
91
  meeting: copied_meeting,
92
- "title" => service.title,
93
- "description" => service.description
92
+ title: service.title,
93
+ description: service.description
94
94
  )
95
95
  end
96
96
  end
@@ -5,33 +5,15 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user creates a Meeting from the admin
7
7
  # panel.
8
- class CreateAgenda < Decidim::Command
9
- def initialize(form, meeting)
10
- @form = form
11
- @meeting = meeting
12
- @agenda = nil
13
- end
14
-
15
- # Creates the agenda if valid.
16
- #
17
- # Broadcasts :ok if successful, :invalid otherwise.
18
- def call
19
- return broadcast(:invalid) if @form.invalid?
20
-
21
- transaction do
22
- create_agenda!
23
- create_agenda_items
24
- end
8
+ class CreateAgenda < Decidim::Commands::CreateResource
9
+ fetch_form_attributes :title, :visible, :meeting
25
10
 
26
- broadcast(:ok, @agenda)
27
- end
28
-
29
- private
11
+ protected
30
12
 
31
- attr_reader :form, :meeting
13
+ def resource_class = Decidim::Meetings::Agenda
32
14
 
33
- def create_agenda_items
34
- @form.agenda_items.each do |form_agenda_item|
15
+ def run_after_hooks
16
+ form.agenda_items.each do |form_agenda_item|
35
17
  create_agenda_item(form_agenda_item)
36
18
  end
37
19
  end
@@ -43,10 +25,10 @@ module Decidim
43
25
  position: form_agenda_item.position,
44
26
  duration: form_agenda_item.duration,
45
27
  parent_id: form_agenda_item.parent_id,
46
- agenda: @agenda
28
+ agenda: resource
47
29
  }
48
30
 
49
- create_nested_model(form_agenda_item, agenda_item_attributes, @form.agenda_items) do |agenda_item|
31
+ create_nested_model(form_agenda_item, agenda_item_attributes, form.agenda_items) do |agenda_item|
50
32
  form_agenda_item.agenda_item_children.each do |form_agenda_item_child|
51
33
  agenda_item_child_attributes = {
52
34
  title: form_agenda_item_child.title,
@@ -54,7 +36,7 @@ module Decidim
54
36
  position: form_agenda_item_child.position,
55
37
  duration: form_agenda_item_child.duration,
56
38
  parent_id: agenda_item.id,
57
- agenda: @agenda
39
+ agenda: resource
58
40
  }
59
41
 
60
42
  create_nested_model(form_agenda_item_child, agenda_item_child_attributes, agenda_item.agenda_item_children)
@@ -77,16 +59,6 @@ module Decidim
77
59
  record.save!
78
60
  end
79
61
  end
80
-
81
- def create_agenda!
82
- @agenda = Decidim.traceability.create!(
83
- Agenda,
84
- @form.current_user,
85
- title: @form.title,
86
- visible: @form.visible,
87
- meeting: @meeting
88
- )
89
- end
90
62
  end
91
63
  end
92
64
  end
@@ -5,84 +5,51 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user creates a Meeting from the admin
7
7
  # panel.
8
- class CreateMeeting < Decidim::Command
9
- def initialize(form)
10
- @form = form
11
- end
12
-
13
- # Creates the meeting if valid.
14
- #
15
- # Broadcasts :ok if successful, :invalid otherwise.
16
- def call
17
- return broadcast(:invalid) if @form.invalid?
8
+ class CreateMeeting < Decidim::Commands::CreateResource
9
+ fetch_form_attributes :scope, :category, :end_time, :start_time, :online_meeting_url, :registration_type,
10
+ :registration_url, :address, :latitude, :longitude, :location, :location_hints,
11
+ :private_meeting, :transparent, :registrations_enabled, :component, :iframe_embed_type,
12
+ :comments_enabled, :comments_start_time, :comments_end_time, :iframe_access_level
18
13
 
19
- transaction do
20
- create_meeting!
21
- create_services!
22
- end
14
+ protected
23
15
 
16
+ def run_after_hooks
17
+ create_services!
24
18
  create_follow_form_resource(form.current_user)
25
- broadcast(:ok, meeting)
26
19
  end
27
20
 
28
- private
29
-
30
- attr_reader :form, :meeting
31
-
32
- def create_meeting!
21
+ def attributes
33
22
  parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
34
23
  parsed_description = Decidim::ContentProcessor.parse(form.description, current_organization: form.current_organization).rewrite
35
- params = {
36
- scope: form.scope,
37
- category: form.category,
38
- title: parsed_title,
39
- description: parsed_description,
40
- end_time: form.end_time,
41
- start_time: form.start_time,
42
- online_meeting_url: form.online_meeting_url,
43
- registration_type: form.registration_type,
44
- registration_url: form.registration_url,
45
- type_of_meeting: form.clean_type_of_meeting,
46
- address: form.address,
47
- latitude: form.latitude,
48
- longitude: form.longitude,
49
- location: form.location,
50
- location_hints: form.location_hints,
51
- private_meeting: form.private_meeting,
52
- transparent: form.transparent,
53
- author: form.current_organization,
54
- registration_terms: form.current_component.settings.default_registration_terms,
55
- registrations_enabled: form.registrations_enabled,
56
- component: form.current_component,
57
- questionnaire: Decidim::Forms::Questionnaire.new,
58
- iframe_embed_type: form.iframe_embed_type,
59
- comments_enabled: form.comments_enabled,
60
- comments_start_time: form.comments_start_time,
61
- comments_end_time: form.comments_end_time,
62
- iframe_access_level: form.iframe_access_level
63
- }
64
-
65
- @meeting = Decidim.traceability.create!(
66
- Meeting,
67
- form.current_user,
68
- params,
69
- visibility: "all"
70
- )
24
+ super.merge({
25
+ title: parsed_title,
26
+ description: parsed_description,
27
+ type_of_meeting: form.clean_type_of_meeting,
28
+ author: form.current_organization,
29
+ registration_terms: form.current_component.settings.default_registration_terms,
30
+ questionnaire: Decidim::Forms::Questionnaire.new
31
+ })
71
32
  end
72
33
 
34
+ def resource_class = Decidim::Meetings::Meeting
35
+
36
+ def extra_params = { visibility: "all" }
37
+
38
+ private
39
+
73
40
  def create_services!
74
41
  form.services_to_persist.each do |service|
75
42
  Decidim::Meetings::Service.create!(
76
- meeting:,
77
- "title" => service.title,
78
- "description" => service.description
43
+ meeting: resource,
44
+ title: service.title,
45
+ description: service.description
79
46
  )
80
47
  end
81
48
  end
82
49
 
83
50
  def create_follow_form_resource(user)
84
- follow_form = Decidim::FollowForm.from_params(followable_gid: meeting.to_signed_global_id.to_s).with_context(current_user: user)
85
- Decidim::CreateFollow.call(follow_form, user)
51
+ follow_form = Decidim::FollowForm.from_params(followable_gid: resource.to_signed_global_id.to_s).with_context(current_user: user)
52
+ Decidim::CreateFollow.call(follow_form)
86
53
  end
87
54
  end
88
55
  end
@@ -5,44 +5,15 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user destroys a Meeting from the admin
7
7
  # panel.
8
- class DestroyMeeting < Decidim::Command
9
- # Initializes a CloseMeeting Command.
10
- #
11
- # meeting - The current instance of the page to be closed.
12
- # current_user - the user performing the action
13
- def initialize(meeting, current_user)
14
- @meeting = meeting
15
- @current_user = current_user
16
- end
17
-
18
- # Destroys the meeting if valid.
19
- #
20
- # Broadcasts :ok if successful, :invalid otherwise.
21
- def call
22
- return broadcast(:invalid, proposals.size) if proposals.any?
23
-
24
- destroy_meeting
25
- broadcast(:ok)
26
- end
8
+ class DestroyMeeting < Decidim::Commands::DestroyResource
9
+ protected
27
10
 
28
- private
29
-
30
- attr_reader :current_user, :meeting
31
-
32
- def destroy_meeting
33
- Decidim.traceability.perform_action!(
34
- :delete,
35
- meeting,
36
- current_user
37
- ) do
38
- meeting.destroy!
39
- end
40
- end
11
+ def invalid? = proposals.any?
41
12
 
42
13
  def proposals
43
14
  return [] unless Decidim::Meetings.enable_proposal_linking
44
15
 
45
- @proposals ||= meeting.authored_proposals.load
16
+ @proposals ||= resource.authored_proposals.load
46
17
  end
47
18
  end
48
19
  end
@@ -3,33 +3,14 @@
3
3
  module Decidim
4
4
  module Meetings
5
5
  module Admin
6
- # This command is executed when the user creates a Meeting from the admin
6
+ # This command is executed when the user updates a Meeting from the admin
7
7
  # panel.
8
- class UpdateAgenda < Decidim::Command
9
- def initialize(form, agenda)
10
- @form = form
11
- @agenda = agenda
12
- end
13
-
14
- # Creates the agenda if valid.
15
- #
16
- # Broadcasts :ok if successful, :invalid otherwise.
17
- def call
18
- return broadcast(:invalid) if @form.invalid?
8
+ class UpdateAgenda < Decidim::Commands::UpdateResource
9
+ fetch_form_attributes :title, :visible
19
10
 
20
- transaction do
21
- update_agenda!
22
- update_agenda_items
23
- end
24
-
25
- broadcast(:ok, @agenda)
26
- end
11
+ protected
27
12
 
28
- private
29
-
30
- attr_reader :form
31
-
32
- def update_agenda_items
13
+ def run_after_hooks
33
14
  @form.agenda_items.each do |form_agenda_item|
34
15
  update_agenda_item(form_agenda_item)
35
16
  end
@@ -44,7 +25,7 @@ module Decidim
44
25
  parent_id: form_agenda_item.parent_id
45
26
  }
46
27
 
47
- update_nested_model(form_agenda_item, agenda_item_attributes, @agenda.agenda_items) do |agenda_item|
28
+ update_nested_model(form_agenda_item, agenda_item_attributes, resource.agenda_items) do |agenda_item|
48
29
  form_agenda_item.agenda_item_children.each do |form_agenda_item_child|
49
30
  agenda_item_child_attributes = {
50
31
  title: form_agenda_item_child.title,
@@ -52,7 +33,7 @@ module Decidim
52
33
  position: form_agenda_item_child.position,
53
34
  duration: form_agenda_item_child.duration,
54
35
  parent_id: agenda_item.id,
55
- agenda: @agenda
36
+ agenda: resource
56
37
  }
57
38
 
58
39
  update_nested_model(form_agenda_item_child, agenda_item_child_attributes, agenda_item.agenda_item_children)
@@ -75,15 +56,6 @@ module Decidim
75
56
  record.save!
76
57
  end
77
58
  end
78
-
79
- def update_agenda!
80
- Decidim.traceability.update!(
81
- @agenda,
82
- form.current_user,
83
- title: form.title,
84
- visible: form.visible
85
- )
86
- end
87
59
  end
88
60
  end
89
61
  end
@@ -5,87 +5,49 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user changes a Meeting from the admin
7
7
  # panel.
8
- class UpdateMeeting < Decidim::Command
9
- # Initializes a UpdateMeeting Command.
10
- #
11
- # form - The form from which to get the data.
12
- # meeting - The current instance of the page to be updated.
13
- def initialize(form, meeting)
14
- @form = form
15
- @meeting = meeting
8
+ class UpdateMeeting < Decidim::Commands::UpdateResource
9
+ fetch_form_attributes :scope, :category, :end_time, :start_time, :online_meeting_url, :registration_type,
10
+ :registration_url, :registrations_enabled, :address, :latitude, :longitude, :location,
11
+ :location_hints,
12
+ :private_meeting, :transparent, :iframe_embed_type, :comments_enabled,
13
+ :comments_start_time, :comments_end_time, :iframe_access_level
14
+
15
+ protected
16
+
17
+ def run_after_hooks
18
+ send_notification if should_notify_followers?
19
+ schedule_upcoming_meeting_notification if resource.published? && start_time_changed?
20
+ update_services!
16
21
  end
17
22
 
18
- # Updates the meeting if valid.
19
- #
20
- # Broadcasts :ok if successful, :invalid otherwise.
21
- def call
22
- return broadcast(:invalid) if form.invalid?
23
-
24
- transaction do
25
- update_meeting!
26
- send_notification if should_notify_followers?
27
- schedule_upcoming_meeting_notification if meeting.published? && start_time_changed?
28
- update_services!
29
- end
30
-
31
- broadcast(:ok, meeting)
32
- end
33
-
34
- private
35
-
36
- attr_reader :form, :meeting
37
-
38
- def update_meeting!
23
+ def attributes
39
24
  parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
40
25
  parsed_description = Decidim::ContentProcessor.parse(form.description, current_organization: form.current_organization).rewrite
41
-
42
- Decidim.traceability.update!(
43
- meeting,
44
- form.current_user,
45
- scope: form.scope,
46
- category: form.category,
47
- title: parsed_title,
48
- description: parsed_description,
49
- end_time: form.end_time,
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
- registrations_enabled: form.registrations_enabled,
55
- type_of_meeting: form.clean_type_of_meeting,
56
- address: form.address,
57
- latitude: form.latitude,
58
- longitude: form.longitude,
59
- location: form.location,
60
- location_hints: form.location_hints,
61
- private_meeting: form.private_meeting,
62
- transparent: form.transparent,
63
- iframe_embed_type: form.iframe_embed_type,
64
- comments_enabled: form.comments_enabled,
65
- comments_start_time: form.comments_start_time,
66
- comments_end_time: form.comments_end_time,
67
- iframe_access_level: form.iframe_access_level
68
- )
26
+ super.merge({
27
+ title: parsed_title,
28
+ description: parsed_description,
29
+ type_of_meeting: form.clean_type_of_meeting
30
+ })
69
31
  end
70
32
 
71
33
  def update_services!
72
- meeting.services = form.services_to_persist.map do |service|
73
- Decidim::Meetings::Service.new("title" => service.title, "description" => service.description)
34
+ resource.services = form.services_to_persist.map do |service|
35
+ Decidim::Meetings::Service.new(title: service.title, description: service.description)
74
36
  end
75
- meeting.save!
37
+ resource.save!
76
38
  end
77
39
 
78
40
  def send_notification
79
41
  Decidim::EventsManager.publish(
80
42
  event: "decidim.events.meetings.meeting_updated",
81
43
  event_class: Decidim::Meetings::UpdateMeetingEvent,
82
- resource: meeting,
83
- followers: meeting.followers
44
+ resource:,
45
+ followers: resource.followers
84
46
  )
85
47
  end
86
48
 
87
49
  def should_notify_followers?
88
- meeting.published? && important_attributes.any? { |attr| meeting.previous_changes[attr].present? }
50
+ resource.published? && important_attributes.any? { |attr| resource.previous_changes[attr].present? }
89
51
  end
90
52
 
91
53
  def important_attributes
@@ -93,17 +55,17 @@ module Decidim
93
55
  end
94
56
 
95
57
  def start_time_changed?
96
- meeting.previous_changes["start_time"].present?
58
+ resource.previous_changes["start_time"].present?
97
59
  end
98
60
 
99
61
  def schedule_upcoming_meeting_notification
100
- return if meeting.start_time < Time.zone.now
62
+ return if resource.start_time < Time.zone.now
101
63
 
102
- checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(meeting)
64
+ checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(resource)
103
65
 
104
66
  Decidim::Meetings::UpcomingMeetingNotificationJob
105
- .set(wait_until: meeting.start_time - Decidim::Meetings.upcoming_meeting_notification)
106
- .perform_later(meeting.id, checksum)
67
+ .set(wait_until: resource.start_time - Decidim::Meetings.upcoming_meeting_notification)
68
+ .perform_later(resource.id, checksum)
107
69
  end
108
70
  end
109
71
  end
@@ -10,8 +10,8 @@ module Decidim
10
10
 
11
11
  # Initializes a UpdateQuestionnaire Command.
12
12
  #
13
- # form - The form from which to get the data.
14
13
  # questionnaire - The current instance of the questionnaire to be updated.
14
+ # current_user - The current user.
15
15
  def initialize(question, current_user)
16
16
  @question = question
17
17
  @current_user = current_user