decidim-meetings 0.26.2 → 0.27.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/meetings/content_blocks/highlighted_meetings_cell.rb +1 -1
  3. data/app/cells/decidim/meetings/content_blocks/upcoming_meetings/show.erb +1 -1
  4. data/app/cells/decidim/meetings/content_blocks/upcoming_meetings_cell.rb +2 -2
  5. data/app/cells/decidim/meetings/highlighted_meetings_for_component_cell.rb +10 -1
  6. data/app/commands/decidim/meetings/admin/close_meeting.rb +1 -1
  7. data/app/commands/decidim/meetings/admin/copy_meeting.rb +1 -1
  8. data/app/commands/decidim/meetings/admin/create_agenda.rb +1 -1
  9. data/app/commands/decidim/meetings/admin/create_meeting.rb +1 -4
  10. data/app/commands/decidim/meetings/admin/destroy_meeting.rb +1 -1
  11. data/app/commands/decidim/meetings/admin/export_meeting_registrations.rb +1 -1
  12. data/app/commands/decidim/meetings/admin/invite_user_to_join_meeting.rb +9 -11
  13. data/app/commands/decidim/meetings/admin/publish_meeting.rb +1 -1
  14. data/app/commands/decidim/meetings/admin/unpublish_meeting.rb +1 -1
  15. data/app/commands/decidim/meetings/admin/update_agenda.rb +1 -1
  16. data/app/commands/decidim/meetings/admin/update_meeting.rb +1 -4
  17. data/app/commands/decidim/meetings/admin/update_question_status.rb +1 -1
  18. data/app/commands/decidim/meetings/admin/update_questionnaire.rb +10 -7
  19. data/app/commands/decidim/meetings/admin/update_registrations.rb +5 -3
  20. data/app/commands/decidim/meetings/admin/validate_registration_code.rb +1 -1
  21. data/app/commands/decidim/meetings/close_meeting.rb +1 -1
  22. data/app/commands/decidim/meetings/create_answer.rb +1 -1
  23. data/app/commands/decidim/meetings/create_meeting.rb +1 -1
  24. data/app/commands/decidim/meetings/decline_invitation.rb +1 -1
  25. data/app/commands/decidim/meetings/join_meeting.rb +15 -7
  26. data/app/commands/decidim/meetings/leave_meeting.rb +3 -3
  27. data/app/commands/decidim/meetings/update_meeting.rb +1 -1
  28. data/app/commands/decidim/meetings/withdraw_meeting.rb +1 -1
  29. data/app/controllers/concerns/decidim/meetings/admin/filterable.rb +4 -4
  30. data/app/controllers/concerns/decidim/meetings/filterable.rb +1 -7
  31. data/app/controllers/decidim/meetings/calendars_controller.rb +1 -1
  32. data/app/controllers/decidim/meetings/directory/meetings_controller.rb +18 -15
  33. data/app/controllers/decidim/meetings/meetings_controller.rb +22 -14
  34. data/app/events/decidim/meetings/meeting_registration_notification_event.rb +1 -1
  35. data/app/forms/decidim/meetings/admin/close_meeting_form.rb +1 -1
  36. data/app/forms/decidim/meetings/admin/meeting_form.rb +2 -5
  37. data/app/forms/decidim/meetings/admin/meeting_registration_invite_form.rb +1 -1
  38. data/app/forms/decidim/meetings/admin/meeting_registrations_form.rb +3 -0
  39. data/app/forms/decidim/meetings/answer_form.rb +0 -1
  40. data/app/forms/decidim/meetings/close_meeting_form.rb +1 -1
  41. data/app/forms/decidim/meetings/meeting_form.rb +2 -2
  42. data/app/helpers/decidim/meetings/application_helper.rb +6 -8
  43. data/app/helpers/decidim/meetings/directory/application_helper.rb +6 -8
  44. data/app/helpers/decidim/meetings/meetings_helper.rb +1 -3
  45. data/app/jobs/decidim/meetings/send_close_meeting_reminder_job.rb +17 -0
  46. data/app/mailers/decidim/meetings/close_meeting_reminder_mailer.rb +43 -0
  47. data/app/models/decidim/meetings/agenda_item.rb +1 -1
  48. data/app/models/decidim/meetings/answer.rb +2 -2
  49. data/app/models/decidim/meetings/invite.rb +2 -2
  50. data/app/models/decidim/meetings/meeting.rb +39 -18
  51. data/app/models/decidim/meetings/questionnaire.rb +6 -0
  52. data/app/models/decidim/meetings/registration.rb +2 -2
  53. data/app/packs/src/decidim/meetings/admin/meetings_form.js +0 -4
  54. data/app/packs/src/decidim/meetings/admin/registrations_form.js +2 -0
  55. data/app/presenters/decidim/meetings/admin_log/questionnaire_presenter.rb +39 -0
  56. data/app/queries/decidim/meetings/admin/invites.rb +1 -1
  57. data/app/queries/decidim/meetings/filtered_meetings.rb +1 -1
  58. data/app/queries/decidim/meetings/questionnaire_user_answers.rb +1 -1
  59. data/app/serializers/decidim/meetings/{data_portability_invite_serializer.rb → download_your_data_invite_serializer.rb} +2 -2
  60. data/app/serializers/decidim/meetings/{data_portability_registration_serializer.rb → download_your_data_registration_serializer.rb} +2 -2
  61. data/app/services/decidim/meetings/calendar/base_calendar.rb +4 -3
  62. data/app/services/decidim/meetings/calendar/component_calendar.rb +7 -9
  63. data/app/services/decidim/meetings/calendar/organization_calendar.rb +1 -1
  64. data/app/services/decidim/meetings/calendar_renderer.rb +4 -4
  65. data/app/services/decidim/meetings/close_meeting_reminder_generator.rb +68 -0
  66. data/app/services/decidim/meetings/meeting_iframe_embedder.rb +16 -12
  67. data/app/services/decidim/meetings/meeting_search.rb +7 -53
  68. data/app/views/decidim/meetings/_calendar_modal.html.erb +19 -2
  69. data/app/views/decidim/meetings/admin/meetings/_form.html.erb +4 -16
  70. data/app/views/decidim/meetings/admin/registrations/_form.html.erb +9 -0
  71. data/app/views/decidim/meetings/close_meeting_reminder_mailer/close_meeting_reminder.html.erb +5 -0
  72. data/app/views/decidim/meetings/directory/meetings/_filters.html.erb +7 -7
  73. data/app/views/decidim/meetings/directory/meetings/_meetings.html.erb +6 -1
  74. data/app/views/decidim/meetings/directory/meetings/index.html.erb +1 -1
  75. data/app/views/decidim/meetings/directory/meetings/index.js.erb +7 -1
  76. data/app/views/decidim/meetings/layouts/live_event.html.erb +6 -2
  77. data/app/views/decidim/meetings/meetings/_count.html.erb +1 -1
  78. data/app/views/decidim/meetings/meetings/_filters.html.erb +7 -7
  79. data/app/views/decidim/meetings/meetings/_form.html.erb +4 -2
  80. data/app/views/decidim/meetings/meetings/_meetings.html.erb +11 -6
  81. data/app/views/decidim/meetings/meetings/index.html.erb +2 -2
  82. data/app/views/decidim/meetings/meetings/index.js.erb +7 -1
  83. data/config/locales/ar.yml +4 -7
  84. data/config/locales/bg.yml +1 -0
  85. data/config/locales/ca.yml +24 -10
  86. data/config/locales/cs.yml +25 -11
  87. data/config/locales/de.yml +73 -10
  88. data/config/locales/el.yml +1 -0
  89. data/config/locales/en.yml +23 -10
  90. data/config/locales/es-MX.yml +25 -11
  91. data/config/locales/es-PY.yml +25 -11
  92. data/config/locales/es.yml +25 -11
  93. data/config/locales/eu.yml +10 -11
  94. data/config/locales/fi-plain.yml +24 -10
  95. data/config/locales/fi.yml +24 -10
  96. data/config/locales/fr-CA.yml +24 -10
  97. data/config/locales/fr.yml +24 -10
  98. data/config/locales/ga-IE.yml +1 -9
  99. data/config/locales/gl.yml +14 -2
  100. data/config/locales/hu.yml +166 -7
  101. data/config/locales/id-ID.yml +1 -0
  102. data/config/locales/is-IS.yml +2 -1
  103. data/config/locales/it.yml +7 -11
  104. data/config/locales/ja.yml +26 -12
  105. data/config/locales/lb.yml +6 -6
  106. data/config/locales/lt.yml +688 -0
  107. data/config/locales/lv.yml +1 -0
  108. data/config/locales/nl.yml +106 -57
  109. data/config/locales/no.yml +7 -12
  110. data/config/locales/pl.yml +3 -11
  111. data/config/locales/pt-BR.yml +2 -12
  112. data/config/locales/pt.yml +6 -11
  113. data/config/locales/ro-RO.yml +8 -8
  114. data/config/locales/ru.yml +1 -0
  115. data/config/locales/sk.yml +1 -0
  116. data/config/locales/sl.yml +1 -0
  117. data/config/locales/sr-CS.yml +1 -0
  118. data/config/locales/sv.yml +15 -11
  119. data/config/locales/tr-TR.yml +1 -11
  120. data/config/locales/uk.yml +1 -0
  121. data/config/locales/zh-CN.yml +1 -7
  122. data/db/migrate/20210512100333_drop_decidim_meetings_minutes_table.rb +2 -2
  123. data/db/migrate/20210518133236_merge_minutes_with_closing_report_in_meetings_table.rb +1 -1
  124. data/db/migrate/20211105115625_remove_not_null_on_customize_registration_email.rb +7 -0
  125. data/lib/decidim/api/meeting_type.rb +1 -1
  126. data/lib/decidim/meetings/component.rb +7 -7
  127. data/lib/decidim/meetings/{data_portability_user_answers_serializer.rb → download_your_data_user_answers_serializer.rb} +2 -2
  128. data/lib/decidim/meetings/engine.rb +14 -0
  129. data/lib/decidim/meetings/test/factories.rb +3 -1
  130. data/lib/decidim/meetings/test/notifications_handling.rb +1 -1
  131. data/lib/decidim/meetings/test/translated_event.rb +2 -2
  132. data/lib/decidim/meetings/version.rb +1 -1
  133. data/lib/decidim/meetings.rb +5 -1
  134. metadata +27 -22
  135. data/app/services/decidim/meetings/directory/meeting_search.rb +0 -53
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26691ea95f69bf432c5fa438182b8ce6a20c897f15821a66dc92670ae76ec0eb
4
- data.tar.gz: 6d5fd46688388abc4c87fbd8869c8bcf4fcf725974f4d1cc27ccea86ecf452a0
3
+ metadata.gz: 27a158b5c9a9dec97373dfc3ec0d72e08921ea0d9e1403416cf686a008fe392e
4
+ data.tar.gz: 94090d3db90607fd599dc45bc61825ee1561cd20b2242143b2b0098d73740138
5
5
  SHA512:
