decidim-meetings 0.25.2 → 0.26.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/meetings/content_blocks/highlighted_meetings/heading.erb +1 -1
  3. data/app/cells/decidim/meetings/content_blocks/highlighted_meetings_cell.rb +1 -1
  4. data/app/cells/decidim/meetings/content_blocks/{upcoming_events → upcoming_meetings}/show.erb +6 -6
  5. data/app/cells/decidim/meetings/content_blocks/{upcoming_events_cell.rb → upcoming_meetings_cell.rb} +11 -10
  6. data/app/cells/decidim/meetings/highlighted_meetings_for_component_cell.rb +1 -1
  7. data/app/cells/decidim/meetings/join_meeting_button_cell.rb +1 -1
  8. data/app/cells/decidim/meetings/meeting_list_item_cell.rb +10 -0
  9. data/app/cells/decidim/meetings/meeting_m_cell.rb +48 -0
  10. data/app/cells/decidim/meetings/meeting_s_cell.rb +22 -0
  11. data/app/cells/decidim/meetings/meetings_map_cell.rb +6 -0
  12. data/app/cells/decidim/meetings/online_meeting_cell.rb +23 -8
  13. data/app/cells/decidim/meetings/online_meeting_link/show.erb +2 -2
  14. data/app/cells/decidim/meetings/online_meeting_link_cell.rb +1 -5
  15. data/app/cells/decidim/meetings/public_participants_list_cell.rb +1 -0
  16. data/app/cells/decidim/meetings/question_responses_cell.rb +1 -1
  17. data/app/commands/decidim/meetings/admin/create_meeting.rb +11 -1
  18. data/app/commands/decidim/meetings/admin/publish_meeting.rb +3 -1
  19. data/app/commands/decidim/meetings/admin/update_meeting.rb +8 -2
  20. data/app/commands/decidim/meetings/create_meeting.rb +14 -2
  21. data/app/commands/decidim/meetings/update_meeting.rb +5 -2
  22. data/app/commands/decidim/meetings/withdraw_meeting.rb +39 -0
  23. data/app/controllers/concerns/decidim/meetings/filterable.rb +33 -0
  24. data/app/controllers/decidim/meetings/directory/application_controller.rb +16 -0
  25. data/app/controllers/decidim/meetings/directory/meetings_controller.rb +31 -20
  26. data/app/controllers/decidim/meetings/live_events_controller.rb +7 -1
  27. data/app/controllers/decidim/meetings/meetings_controller.rb +19 -17
  28. data/app/events/decidim/meetings/close_meeting_event.rb +1 -3
  29. data/app/events/decidim/meetings/create_meeting_event.rb +2 -4
  30. data/app/events/decidim/meetings/meeting_event.rb +37 -0
  31. data/app/events/decidim/meetings/meeting_registrations_enabled_event.rb +1 -3
  32. data/app/events/decidim/meetings/meeting_registrations_over_percentage_event.rb +2 -4
  33. data/app/events/decidim/meetings/registration_code_validated_event.rb +2 -4
  34. data/app/events/decidim/meetings/upcoming_meeting_event.rb +1 -3
  35. data/app/events/decidim/meetings/update_meeting_event.rb +1 -3
  36. data/app/forms/decidim/meetings/admin/close_meeting_form.rb +1 -1
  37. data/app/forms/decidim/meetings/admin/meeting_copy_form.rb +4 -13
  38. data/app/forms/decidim/meetings/admin/meeting_form.rb +34 -46
  39. data/app/forms/decidim/meetings/base_meeting_form.rb +59 -0
  40. data/app/forms/decidim/meetings/close_meeting_form.rb +6 -6
  41. data/app/forms/decidim/meetings/meeting_form.rb +30 -46
  42. data/app/helpers/decidim/meetings/application_helper.rb +13 -1
  43. data/app/helpers/decidim/meetings/directory/application_helper.rb +150 -0
  44. data/app/helpers/decidim/meetings/meeting_cells_helper.rb +4 -1
  45. data/app/helpers/decidim/meetings/meetings_helper.rb +3 -0
  46. data/app/models/decidim/meetings/meeting.rb +53 -1
  47. data/app/packs/src/decidim/meetings/admin/meetings_form.js +27 -11
  48. data/app/packs/src/decidim/meetings/meetings_form.js +19 -0
  49. data/app/packs/src/decidim/meetings/meetings_polls.js +31 -26
  50. data/app/permissions/decidim/meetings/permissions.rb +9 -1
  51. data/app/presenters/decidim/meetings/meeting_edition_presenter.rb +14 -0
  52. data/app/presenters/decidim/meetings/meeting_presenter.rb +13 -6
  53. data/app/services/decidim/meetings/directory/meeting_search.rb +53 -0
  54. data/app/services/decidim/meetings/meeting_iframe_embedder.rb +1 -1
  55. data/app/services/decidim/meetings/meeting_search.rb +15 -2
  56. data/app/views/decidim/meetings/admin/meeting_copies/_form.html.erb +16 -1
  57. data/app/views/decidim/meetings/admin/meeting_copies/new.html.erb +1 -1
  58. data/app/views/decidim/meetings/admin/meetings/_form.html.erb +15 -3
  59. data/app/views/decidim/meetings/directory/meetings/_filters.html.erb +34 -0
  60. data/app/views/decidim/meetings/directory/meetings/index.html.erb +1 -18
  61. data/app/views/decidim/meetings/meetings/_filters.html.erb +2 -0
  62. data/app/views/decidim/meetings/meetings/_filters_small_view.html.erb +3 -3
  63. data/app/views/decidim/meetings/meetings/_form.html.erb +14 -3
  64. data/app/views/decidim/meetings/meetings/_linked_meetings.html.erb +1 -1
  65. data/app/views/decidim/meetings/meetings/_meetings.html.erb +18 -0
  66. data/app/views/decidim/meetings/meetings/index.html.erb +1 -0
  67. data/app/views/decidim/meetings/meetings/show.html.erb +10 -4
  68. data/config/locales/ar.yml +2 -7
  69. data/config/locales/ca.yml +3 -15
  70. data/config/locales/cs.yml +41 -13
  71. data/config/locales/de.yml +2 -9
  72. data/config/locales/el.yml +2 -7
  73. data/config/locales/en.yml +41 -13
  74. data/config/locales/es-MX.yml +2 -15
  75. data/config/locales/es-PY.yml +2 -15
  76. data/config/locales/es.yml +40 -12
  77. data/config/locales/eu.yml +19 -15
  78. data/config/locales/fi-plain.yml +40 -13
  79. data/config/locales/fi.yml +41 -13
  80. data/config/locales/fr-CA.yml +32 -15
  81. data/config/locales/fr.yml +42 -24
  82. data/config/locales/ga-IE.yml +2 -7
  83. data/config/locales/gl.yml +28 -7
  84. data/config/locales/hu.yml +2 -7
  85. data/config/locales/id-ID.yml +2 -7
  86. data/config/locales/is-IS.yml +0 -7
  87. data/config/locales/it.yml +3 -15
  88. data/config/locales/ja.yml +44 -17
  89. data/config/locales/lb-LU.yml +210 -0
  90. data/config/locales/lb.yml +2 -6
  91. data/config/locales/lv.yml +2 -7
  92. data/config/locales/nl.yml +33 -9
  93. data/config/locales/no.yml +2 -9
  94. data/config/locales/pl.yml +14 -9
  95. data/config/locales/pt-BR.yml +3 -10
  96. data/config/locales/pt.yml +2 -15
  97. data/config/locales/ro-RO.yml +31 -15
  98. data/config/locales/ru.yml +0 -7
  99. data/config/locales/sk.yml +2 -7
  100. data/config/locales/sv.yml +23 -15
  101. data/config/locales/tr-TR.yml +2 -9
  102. data/config/locales/uk.yml +0 -9
  103. data/config/locales/val-ES.yml +1 -0
  104. data/config/locales/zh-CN.yml +2 -9
  105. data/db/migrate/20210519133705_add_comments_availability_columns_to_meetings_table.rb +14 -0
  106. data/db/migrate/20210727085318_add_state_field_to_meeting.rb +7 -0
  107. data/db/migrate/20210903143040_add_iframe_access_level_to_decidim_meetings.rb +7 -0
  108. data/db/migrate/20210922140454_transform_show_embedded_iframe_column.rb +15 -0
  109. data/db/migrate/20210928095036_rename_upcoming_events_content_block_to_upcoming_meetings.rb +13 -0
  110. data/lib/decidim/api/meeting_type.rb +2 -1
  111. data/lib/decidim/meetings/component.rb +13 -5
  112. data/lib/decidim/meetings/directory_engine.rb +3 -3
  113. data/lib/decidim/meetings/engine.rb +4 -1
  114. data/lib/decidim/meetings/meeting_serializer.rb +2 -2
  115. data/lib/decidim/meetings/test/factories.rb +24 -3
  116. data/lib/decidim/meetings/test/notifications_handling.rb +39 -0
  117. data/lib/decidim/meetings/test/translated_event.rb +22 -0
  118. data/lib/decidim/meetings/version.rb +1 -1
  119. data/lib/decidim/meetings.rb +5 -0
  120. metadata +36 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ae414fe044e7f7ceb3768cdb416c37366bdd2beb3027aa4cf7defedf753a3a4