6
- metadata.gz: cb185e7bc69a84b2b5582a8ec5cb0f1619c7687a6c7f7b2c2a6db1a52aff31f1448bef465f14d5be0525f8a145278b21014ceeba0052a528815e0054c75ea837
7
- data.tar.gz: 503ab4fda399ac1a43233b8d55afdff838b4b44f1e25d0d9416975c0f5e11c37379000e4a4d7e30a5c1118e984aed584154be8b9cfdad1bb2190eff21c54ef7b
6
+ metadata.gz: fca8eabda9f4e26bf77f4021a9f4ab74de63da59118b76d997089f8a87ec84e81f678f69b89be07e354724165ca2a19b1015d943b87e21de2328580a5672bb72
7
+ data.tar.gz: 15c6907d0cad955e13c2dc93a540bdb6eb5707b7617aa3d5c5671a369c6133c99f4719248e71cc6b35b1ed24c1417dace9c424111ed666ce605a2e237ed858a4
@@ -10,7 +10,7 @@ module Decidim
10
10
  .published
11
11
  .not_hidden
12
12
  .upcoming
13
- .visible_meeting_for(current_user)
13
+ .visible_for(current_user)
14
14
  .where(component: published_components)
15
15
  end
16
16
 
@@ -1,4 +1,4 @@
1
- <section class="wrapper-home upcoming-meetings home-section">
1
+ <section id="upcoming_meetings" class="wrapper-home upcoming-meetings home-section">
2
2
  <div class="row">