4
- data.tar.gz: 659164c74c1a39f7614000c2f4a57bc1a95d1641396b9a24754c1855197f51ed
3
+ metadata.gz: 256dad0f957894de0c248a6cce248f88bc042dd492c66fd11e184d7a87967c39
4
+ data.tar.gz: c6a0dfbfe8f98bebebf610efb7343760c54dba467c110cc9f5f13f00b3808f15
5
5
  SHA512:
6
- metadata.gz: d3549df723f3ee977c20a0418ed165a80ebf4f8df2b148e1494484388df72c4c47f30542b51db09df74290d1216f14b16dc3dde447102dc61a20d419a8a335ef
7
- data.tar.gz: e637a74a06ab3e6a8e45a099c237ee7f3153b4e42523cd7591ad6b92e723c0dcca50878b5fba459c53649c314869dd78d983f44b3ef59129ebe62bf7ab9ac16e
6
+ metadata.gz: 5dd07cca73c821eaf9cc3563a214a1739cac3fa09e1cd6a4f306dc0724a035d04019628b913ba134c4568cf453bc5d177a6c6df3753a835ba590756d7a01b68e
7
+ data.tar.gz: f44f047fcd96d9e89dd57a3758c6199285675eb91b813dc9c5fa60d50bdd69cff37f067697469513e129f4a3b8473d0d59d14d46efc436fc3817bda17f22aad5
@@ -1 +1 @@
1
- <h2 class="section-heading"><%= t("decidim.meetings.content_blocks.upcoming_events.upcoming_events") %></h2>
1
+ <h2 class="section-heading"><%= t("decidim.meetings.content_blocks.upcoming_meetings.upcoming_meetings") %></h2>
@@ -5,7 +5,7 @@ module Decidim
5
5
  module ContentBlocks
6
6
  class HighlightedMeetingsCell < Decidim::ContentBlocks::HighlightedElementsCell
7
7
  def base_relation
8
- Decidim::Meetings::Meeting.where(component: published_components)
8
+ Decidim::Meetings::Meeting.except_withdrawn.where(component: published_components)
9
9
  end
10
10
 
11
11
  def elements
@@ -1,17 +1,17 @@
1
- <section class="wrapper-home upcoming-events home-section">
1
+ <section class="wrapper-home upcoming-meetings home-section">
2
2
  <div class="row">
3
- <h3 class="section-heading"><%= t("decidim.meetings.content_blocks.upcoming_events.upcoming_events") %></h3>
3
+ <h3 class="section-heading"><%= t("decidim.meetings.content_blocks.upcoming_meetings.upcoming_meetings") %></h3>
4
4
  <div class="row">
5
5
  <div class="columns medium-6">
6
- <% upcoming_events.first(4).each do |event| %>
6
+ <% upcoming_meetings.first(4).each do |event| %>
7
7
  <%= card_for event, size: :s %>
8
8
  <% end %>
9
9
  </div>
10
10
  <div class="columns medium-6">
11
11
  <% if geolocation_enabled? %>
12
- <%= cell "decidim/meetings/meetings_map", upcoming_events %>
12
+ <%= cell "decidim/meetings/meetings_map", upcoming_meetings %>
13
13
  <% else %>