3
3
  <h3 class="section-heading"><%= t("decidim.meetings.content_blocks.upcoming_meetings.upcoming_meetings") %></h3>
4
4
  <div class="row">
@@ -14,9 +14,9 @@ module Decidim
14
14
 
15
15
  def upcoming_meetings
16
16
  @upcoming_meetings ||= Decidim::Meetings::Meeting
17
- .includes(component: :participatory_space)
17
+ .includes(:author, component: :participatory_space)
18
18
  .where(component: meeting_components)
19
- .visible_meeting_for(current_user)
19
+ .visible_for(current_user)
20
20
  .published
21
21
  .where("end_time >= ?", Time.current)
22
22
  .except_withdrawn
@@ -22,7 +22,7 @@ module Decidim
22
22
  .except_withdrawn
23
23
  .published
24
24
  .not_hidden
25
- .visible_meeting_for(current_user)
25
+ .visible_for(current_user)
26
26
  end
27
27
 
28
28
  def past_meetings
@@ -44,6 +44,15 @@ module Decidim
44
44
  def upcoming_meetings_count
45
45
  @upcoming_meetings_count ||= meetings.upcoming.count
46
46
  end
47
+
48
+ def cache_hash
49
+ hash = []
50
+ hash << "decidim/meetings/highlighted_meetings_for_component"
51
+ hash << meetings.cache_key_with_version
52
+ hash.push(current_user.try(:id))
53
+ hash << I18n.locale.to_s
54
+ hash.join(Decidim.cache_key_separator)
55
+ end
47
56
  end