14
- <% (upcoming_events - upcoming_events.first(4)).each do |event| %>
14
+ <% (upcoming_meetings - upcoming_meetings.first(4)).each do |event| %>
15
15
  <%= card_for event, size: :s %>
16
16
  <% end %>
17
17
  <% end %>
@@ -19,7 +19,7 @@
19
19
  </div>
20
20
  <div class="row">
21
21
  <div class="column">
22
- <%= link_to t("decidim.meetings.content_blocks.upcoming_events.view_all_events"), meetings_directory_path, class: "button hollow button--sc pull-right" %>
22
+ <%= link_to t("decidim.meetings.content_blocks.upcoming_meetings.view_all_meetings"), meetings_directory_path, class: "button hollow button--sc pull-right" %>
23
23
  </div>
24
24
  </div>
25
25
  </div>
@@ -3,23 +3,24 @@
3
3
  module Decidim
4
4
  module Meetings
5
5
  module ContentBlocks
6
- class UpcomingEventsCell < Decidim::ViewModel
6
+ class UpcomingMeetingsCell < Decidim::ViewModel
7
7
  include Decidim::CardHelper
8
8
 
9
9
  def show
10
- return if upcoming_events.blank?
10
+ return if upcoming_meetings.blank?
11
11
 
12
12
  render
13
13
  end
14
14
 
15
- def upcoming_events
16
- @upcoming_events ||= Decidim::Meetings::Meeting
17
- .includes(component: :participatory_space)
18
- .where(component: meeting_components)
19
- .visible_meeting_for(current_user)
20
- .where("end_time >= ?", Time.current)
21
- .order(start_time: :asc)
22
- .limit(limit)
15
+ def upcoming_meetings
16
+ @upcoming_meetings ||= Decidim::Meetings::Meeting
17
+ .includes(component: :participatory_space)
18
+ .where(component: meeting_components)
19
+ .visible_meeting_for(current_user)
20
+ .where("end_time >= ?", Time.current)
21
+ .except_withdrawn
22
+ .order(start_time: :asc)
23
+ .limit(limit)
23
24
  end
24
25
 
25
26
  def geolocation_enabled?
@@ -18,7 +18,7 @@ module Decidim
18
18
  private
19
19
 
20
20
  def meetings
21
- @meetings ||= Decidim::Meetings::Meeting.where(component: model).visible_meeting_for(current_user)
21
+ @meetings ||= Decidim::Meetings::Meeting.where(component: model).except_withdrawn.visible_meeting_for(current_user)
22
22
  end
23
23
 
24
24
  def past_meetings
@@ -50,7 +50,7 @@ module Decidim
50
50
  end
51
51
 
52
52
  def registration_terms_text
53
- decidim_sanitize translated_attribute(model.registration_terms)
53
+ decidim_sanitize_editor translated_attribute(model.registration_terms)
54
54
  end
55
55
 
56
56
  def registration_form
@@ -13,6 +13,16 @@ module Decidim
13
13
 
14
14
  private
15
15
 
16
+ def cache_hash
17
+ hash = []
18
+ hash.push(I18n.locale.to_s)
19
+ hash.push(model.cache_key_with_version)
20
+ hash.push(model.component.cache_key_with_version)
21
+ hash.push(model.must_render_translation?(current_organization) ? 1 : 0) if model.respond_to?(:must_render_translation?)
22
+
23
+ hash.join(Decidim.cache_key_separator)
24
+ end
25
+
16
26
  def resource_path
17
27
  resource_locator(model).path(filter_link_params)
18
28
  end
@@ -27,10 +27,58 @@ module Decidim
27
27
  present(model).title
28
28
  end
29
29
 
30
+ def description
31
+ present(model).description(strip_tags: true)
32
+ end
33
+
34
+ def badge
35
+ render if has_badge?
36
+ end
37
+
38
+ def has_badge?
39
+ withdrawn?
40
+ end
41
+
42
+ def state_classes
43
+ ["alert"]
44
+ end
45
+
30
46
  delegate :online_meeting?, to: :model
31
47
 
32
48
  private
33
49
 
50
+ def cache_hash
51
+ hash = []
52
+ hash << I18n.locale.to_s
53
+ hash << model.cache_key_with_version
54
+ hash << Digest::MD5.hexdigest(model.component.cache_key_with_version)
55
+ hash << Digest::MD5.hexdigest(resource_image_path) if resource_image_path
56
+ hash << model.comments_count
57
+ hash << model.follows_count
58
+ hash << render_space? ? 1 : 0
59
+
60
+ if current_user
61
+ hash << current_user.cache_key_with_version
62
+ hash << current_user.follows?(model) ? 1 : 0
63
+ end
64
+ hash << Digest::MD5.hexdigest(model.author.cache_key_with_version)
65
+ hash << (model.must_render_translation?(current_organization) ? 1 : 0) if model.respond_to?(:must_render_translation?)
66
+
67
+ hash.join(Decidim.cache_key_separator)
68
+ end
69
+
70
+ def has_state?
71
+ withdrawn?
72
+ end
73
+
74
+ def resource_image_path
75
+ model.photo&.url
76
+ end
77
+
78
+ def has_image?
79
+ true
80
+ end
81
+
34
82
  def spans_multiple_dates?
35
83
  start_date != end_date
36
84
  end
@@ -26,6 +26,28 @@ module Decidim
26
26
  def presenter
27
27
  @presenter ||= Decidim::Meetings::MeetingPresenter.new(model)
28
28
  end
29
+
30
+ private
31
+
32
+ def cache_hash
33
+ hash = []
34
+ hash << I18n.locale.to_s
35
+ hash << model.cache_key_with_version
36
+ hash << Digest::MD5.hexdigest(model.component.cache_key_with_version)
37
+ hash << Digest::MD5.hexdigest(resource_image_path) if resource_image_path
38
+ hash << model.comments_count
39
+ hash << model.follows_count
40
+ hash << render_space? ? 1 : 0
41
+
42
+ if current_user
43
+ hash << current_user.cache_key_with_version
44
+ hash << current_user.follows?(model) ? 1 : 0
45
+ end
46
+ hash << Digest::MD5.hexdigest(model.author.cache_key_with_version)
47
+ hash << (model.must_render_translation?(current_organization) ? 1 : 0) if model.respond_to?(:must_render_translation?)
48
+
49
+ hash.join(Decidim.cache_key_separator)
50
+ end
29
51
  end
30
52
  end
31
53
  end
@@ -21,6 +21,12 @@ module Decidim
21
21
  def meetings
22
22
  model
23
23
  end
24
+
25
+ private
26
+
27
+ def cache_hash
28
+ nil
29
+ end
24
30
  end
25
31
  end
26
32
  end
@@ -5,6 +5,16 @@ module Decidim
5
5
  # This cell defines methods required for other cells to render
6
6
  # online meeting urls
7
7
  class OnlineMeetingCell < Decidim::ViewModel
8
+ delegate :live?, to: :model
9
+
10
+ def show
11
+ return if model.iframe_embed_type_none?
12
+ return unless model.iframe_access_level_allowed_for_user?(current_user)
13
+ return unless assembly_privacy_allowed?
14
+
15
+ render
16
+ end
17
+
8
18
  protected
9
19
 
10
20
  def embedder
@@ -14,23 +24,28 @@ module Decidim
14
24
  delegate :embeddable?, to: :embedder