48
57
  end
49
58
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user closes a Meeting from the admin
7
7
  # panel.
8
- class CloseMeeting < Rectify::Command
8
+ class CloseMeeting < Decidim::Command
9
9
  # Initializes a CloseMeeting Command.
10
10
  #
11
11
  # form - The form from which to get the data.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when copying a meeting
7
7
  # in the system.
8
- class CopyMeeting < Rectify::Command
8
+ class CopyMeeting < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -5,7 +5,7 @@ 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 < Rectify::Command
8
+ class CreateAgenda < Decidim::Command
9
9
  def initialize(form, meeting)
10
10
  @form = form
11
11
  @meeting = meeting
@@ -5,7 +5,7 @@ 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 < Rectify::Command
8
+ class CreateMeeting < Decidim::Command
9
9
  def initialize(form)
10
10
  @form = form
11
11
  end
@@ -42,7 +42,6 @@ module Decidim
42
42
  online_meeting_url: form.online_meeting_url,
43
43
  registration_type: form.registration_type,
44
44
  registration_url: form.registration_url,
45
- available_slots: form.available_slots,
46
45
  type_of_meeting: form.clean_type_of_meeting,
47
46
  address: form.address,
48
47
  latitude: form.latitude,
@@ -55,8 +54,6 @@ module Decidim
55
54
  registration_terms: form.current_component.settings.default_registration_terms,
56
55
  component: form.current_component,
57
56
  questionnaire: Decidim::Forms::Questionnaire.new,
58
- customize_registration_email: form.customize_registration_email,
59
- registration_email_custom_content: form.registration_email_custom_content,
60
57
  iframe_embed_type: form.iframe_embed_type,
61
58
  comments_enabled: form.comments_enabled,
62
59
  comments_start_time: form.comments_start_time,
@@ -5,7 +5,7 @@ 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 < Rectify::Command
8
+ class DestroyMeeting < Decidim::Command
9
9
  # Initializes a CloseMeeting Command.
10
10
  #
11
11
  # meeting - The current instance of the page to be closed.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user exports the registrations of
7
7
  # a Meeting from the admin panel.
8
- class ExportMeetingRegistrations < Rectify::Command
8
+ class ExportMeetingRegistrations < Decidim::Command
9
9
  # meeting - The current instance of the page to be closed.
10
10
  # format - a string representing the export format
11
11
  # current_user - the user performing the action
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic to invite users to join a meeting.
7
7
  #
8
- class InviteUserToJoinMeeting < Rectify::Command
8
+ class InviteUserToJoinMeeting < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -86,16 +86,14 @@ module Decidim
86
86
  end
87
87
 
88
88
  def user