15
25
 
16
26
  def live_event_url
17
- if embeddable?
27
+ if embeddable? && !model.iframe_embed_type_open_in_new_tab?
18
28
  Decidim::EngineRouter.main_proxy(model.component).meeting_live_event_path(meeting_id: model.id)
19
29
  else
20
30
  model.online_meeting_url
21
31
  end
22
32
  end
23
33
 
24
- def live?
25
- model.start_time &&
26
- model.end_time &&
27
- Time.current >= (model.start_time - 10.minutes) &&
28
- Time.current <= model.end_time
29
- end
30
-
31
34
  def future?
32
35
  Time.current <= model.start_time && !live?
33
36
  end
37
+
38
+ def assembly_privacy_allowed?
39
+ return true if !private_transparent_assembly? || current_user&.admin?
40
+
41
+ model.participatory_space.users.include?(current_user)
42
+ end
43
+
44
+ def private_transparent_assembly?
45
+ return unless model.participatory_space.is_a?(Decidim::Assembly)
46
+
47
+ model.participatory_space.private_space? && model.participatory_space.is_transparent?
48
+ end
34
49
  end
35
50
  end
36
51
  end
@@ -1,5 +1,5 @@
1
1
  <% if online_meeting_url? %>
2
- <% if show_embed? || live? || future? %>
2
+ <% if live? || future? %>
3
3
  <div class="card card--secondary">
4
4
  <div class="card__content text-center">
5
5
  <% if live? %>
@@ -14,7 +14,7 @@
14
14
  </div>
15
15
  <% end %>
16
16
 
17
- <% if show_embed? %>
17
+ <% if show_embed? && live? %>
18
18
  <div class="<%= "margin-top-3" if live? %> absolutes aspect-ratio-16-9">
19
19
  <%== embed_code(request.host) %>
20
20
  </div>
@@ -7,10 +7,6 @@ module Decidim
7
7
  class OnlineMeetingLinkCell < Decidim::Meetings::OnlineMeetingCell
8
8
  include Decidim::LayoutHelper
9
9
 
10
- def show
11
- render
12
- end
13
-
14
10
  def online_meeting_url?
15
11
  model.online_meeting_url.present?
16
12
  end
@@ -20,7 +16,7 @@ module Decidim
20
16
  private
21
17
 
22
18
  def show_embed?
23
- model.show_embedded_iframe? && embedder.embeddable?
19
+ model.iframe_embed_type_embed_in_meeting_page? && embedder.embeddable?
24
20
  end
25
21
  end
26
22
  end
@@ -10,6 +10,7 @@ module Decidim
10
10
  #
11
11
  # cell("decidim/public_participants_list", meeting)
12
12
  class PublicParticipantsListCell < Decidim::ViewModel
13
+ include Decidim::Meetings::MeetingsHelper
13
14
  include ApplicationHelper
14
15
 
15
16
  def show
@@ -25,7 +25,7 @@ module Decidim
25
25
  # This calculation is a bit complex because of multiple option answers
26
26
  question_answers_choices = Decidim::Meetings::AnswerOption.where(decidim_question_id: model.id)
27
27
  .joins([choices: :answer])
28
- .group("#{answers_table_name}.id, #{answer_options_table_name}.id")
28
+ .group(Arel.sql("#{answers_table_name}.id, #{answer_options_table_name}.id"))
29
29
  .select(<<~SELECT
30
30
  #{answer_options_table_name}.id AS id,
31
31
  #{answer_options_table_name}.body,
@@ -21,6 +21,7 @@ module Decidim
21
21
  create_services!
22
22
  end
23
23
 
24
+ create_follow_form_resource(form.current_user)
24
25
  broadcast(:ok, meeting)
25
26
  end
26
27
 
@@ -56,7 +57,11 @@ module Decidim
56
57
  questionnaire: Decidim::Forms::Questionnaire.new,
57
58
  customize_registration_email: form.customize_registration_email,
58
59
  registration_email_custom_content: form.registration_email_custom_content,
59
- show_embedded_iframe: form.show_embedded_iframe
60
+ iframe_embed_type: form.iframe_embed_type,
61
+ comments_enabled: form.comments_enabled,
62
+ comments_start_time: form.comments_start_time,
63
+ comments_end_time: form.comments_end_time,
64
+ iframe_access_level: form.iframe_access_level
60
65
  }
61
66
 
62
67
  @meeting = Decidim.traceability.create!(
@@ -76,6 +81,11 @@ module Decidim
76
81
  )
77
82
  end
78
83
  end
84
+
85
+ def create_follow_form_resource(user)
86
+ follow_form = Decidim::FollowForm.from_params(followable_gid: meeting.to_signed_global_id.to_s).with_context(current_user: user)
87
+ Decidim::CreateFollow.call(follow_form, user)
88
+ end
79
89
  end
80
90
  end
81
91
  end
@@ -60,10 +60,12 @@ module Decidim
60
60
  end
61
61
 
62
62
  def schedule_upcoming_meeting_notification
63
+ return if meeting.start_time < Time.zone.now
64
+
63
65
  checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(meeting)
64
66
 
65
67
  Decidim::Meetings::UpcomingMeetingNotificationJob
66
- .set(wait_until: meeting.start_time - 2.days)
68
+ .set(wait_until: meeting.start_time - Decidim::Meetings.upcoming_meeting_notification)
67
69
  .perform_later(meeting.id, checksum)
68
70
  end
69
71
  end
@@ -62,7 +62,11 @@ module Decidim
62
62
  transparent: form.transparent,
63
63
  customize_registration_email: form.customize_registration_email,
64
64
  registration_email_custom_content: form.registration_email_custom_content,
65
- show_embedded_iframe: form.show_embedded_iframe
65
+ iframe_embed_type: form.iframe_embed_type,
66
+ comments_enabled: form.comments_enabled,
67
+ comments_start_time: form.comments_start_time,
68
+ comments_end_time: form.comments_end_time,
69
+ iframe_access_level: form.iframe_access_level
66
70
  )
67
71
  end
68
72
 
@@ -95,10 +99,12 @@ module Decidim
95
99
  end
96
100
 
97
101
  def schedule_upcoming_meeting_notification
102
+ return if meeting.start_time < Time.zone.now
103
+
98
104
  checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(meeting)
99
105
 
100
106
  Decidim::Meetings::UpcomingMeetingNotificationJob
101
- .set(wait_until: meeting.start_time - 2.days)
107
+ .set(wait_until: meeting.start_time - Decidim::Meetings.upcoming_meeting_notification)
102
108
  .perform_later(meeting.id, checksum)
103
109
  end
104
110
  end
@@ -21,6 +21,7 @@ module Decidim
21
21
  send_notification
22
22
  end
23
23
 
24
+ create_follow_form_resource(form.current_user)
24
25
  broadcast(:ok, meeting)
25
26
  end
26
27
 
@@ -54,7 +55,8 @@ module Decidim
54
55
  type_of_meeting: form.clean_type_of_meeting,
55
56
  component: form.current_component,
56
57
  published_at: Time.current,
57
- show_embedded_iframe: form.show_embedded_iframe
58
+ iframe_embed_type: form.iframe_embed_type,
59
+ iframe_access_level: form.iframe_access_level
58
60
  }
59
61
 
60
62
  @meeting = Decidim.traceability.create!(
@@ -63,13 +65,18 @@ module Decidim
63
65
  params,
64
66
  visibility: "public-only"
65
67
  )
68
+ Decidim.traceability.perform_action!(:publish, meeting, form.current_user, visibility: "all") do
69
+ meeting.publish!
70
+ end
66
71
  end
67
72
 
68
73
  def schedule_upcoming_meeting_notification
74
+ return if meeting.start_time < Time.zone.now
75
+
69
76
  checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(meeting)
70
77
 
71
78
  Decidim::Meetings::UpcomingMeetingNotificationJob