89
- @user ||= begin
90
- if form.existing_user
91
- form.user
92
- else
93
- Decidim::User.find_or_initialize_by(
94
- organization: form.current_organization,
95
- email: form.email.downcase
96
- )
97
- end
98
- end
89
+ @user ||= if form.existing_user
90
+ form.user
91
+ else
92
+ Decidim::User.find_or_initialize_by(
93
+ organization: form.current_organization,
94
+ email: form.email.downcase
95
+ )
96
+ end
99
97
  end
100
98
 
101
99
  def invite_user_to_sign_up
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic that publishes an
7
7
  # existing meeting.
8
- class PublishMeeting < Rectify::Command
8
+ class PublishMeeting < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # meeting - Decidim::Meetings::Meeting
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic that unpublishes an
7
7
  # existing meeting.
8
- class UnpublishMeeting < Rectify::Command
8
+ class UnpublishMeeting < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # meeting - Decidim::Meetings::Meeting
@@ -5,7 +5,7 @@ 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 UpdateAgenda < Rectify::Command
8
+ class UpdateAgenda < Decidim::Command
9
9
  def initialize(form, agenda)
10
10
  @form = form
11
11
  @agenda = agenda
@@ -5,7 +5,7 @@ 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 < Rectify::Command
8
+ class UpdateMeeting < Decidim::Command
9
9
  # Initializes a UpdateMeeting Command.
10
10
  #
11
11
  # form - The form from which to get the data.
@@ -51,7 +51,6 @@ module Decidim
51
51
  online_meeting_url: form.online_meeting_url,
52
52
  registration_type: form.registration_type,
53
53
  registration_url: form.registration_url,
54
- available_slots: form.available_slots,
55
54
  type_of_meeting: form.clean_type_of_meeting,
56
55
  address: form.address,
57
56
  latitude: form.latitude,
@@ -60,8 +59,6 @@ module Decidim
60
59
  location_hints: form.location_hints,
61
60
  private_meeting: form.private_meeting,
62
61
  transparent: form.transparent,
63
- customize_registration_email: form.customize_registration_email,
64
- registration_email_custom_content: form.registration_email_custom_content,
65
62
  iframe_embed_type: form.iframe_embed_type,
66
63
  comments_enabled: form.comments_enabled,
67
64
  comments_start_time: form.comments_start_time,
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user changes a Questionnaire from the admin
7
7
  # panel.
8
- class UpdateQuestionStatus < Rectify::Command
8
+ class UpdateQuestionStatus < Decidim::Command
9
9
  class InvalidStatus < StandardError; end
10
10
 
11
11
  # Initializes a UpdateQuestionnaire Command.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # This command is executed when the user changes a Questionnaire from the admin
7
7
  # panel.
8
- class UpdateQuestionnaire < Rectify::Command
8
+ class UpdateQuestionnaire < Decidim::Command
9
9
  # Initializes a UpdateQuestionnaire Command.
10
10
  #
11
11
  # form - The form from which to get the data.
@@ -21,12 +21,15 @@ module Decidim
21
21
  def call
22
22
  return broadcast(:invalid) if @form.invalid?
23
23
 
24
- Decidim::Meetings::Questionnaire.transaction do
25
- create_questionnaire_for
26
- create_questionaire
27
- if @questionnaire.questions_editable?
28
- update_questionnaire_questions
29
- delete_answers
24
+ Decidim.traceability.perform_action!("update", Decidim::Meetings::Questionnaire, @form.current_user, { meeting: @questionnaire.questionnaire_for.try(:meeting) }) do
25
+ Decidim::Meetings::Questionnaire.transaction do
26
+ create_questionnaire_for
27
+ create_questionaire
28
+ if @questionnaire.questions_editable?
29
+ update_questionnaire_questions
30
+ delete_answers
31
+ end
32
+ @questionnaire
30
33
  end
31
34
  end
32
35
 
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Meetings
5
5
  module Admin
6
6
  # This command is executed when the user updates the meeting registrations.
7
- class UpdateRegistrations < Rectify::Command
7
+ class UpdateRegistrations < Decidim::Command
8
8
  # Initializes a UpdateRegistrations Command.
9
9
  #
10
10
  # form - The form from which to get the data.
@@ -18,9 +18,9 @@ module Decidim
18
18
  #
19
19
  # Broadcasts :ok if successful, :invalid otherwise.
20
20
  def call
21
- meeting.with_lock do
22
- return broadcast(:invalid) if form.invalid?
21
+ return broadcast(:invalid) if form.invalid?
23
22
 