72
- .set(wait_until: meeting.start_time - 2.days)
79
+ .set(wait_until: meeting.start_time - Decidim::Meetings.upcoming_meeting_notification)
73
80
  .perform_later(meeting.id, checksum)
74
81
  end
75
82
 
@@ -81,6 +88,11 @@ module Decidim
81
88
  followers: meeting.participatory_space.followers
82
89
  )
83
90
  end
91
+
92
+ def create_follow_form_resource(user)
93
+ follow_form = Decidim::FollowForm.from_params(followable_gid: meeting.to_signed_global_id.to_s).with_context(current_user: user)
94
+ Decidim::CreateFollow.call(follow_form, user)
95
+ end
84
96
  end
85
97
  end
86
98
  end
@@ -63,7 +63,8 @@ module Decidim
63
63
  registrations_enabled: form.registrations_enabled,
64
64
  type_of_meeting: form.clean_type_of_meeting,
65
65
  online_meeting_url: form.online_meeting_url,
66
- show_embedded_iframe: form.show_embedded_iframe
66
+ iframe_embed_type: form.iframe_embed_type,
67
+ iframe_access_level: form.iframe_access_level
67
68
  },
68
69
  visibility: "public-only"
69
70
  )
@@ -91,10 +92,12 @@ module Decidim
91
92
  end
92
93
 
93
94
  def schedule_upcoming_meeting_notification
95
+ return if meeting.start_time < Time.zone.now
96
+
94
97
  checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(meeting)
95
98
 
96
99
  Decidim::Meetings::UpcomingMeetingNotificationJob
97
- .set(wait_until: meeting.start_time - 2.days)
100
+ .set(wait_until: meeting.start_time - Decidim::Meetings.upcoming_meeting_notification)
98
101
  .perform_later(meeting.id, checksum)
99
102
  end
100
103
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ # A command with all the business logic when a user withdraws a new proposal.
6
+ class WithdrawMeeting < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # meeting - The meeting to withdraw.
10
+ # current_user - The current user.
11
+ def initialize(meeting, current_user)
12
+ @meeting = meeting
13
+ @current_user = current_user
14
+ end
15
+
16
+ # Executes the command. Broadcasts these events:
17
+ #
18
+ # - :ok when everything is valid, together with the meeting.
19
+ # - :invalid if the meeting does not belong to current user.
20
+ #
21
+ # Returns nothing.
22
+ def call
23
+ return broadcast(:invalid) unless @meeting.authored_by?(@current_user)
24
+
25
+ transaction do
26
+ change_meeting_state_to_withdrawn
27
+ end
28
+
29
+ broadcast(:ok, @meeting)
30
+ end
31
+
32
+ private
33
+
34
+ def change_meeting_state_to_withdrawn
35
+ @meeting.update state: "withdrawn"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/concern"
4
+
5
+ module Decidim
6
+ module Meetings
7
+ # A controller concern to specify default filter parameters for the controller resources.
8
+ module Filterable
9
+ extend ActiveSupport::Concern
10
+
11
+ included do
12
+ private
13
+
14
+ def default_filter_type_params
15
+ %w(all) + Decidim::Meetings::Meeting::TYPE_OF_MEETING
16
+ end
17
+
18
+ def default_search_params
19
+ {
20
+ scope: Meeting.not_hidden.visible_meeting_for(current_user)
21
+ }
22
+ end
23
+
24
+ def default_filter_origin_params
25
+ filter_origin_params = %w(citizens)
26
+ filter_origin_params << "official"
27
+ filter_origin_params << "user_group" if current_organization.user_groups_enabled?
28
+ filter_origin_params
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ # This controller is the abstract class from which all other controllers of
6
+ # this engine inherit.
7
+ #
8
+ # Note that it inherits from `Decidim::Components::BaseController`, which
9
+ # override its layout and provide all kinds of useful methods.
10
+ module Directory
11
+ class ApplicationController < Decidim::ApplicationController
12
+ helper Decidim::Meetings::Directory::ApplicationHelper
13
+ end
14
+ end
15
+ end
16
+ end