23
+ meeting.with_lock do
24
24
  update_meeting_registrations
25
25
  send_notification if should_notify_followers?
26
26
  end
@@ -40,6 +40,8 @@ module Decidim
40
40
  meeting.available_slots = form.available_slots
41
41
  meeting.reserved_slots = form.reserved_slots
42
42
  meeting.registration_terms = form.registration_terms
43
+ meeting.customize_registration_email = form.customize_registration_email
44
+ meeting.registration_email_custom_content = form.registration_email_custom_content if form.customize_registration_email
43
45
  end
44
46
 
45
47
  meeting.save!
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Meetings
5
5
  module Admin
6
6
  # This command is executed when the admin validates a registration code in the admin panel.
7
- class ValidateRegistrationCode < Rectify::Command
7
+ class ValidateRegistrationCode < Decidim::Command
8
8
  # Initializes a ValidateRegistrationCode Command.
9
9
  #
10
10
  # form - The form from which to get the data.
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Meetings
5
5
  # This command is executed when the user closes a Meeting from the public
6
6
  # views.
7
- class CloseMeeting < Rectify::Command
7
+ class CloseMeeting < Decidim::Command
8
8
  # Initializes a CloseMeeting Command.
9
9
  #
10
10
  # form - The form from which to get the data.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Meetings
5
5
  # This command is executed when the user creates an Answer in a meeting poll.
6
- class CreateAnswer < Rectify::Command
6
+ class CreateAnswer < Decidim::Command
7
7
  def initialize(form, current_user, questionnaire)
8
8
  @form = form
9
9
  @current_user = current_user
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Meetings
5
5
  # This command is executed when a participant or user group creates a Meeting from the public
6
6
  # views.
7
- class CreateMeeting < Rectify::Command
7
+ class CreateMeeting < Decidim::Command
8
8
  def initialize(form)
9
9
  @form = form
10
10
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Meetings
5
5
  # This command is executed when the user declines an invite to the meeting.
6
- class DeclineInvitation < Rectify::Command
6
+ class DeclineInvitation < Decidim::Command
7
7
  # Initializes a DeclineInvitation Command.
8
8
  #
9
9
  # meeting - The current instance of the meeting where user has been invited.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Meetings
5
5
  # This command is executed when the user joins a meeting.
6
- class JoinMeeting < Rectify::Command
6
+ class JoinMeeting < Decidim::Command
7
7
  # Initializes a JoinMeeting Command.
8
8
  #
9
9
  # meeting - The current instance of the meeting to be joined.
@@ -21,11 +21,11 @@ module Decidim
21
21
  #
22
22
  # Broadcasts :ok if successful, :invalid otherwise.
23
23
  def call
24
- meeting.with_lock do
25
- return broadcast(:invalid) unless can_join_meeting?
26
- return broadcast(:invalid_form) unless registration_form.valid?
24
+ return broadcast(:invalid) unless can_join_meeting?
25
+ return broadcast(:invalid_form) unless registration_form.valid?
26
+ return broadcast(:invalid) if answer_questionnaire == :invalid
27
27
 
28
- answer_questionnaire
28
+ meeting.with_lock do
29
29
  create_registration
30
30
  accept_invitation
31
31
  send_email_confirmation
@@ -48,7 +48,15 @@ module Decidim
48
48
  def answer_questionnaire
49
49
  return unless questionnaire?
50
50
 
51
- Decidim::Forms::AnswerQuestionnaire.call(registration_form, user, meeting.questionnaire)
51
+ Decidim::Forms::AnswerQuestionnaire.call(registration_form, user, meeting.questionnaire) do
52
+ on(:ok) do
53
+ return :valid
54
+ end
55
+
56
+ on(:invalid) do
57
+ return :invalid
58
+ end
59
+ end
52
60
  end
53
61
 
54
62
  def create_registration
@@ -123,7 +131,7 @@ module Decidim
123
131
  end
124
132
 
125
133
  def questionnaire?
126
- registration_form.model_name == "Questionnaire"
134
+ registration_form.model_name == "questionnaire"
127
135
  end
128
136
  end
129
137
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Meetings
5
5
  # This command is executed when the user leaves a meeting.
6
- class LeaveMeeting < Rectify::Command
6
+ class LeaveMeeting < Decidim::Command
7
7
  # Initializes a LeaveMeeting Command.
8
8
  #
9
9
  # meeting - The current instance of the meeting to be left.
@@ -18,9 +18,9 @@ module Decidim
18
18
  #
19
19
  # Broadcasts :ok if successful, :invalid otherwise.
20
20
  def call
21
- @meeting.with_lock do
22
- return broadcast(:invalid) unless registration
21
+ return broadcast(:invalid) unless registration
23
22
 
23
+ @meeting.with_lock do
24
24
  destroy_registration
25
25
  destroy_questionnaire_answers
26
26
  decrement_score
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Meetings
5
5
  # This command is executed when the user changes a Meeting from the admin
6
6
  # panel.
7
- class UpdateMeeting < Rectify::Command
7
+ class UpdateMeeting < Decidim::Command
8
8
  # Initializes a UpdateMeeting Command.
9
9
  #
10
10
  # form - The form from which to get the data.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Meetings
5
5
  # A command with all the business logic when a user withdraws a new proposal.
6
- class WithdrawMeeting < Rectify::Command
6
+ class WithdrawMeeting < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # meeting - The meeting to withdraw.
@@ -21,23 +21,23 @@ module Decidim
21
21
 
22
22
  def filters
23
23
  [
24
- :type_eq,
24
+ :with_any_type,
25
25
  :is_upcoming_true,
26
26
  :scope_id_eq,
27
27
  :category_id_eq,
28
- :origin_eq,
28
+ :with_any_origin,
29
29
  :closed_at_present
30
30
  ]
31
31
  end
32
32
 
33
33
  def filters_with_values
34
34
  {
35
- type_eq: meeting_types,
35
+ with_any_type: meeting_types,
36
36
  scope_id_eq: scope_ids_hash(scopes.top_level),
37
37
  category_id_eq: category_ids_hash(categories.first_class),
38
38
  closed_at_present: %w(true false),
39
39
  is_upcoming_true: %w(true false),
40
- origin_eq: %w(citizen official user_group)
40
+ with_any_origin: %w(participants official user_group)
41
41
  }
42
42
  end
43
43
 
@@ -15,14 +15,8 @@ module Decidim
15
15
  %w(all) + Decidim::Meetings::Meeting::TYPE_OF_MEETING
16
16
  end
17
17
 
18
- def default_search_params
19
- {
20
- scope: Meeting.not_hidden.visible_meeting_for(current_user)
21
- }
22
- end
23
-
24
18
  def default_filter_origin_params
25
- filter_origin_params = %w(citizens)
19
+ filter_origin_params = %w(participants)
26
20
  filter_origin_params << "official"
27
21
  filter_origin_params << "user_group" if current_organization.user_groups_enabled?
28
22
  filter_origin_params
@@ -11,7 +11,7 @@ module Decidim
11
11
  skip_around_action :use_organization_time_zone
12
12
 
13
13
  def show
14
- render plain: CalendarRenderer.for(current_component), content_type: "type/calendar"
14
+ render plain: CalendarRenderer.for(current_component, params[:filter]), content_type: "type/calendar"
15
15
  end
16
16
 
17
17
  def meeting_calendar
@@ -15,33 +15,40 @@ module Decidim
15
15
  helper Decidim::FiltersHelper
16
16
  helper Decidim::Meetings::MapHelper
17
17
  helper Decidim::ResourceHelper
18
+ helper Decidim::ShortLinkHelper
18
19
 
19
20
  helper_method :meetings, :search
20
21
 
21
22
  def calendar
22
- render plain: CalendarRenderer.for(current_organization), content_type: "type/calendar"
23
+ render plain: CalendarRenderer.for(current_organization, params[:filter]), content_type: "type/calendar"
23
24
  end
24
25
 
25
26
  private
26
27
 
27
28
  def meetings
28
- @meetings ||= paginate(search.results)
29
+ is_past_meetings = params.dig("filter", "with_any_date")&.include?("past")
30
+ @meetings ||= paginate(search.result.order(start_time: is_past_meetings ? :desc : :asc))
29
31
  end
30
32
 
31
- def search_klass
32
- ::Decidim::Meetings::Directory::MeetingSearch
33
+ def search_collection
34
+ Meeting.where(component: meeting_components).published.not_hidden.visible_for(current_user).with_availability(
35
+ filter_params[:availability]
36
+ ).includes(
37
+ :component,
38
+ attachments: :file_attachment
39
+ )
33
40
  end
34
41
 
35
42
  def default_filter_params
36
43
  {
37
- date: "upcoming",
38
- search_text: "",
44
+ with_any_date: "upcoming",
45
+ title_or_description_cont: "",
39
46
  activity: "all",
40
- scope_id: default_filter_scope_params,
41
- space: default_filter_space_params,
42
- type: default_filter_type_params,
43
- origin: default_filter_origin_params,
44
- category_id: default_filter_category_params
47
+ with_any_scope: default_filter_scope_params,
48
+ with_any_space: default_filter_space_params,
49
+ with_any_type: default_filter_type_params,
50
+ with_any_origin: default_filter_origin_params,
51
+ with_any_global_category: default_filter_category_params
45
52
  }
46
53
  end
47
54
 
@@ -68,10 +75,6 @@ module Decidim
68
75
  %w(all global) + current_organization.scopes.pluck(:id).map(&:to_s)
69
76
  end
70
77
 
71
- def context_params
72
- { component: meeting_components, organization: current_organization, current_user: current_user }
73
- end
74
-
75
78
  def meeting_components
76
79
  @meeting_components ||= Decidim::Component
77
80
  .where(manifest_name: "meetings")
@@ -13,6 +13,7 @@ module Decidim
13
13
 
14
14
  helper Decidim::WidgetUrlsHelper
15
15
  helper Decidim::ResourceVersionsHelper
16
+ helper Decidim::ShortLinkHelper
16
17
 
17
18
  helper_method :meetings, :meeting, :registration, :search
18
19
 
@@ -41,13 +42,13 @@ module Decidim
41
42
  end
42
43
 
43
44
  def index
44
- return unless search.results.blank? && params.dig("filter", "date") != %w(past)
45
+ return unless search.result.blank? && params.dig("filter", "date") != %w(past)
45
46
 
46
- @past_meetings = search_klass.new(search_params.merge(date: %w(past)))
47
+ @past_meetings ||= search_with(filter_params.merge(with_any_date: %w(past)))
47
48
 
48
- if @past_meetings.results.present?
49
+ if @past_meetings.result.present?
49
50
  params[:filter] ||= {}
50
- params[:filter][:date] = %w(past)
51
+ params[:filter][:with_any_date] = %w(past)
51
52
  @forced_past_meetings = true
52
53
  @search = @past_meetings
53
54
  end
@@ -108,15 +109,21 @@ module Decidim
108
109
  end
109
110
 
110
111
  def meetings
111
- @meetings ||= paginate(search.results.order(start_time: :desc))
112
+ is_past_meetings = params.dig("filter", "with_any_date")&.include?("past")
113
+ @meetings ||= paginate(search.result.order(start_time: is_past_meetings ? :desc : :asc))
112
114
  end
113
115
 
114
116
  def registration
115
117
  @registration ||= meeting.registrations.find_by(user: current_user)
116
118
  end
117
119
 
118
- def search_klass
119
- MeetingSearch
120
+ def search_collection
121
+ Meeting.where(component: current_component).published.not_hidden.visible_for(current_user).with_availability(
122
+ filter_params[:with_availability]
123
+ ).includes(
124
+ :component,
125
+ attachments: :file_attachment
126
+ )
120
127
  end
121
128
 
122
129
  def meeting_form
@@ -125,14 +132,15 @@ module Decidim
125
132
 
126
133
  def default_filter_params
127
134
  {
128
- search_text: "",
129
- date: %w(upcoming),
135
+ search_text_cont: "",
136
+ with_any_date: "upcoming",
130
137
  activity: "all",
131
- scope_id: default_filter_scope_params,
132
- category_id: default_filter_category_params,
133
- state: nil,
134
- origin: default_filter_origin_params,
135
- type: default_filter_type_params
138
+ with_availability: "",
139
+ with_any_scope: default_filter_scope_params,
140
+ with_any_category: default_filter_category_params,
141
+ with_any_state: nil,
142
+ with_any_origin: default_filter_origin_params,
143
+ with_any_type: default_filter_type_params
136
144
  }
137
145
  end
138
146
  end