decidim-meetings 0.19.1 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/decidim_meetings_manifest.js +2 -0
  3. data/app/assets/images/decidim/gamification/badges/attended_meetings.svg +1 -106
  4. data/app/assets/images/decidim/meetings/icon.svg +1 -5
  5. data/app/assets/javascripts/decidim/meetings/admin/destroy_meeting_alert.js.es6 +16 -0
  6. data/app/assets/javascripts/decidim/meetings/admin/meetings_form.js.es6 +3 -0
  7. data/app/assets/javascripts/decidim/meetings/meetings_form.js.es6 +9 -0
  8. data/app/cells/decidim/meetings/content_blocks/upcoming_events_cell.rb +2 -1
  9. data/app/cells/decidim/meetings/highlighted_meetings_for_component/show.erb +7 -7
  10. data/app/cells/decidim/meetings/highlighted_meetings_for_component_cell.rb +1 -1
  11. data/app/cells/decidim/meetings/join_meeting_button/show.erb +2 -2
  12. data/app/cells/decidim/meetings/meeting_cell.rb +1 -0
  13. data/app/cells/decidim/meetings/meeting_list_item/show.erb +3 -3
  14. data/app/cells/decidim/meetings/meeting_list_item_cell.rb +1 -1
  15. data/app/cells/decidim/meetings/meeting_m/date.erb +1 -1
  16. data/app/cells/decidim/meetings/meeting_m/footer.erb +1 -1
  17. data/app/cells/decidim/meetings/meeting_m/multiple_dates.erb +1 -1
  18. data/app/cells/decidim/meetings/meeting_m_cell.rb +9 -1
  19. data/app/cells/decidim/meetings/meeting_s/show.erb +6 -6
  20. data/app/cells/decidim/meetings/meetings_map/show.erb +0 -2
  21. data/app/cells/decidim/meetings/meetings_map_cell.rb +3 -1
  22. data/app/commands/decidim/meetings/admin/close_meeting.rb +1 -2
  23. data/app/commands/decidim/meetings/admin/copy_meeting.rb +38 -28
  24. data/app/commands/decidim/meetings/admin/create_meeting.rb +36 -24
  25. data/app/commands/decidim/meetings/admin/destroy_meeting.rb +6 -1
  26. data/app/commands/decidim/meetings/admin/invite_user_to_join_meeting.rb +2 -1
  27. data/app/commands/decidim/meetings/admin/update_meeting.rb +9 -3
  28. data/app/commands/decidim/meetings/create_meeting.rb +78 -0
  29. data/app/commands/decidim/meetings/join_meeting.rb +11 -0
  30. data/app/commands/decidim/meetings/update_meeting.rb +94 -0
  31. data/app/controllers/decidim/meetings/admin/application_controller.rb +1 -1
  32. data/app/controllers/decidim/meetings/admin/meeting_closes_controller.rb +2 -0
  33. data/app/controllers/decidim/meetings/admin/meetings_controller.rb +21 -7
  34. data/app/controllers/decidim/meetings/admin/registration_form_controller.rb +4 -0
  35. data/app/controllers/decidim/meetings/calendars_controller.rb +1 -0
  36. data/app/controllers/decidim/meetings/directory/meetings_controller.rb +1 -1
  37. data/app/controllers/decidim/meetings/meetings_controller.rb +75 -12
  38. data/app/controllers/decidim/meetings/registrations_controller.rb +2 -2
  39. data/app/controllers/decidim/meetings/versions_controller.rb +14 -0
  40. data/app/controllers/decidim/meetings/{meeting_widgets_controller.rb → widgets_controller.rb} +2 -2
  41. data/app/forms/decidim/meetings/admin/close_meeting_form.rb +7 -1
  42. data/app/forms/decidim/meetings/admin/meeting_copy_form.rb +2 -8
  43. data/app/forms/decidim/meetings/admin/meeting_form.rb +24 -23
  44. data/app/forms/decidim/meetings/meeting_form.rb +78 -0
  45. data/app/helpers/decidim/meetings/admin/application_helper.rb +1 -6
  46. data/app/helpers/decidim/meetings/application_helper.rb +26 -0
  47. data/app/helpers/decidim/meetings/map_helper.rb +2 -1
  48. data/app/helpers/decidim/meetings/meetings_helper.rb +13 -1
  49. data/app/models/decidim/meetings/agenda.rb +3 -0
  50. data/app/models/decidim/meetings/agenda_item.rb +3 -0
  51. data/app/models/decidim/meetings/meeting.rb +43 -15
  52. data/app/models/decidim/meetings/minutes.rb +3 -0
  53. data/app/models/decidim/meetings/service.rb +13 -0
  54. data/app/permissions/decidim/meetings/admin/permissions.rb +2 -0
  55. data/app/permissions/decidim/meetings/permissions.rb +20 -0
  56. data/app/presenters/decidim/meetings/admin_log/invite_presenter.rb +5 -1
  57. data/app/presenters/decidim/meetings/admin_log/meeting_presenter.rb +1 -2
  58. data/app/presenters/decidim/meetings/meeting_presenter.rb +21 -6
  59. data/app/presenters/decidim/meetings/official_author_presenter.rb +14 -0
  60. data/app/queries/decidim/meetings/filtered_meetings.rb +37 -0
  61. data/app/queries/decidim/meetings/metrics/meetings_metric_manage.rb +2 -8
  62. data/app/services/decidim/meetings/calendar/meeting_to_event.rb +3 -3
  63. data/app/services/decidim/meetings/diff_renderer.rb +21 -0
  64. data/app/services/decidim/meetings/meeting_search.rb +3 -25
  65. data/app/types/decidim/meetings/agenda_item_type.rb +28 -0
  66. data/app/types/decidim/meetings/agenda_type.rb +25 -0
  67. data/app/types/decidim/meetings/meeting_type.rb +35 -8
  68. data/app/types/decidim/meetings/meetings_type.rb +1 -1
  69. data/app/types/decidim/meetings/minutes_type.rb +26 -0
  70. data/app/types/decidim/meetings/service_type.rb +13 -0
  71. data/app/views/decidim/meetings/_calendar_modal.html.erb +4 -4
  72. data/app/views/decidim/meetings/admin/invites/index.html.erb +2 -2
  73. data/app/views/decidim/meetings/admin/meeting_closes/_form.html.erb +1 -6
  74. data/app/views/decidim/meetings/admin/meeting_closes/proposals_picker.html.erb +1 -0
  75. data/app/views/decidim/meetings/admin/meeting_copies/_form.html.erb +2 -9
  76. data/app/views/decidim/meetings/admin/meetings/_form.html.erb +8 -12
  77. data/app/views/decidim/meetings/admin/meetings/edit.html.erb +1 -1
  78. data/app/views/decidim/meetings/admin/meetings/index.html.erb +22 -3
  79. data/app/views/decidim/meetings/admin/registrations/_form.html.erb +4 -0
  80. data/app/views/decidim/meetings/directory/meetings/index.html.erb +5 -3
  81. data/app/views/decidim/meetings/directory/meetings/index.js.erb +11 -4
  82. data/app/views/decidim/meetings/meetings/_count.html.erb +1 -0
  83. data/app/views/decidim/meetings/meetings/_filters.html.erb +13 -7
  84. data/app/views/decidim/meetings/meetings/_form.html.erb +51 -0
  85. data/app/views/decidim/meetings/meetings/_linked_meetings.html.erb +2 -2
  86. data/app/views/decidim/meetings/meetings/_meeting_agenda.html.erb +2 -2
  87. data/app/views/decidim/meetings/meetings/_meeting_minutes.html.erb +8 -8
  88. data/app/views/decidim/meetings/meetings/edit.html.erb +25 -0
  89. data/app/views/decidim/meetings/meetings/index.html.erb +16 -1
  90. data/app/views/decidim/meetings/meetings/index.js.erb +13 -4
  91. data/app/views/decidim/meetings/meetings/new.html.erb +25 -0
  92. data/app/views/decidim/meetings/meetings/show.html.erb +30 -8
  93. data/app/views/decidim/meetings/versions/index.html.erb +8 -0
  94. data/app/views/decidim/meetings/versions/show.html.erb +10 -0
  95. data/app/views/decidim/participatory_processes/participatory_process_groups/_meeting.html.erb +2 -2
  96. data/app/views/decidim/participatory_spaces/_conference_venues.html.erb +1 -1
  97. data/app/views/decidim/participatory_spaces/_upcoming_meeting_for_card.html.erb +1 -3
  98. data/config/locales/am-ET.yml +1 -0
  99. data/config/locales/ar.yml +4 -8
  100. data/config/locales/bg-BG.yml +21 -0
  101. data/config/locales/bg.yml +21 -0
  102. data/config/locales/ca.yml +64 -8
  103. data/config/locales/cs.yml +70 -8
  104. data/config/locales/da-DK.yml +1 -0
  105. data/config/locales/da.yml +1 -0
  106. data/config/locales/de.yml +64 -7
  107. data/config/locales/el-GR.yml +1 -0
  108. data/config/locales/el.yml +449 -0
  109. data/config/locales/en.yml +65 -9
  110. data/config/locales/eo.yml +1 -0
  111. data/config/locales/es-MX.yml +63 -7
  112. data/config/locales/es-PY.yml +63 -7
  113. data/config/locales/es.yml +65 -9
  114. data/config/locales/et-EE.yml +1 -0
  115. data/config/locales/et.yml +1 -0
  116. data/config/locales/eu.yml +0 -8
  117. data/config/locales/fi-plain.yml +63 -7
  118. data/config/locales/fi.yml +89 -33
  119. data/config/locales/fr-CA.yml +504 -0
  120. data/config/locales/fr.yml +63 -7
  121. data/config/locales/ga-IE.yml +1 -0
  122. data/config/locales/gl.yml +0 -8
  123. data/config/locales/hr-HR.yml +1 -0
  124. data/config/locales/hr.yml +1 -0
  125. data/config/locales/hu.yml +14 -7
  126. data/config/locales/id-ID.yml +0 -8
  127. data/config/locales/is-IS.yml +228 -0
  128. data/config/locales/is.yml +228 -0
  129. data/config/locales/it.yml +62 -8
  130. data/config/locales/ja-JP.yml +494 -0
  131. data/config/locales/ja.yml +496 -0
  132. data/config/locales/ko-KR.yml +1 -0
  133. data/config/locales/ko.yml +1 -0
  134. data/config/locales/lt-LT.yml +1 -0
  135. data/config/locales/lt.yml +1 -0
  136. data/config/locales/lv.yml +452 -0
  137. data/config/locales/mt-MT.yml +1 -0
  138. data/config/locales/mt.yml +1 -0
  139. data/config/locales/nl.yml +95 -47
  140. data/config/locales/no.yml +358 -1
  141. data/config/locales/om-ET.yml +1 -0
  142. data/config/locales/pl.yml +210 -147
  143. data/config/locales/pt-BR.yml +1 -9
  144. data/config/locales/pt.yml +232 -177
  145. data/config/locales/ro-RO.yml +500 -0
  146. data/config/locales/ru.yml +0 -8
  147. data/config/locales/sk-SK.yml +463 -0
  148. data/config/locales/sk.yml +458 -0
  149. data/config/locales/sl.yml +29 -0
  150. data/config/locales/so-SO.yml +1 -0
  151. data/config/locales/sr-CS.yml +13 -0
  152. data/config/locales/sv.yml +67 -13
  153. data/config/locales/ti-ER.yml +1 -0
  154. data/config/locales/tr-TR.yml +0 -8
  155. data/config/locales/uk.yml +0 -8
  156. data/config/locales/vi-VN.yml +1 -0
  157. data/config/locales/vi.yml +1 -0
  158. data/config/locales/zh-CN.yml +496 -0
  159. data/config/locales/zh-TW.yml +1 -0
  160. data/db/migrate/20200320105922_index_foreign_keys_in_decidim_meetings_registrations.rb +7 -0
  161. data/db/migrate/20200526110940_add_author_to_meetings.rb +30 -0
  162. data/db/migrate/20200702123209_create_meeting_services_table.rb +13 -0
  163. data/db/migrate/20200702123210_move_meeting_services_to_own_model.rb +31 -0
  164. data/db/migrate/20200827153856_add_commentable_counter_cache_to_meetings.rb +9 -0
  165. data/db/migrate/20201016065302_fix_meetings_registration_terms.rb +29 -0
  166. data/lib/decidim/api/linked_resources_interface.rb +17 -0
  167. data/lib/decidim/api/services_interface.rb +13 -0
  168. data/lib/decidim/meetings.rb +1 -0
  169. data/lib/decidim/meetings/admin_engine.rb +5 -1
  170. data/lib/decidim/meetings/api.rb +8 -0
  171. data/lib/decidim/meetings/component.rb +69 -14
  172. data/lib/decidim/meetings/engine.rb +3 -6
  173. data/lib/decidim/meetings/meeting_serializer.rb +1 -1
  174. data/lib/decidim/meetings/seeds/city.jpeg +0 -0
  175. data/lib/decidim/meetings/test/factories.rb +45 -8
  176. data/lib/decidim/meetings/version.rb +1 -1
  177. data/lib/tasks/decidim_meetings.rake +16 -0
  178. metadata +92 -20
  179. data/app/presenters/decidim/meetings/admin_log/value_types/organizer_presenter.rb +0 -70
  180. data/app/views/decidim/meetings/meeting_widgets/show.html.erb +0 -9
@@ -0,0 +1 @@
1
+ zh-TW:
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class IndexForeignKeysInDecidimMeetingsRegistrations < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_index :decidim_meetings_registrations, :decidim_user_group_id
6
+ end
7
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddAuthorToMeetings < ActiveRecord::Migration[5.2]
4
+ class Meeting < ApplicationRecord
5
+ self.table_name = :decidim_meetings_meetings
6
+ include Decidim::HasComponent
7
+ end
8
+
9
+ def change
10
+ add_column :decidim_meetings_meetings, :decidim_author_type, :string
11
+ add_column :decidim_meetings_meetings, :decidim_user_group_id, :integer
12
+
13
+ Meeting.reset_column_information
14
+ Meeting.find_each do |meeting|
15
+ if meeting.organizer_id.present?
16
+ meeting.decidim_author_id = meeting.organizer_id
17
+ meeting.decidim_author_type = "Decidim::UserBaseEntity"
18
+ else
19
+ meeting.decidim_author_id = meeting.organization.id
20
+ meeting.decidim_author_type = "Decidim::Organization"
21
+ end
22
+ meeting.save!
23
+ end
24
+
25
+ remove_column :decidim_meetings_meetings, :organizer_id
26
+ add_index :decidim_meetings_meetings,
27
+ [:decidim_author_id, :decidim_author_type],
28
+ name: "index_decidim_meetings_meetings_on_author"
29
+ end
30
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateMeetingServicesTable < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :decidim_meetings_services do |t|
6
+ t.jsonb :title
7
+ t.jsonb :description
8
+ t.bigint :decidim_meeting_id, null: false, index: true
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ class MoveMeetingServicesToOwnModel < ActiveRecord::Migration[5.2]
4
+ class Meeting < ApplicationRecord
5
+ self.table_name = :decidim_meetings_meetings
6
+ end
7
+
8
+ class Service < ApplicationRecord
9
+ self.table_name = :decidim_meetings_services
10
+ end
11
+
12
+ def change
13
+ Meeting.reset_column_information
14
+ Service.reset_column_information
15
+
16
+ Meeting.find_each do |meeting|
17
+ meeting["services"].each do |service|
18
+ Service.create!(
19
+ decidim_meeting_id: meeting.id,
20
+ title: service["title"],
21
+ description: service["description"]
22
+ )
23
+ end
24
+ end
25
+
26
+ remove_column :decidim_meetings_meetings, :services
27
+
28
+ Meeting.reset_column_information
29
+ Service.reset_column_information
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddCommentableCounterCacheToMeetings < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :decidim_meetings_meetings, :comments_count, :integer, null: false, default: 0
6
+ Decidim::Meetings::Meeting.reset_column_information
7
+ Decidim::Meetings::Meeting.find_each(&:update_comments_count)
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FixMeetingsRegistrationTerms < ActiveRecord::Migration[5.2]
4
+ def up
5
+ reset_column_information
6
+
7
+ PaperTrail.request(enabled: false) do
8
+ Decidim::Meetings::Meeting.find_each do |meeting|
9
+ next if meeting.component.nil?
10
+ # Only user-created meetings have this problem
11
+ next if meeting.official?
12
+
13
+ # Since user-created meetings have no way to override the `registration_terms` field
14
+ # and it's supposed to use the component defaults,
15
+ # we can safely override this.
16
+ meeting.registration_terms = meeting.component.settings.default_registration_terms
17
+ meeting.save!
18
+ end
19
+ end
20
+ reset_column_information
21
+ end
22
+
23
+ def down; end
24
+
25
+ def reset_column_information
26
+ Decidim::Meetings::Meeting.reset_column_information
27
+ Decidim::Component.reset_column_information
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ # This interface represents all linked resources available in the module meetings
6
+ LinkedResourcesInterface = GraphQL::InterfaceType.define do
7
+ name "MeetinsLinkedResourcewInterface"
8
+ description "An interface that can be used with Resourceable models."
9
+
10
+ field :proposalsFromMeeting, !types[Decidim::Proposals::ProposalType], "Proposals created in this meeting" do
11
+ resolve ->(meeting, _args, _ctx) {
12
+ meeting.linked_resources(:proposals, :proposals_from_meeting)
13
+ }
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ # This interface represents a categorizable object.
6
+ ServicesInterface = GraphQL::InterfaceType.define do
7
+ name "ServicesInterface"
8
+ description "An interface that can be used with services."
9
+
10
+ field :services, !types[ServiceType], "The object's services"
11
+ end
12
+ end
13
+ end
@@ -6,6 +6,7 @@ require "decidim/meetings/admin_engine"
6
6
  require "decidim/meetings/directory"
7
7
  require "decidim/meetings/directory_engine"
8
8
  require "decidim/meetings/component"
9
+ require "decidim/meetings/api"
9
10
 
10
11
  module Decidim
11
12
  # Base module for this engine.
@@ -12,8 +12,12 @@ module Decidim
12
12
  paths["lib/tasks"] = nil
13
13
 
14
14
  routes do
15
+ get "/answer_options", to: "registration_form#answer_options", as: :answer_options_meeting
16
+
15
17
  resources :meetings do
16
- resources :meeting_closes, only: [:edit, :update]
18
+ resources :meeting_closes, only: [:edit, :update] do
19
+ get :proposals_picker, on: :collection
20
+ end
17
21
  resource :registrations, only: [:edit, :update] do
18
22
  resources :invites, only: [:index, :create]
19
23
  resource :form, only: [:edit, :update], controller: "registration_form"
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ autoload :LinkedResourcesInterface, "decidim/api/linked_resources_interface"
6
+ autoload :ServicesInterface, "decidim/api/services_interface"
7
+ end
8
+ end
@@ -24,15 +24,19 @@ Decidim.register_component(:meetings) do |component|
24
24
  end
25
25
 
26
26
  component.register_stat :meetings_count, primary: true, priority: Decidim::StatsRegistry::MEDIUM_PRIORITY do |components, start_at, end_at|
27
- meetings = Decidim::Meetings::Meeting.where(component: components)
28
- meetings = meetings.where("created_at >= ?", start_at) if start_at.present?
29
- meetings = meetings.where("created_at <= ?", end_at) if end_at.present?
27
+ meetings = Decidim::Meetings::FilteredMeetings.for(components, start_at, end_at)
30
28
  meetings.count
31
29
  end
32
30
 
31
+ component.register_stat :followers_count, tag: :followers, priority: Decidim::StatsRegistry::LOW_PRIORITY do |components, start_at, end_at|
32
+ meetings_ids = Decidim::Meetings::FilteredMeetings.for(components, start_at, end_at).pluck(:id)
33
+ Decidim::Follow.where(decidim_followable_type: "Decidim::Meetings::Meeting", decidim_followable_id: meetings_ids).count
34
+ end
35
+
33
36
  component.exports :meetings do |exports|
34
37
  exports.collection do |component_instance|
35
38
  Decidim::Meetings::Meeting
39
+ .not_hidden
36
40
  .visible
37
41
  .where(component: component_instance)
38
42
  .includes(component: { participatory_space: :organization })
@@ -46,11 +50,15 @@ Decidim.register_component(:meetings) do |component|
46
50
  component.actions = %w(join)
47
51
 
48
52
  component.settings(:global) do |settings|
53
+ settings.attribute :scopes_enabled, type: :boolean, default: false
54
+ settings.attribute :scope_id, type: :scope
49
55
  settings.attribute :announcement, type: :text, translated: true, editor: true
50
56
  settings.attribute :default_registration_terms, type: :text, translated: true, editor: true
51
57
  settings.attribute :comments_enabled, type: :boolean, default: true
58
+ settings.attribute :comments_max_length, type: :integer, required: false
52
59
  settings.attribute :resources_permissions_enabled, type: :boolean, default: true
53
60
  settings.attribute :enable_pads_creation, type: :boolean, default: false
61
+ settings.attribute :creation_enabled_for_participants, type: :boolean, default: false
54
62
  end
55
63
 
56
64
  component.settings(:step) do |settings|
@@ -106,13 +114,10 @@ Decidim.register_component(:meetings) do |component|
106
114
  longitude: Faker::Address.longitude,
107
115
  registrations_enabled: [true, false].sample,
108
116
  available_slots: (10..50).step(10).to_a.sample,
117
+ author: participatory_space.organization,
109
118
  registration_terms: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
110
119
  Decidim::Faker::Localized.paragraph(3)
111
- end,
112
- services: [
113
- { title: Decidim::Faker::Localized.sentence(2), description: Decidim::Faker::Localized.sentence(5) },
114
- { title: Decidim::Faker::Localized.sentence(2), description: Decidim::Faker::Localized.sentence(5) }
115
- ]
120
+ end
116
121
  }
117
122
 
118
123
  meeting = Decidim.traceability.create!(
@@ -122,6 +127,14 @@ Decidim.register_component(:meetings) do |component|
122
127
  visibility: "all"
123
128
  )
124
129
 
130
+ 2.times do
131
+ Decidim::Meetings::Service.create!(
132
+ meeting: meeting,
133
+ title: Decidim::Faker::Localized.sentence(2),
134
+ description: Decidim::Faker::Localized.sentence(5)
135
+ )
136
+ end
137
+
125
138
  Decidim::Forms::Questionnaire.create!(
126
139
  title: Decidim::Faker::Localized.paragraph,
127
140
  description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
@@ -165,21 +178,63 @@ Decidim.register_component(:meetings) do |component|
165
178
  Decidim::Attachment.create!(
166
179
  title: Decidim::Faker::Localized.sentence(2),
167
180
  description: Decidim::Faker::Localized.sentence(5),
168
- file: File.new(File.join(__dir__, "seeds", "Exampledocument.pdf")),
169
181
  attachment_collection: attachment_collection,
170
- attached_to: meeting
182
+ attached_to: meeting,
183
+ file: File.new(File.join(__dir__, "seeds", "Exampledocument.pdf")) # Keep after attached_to
171
184
  )
172
185
  Decidim::Attachment.create!(
173
186
  title: Decidim::Faker::Localized.sentence(2),
174
187
  description: Decidim::Faker::Localized.sentence(5),
175
- file: File.new(File.join(__dir__, "seeds", "city.jpeg")),
176
- attached_to: meeting
188
+ attached_to: meeting,
189
+ file: File.new(File.join(__dir__, "seeds", "city.jpeg")) # Keep after attached_to
177
190
  )
178
191
  Decidim::Attachment.create!(
179
192
  title: Decidim::Faker::Localized.sentence(2),
180
193
  description: Decidim::Faker::Localized.sentence(5),
181
- file: File.new(File.join(__dir__, "seeds", "Exampledocument.pdf")),
182
- attached_to: meeting
194
+ attached_to: meeting,
195
+ file: File.new(File.join(__dir__, "seeds", "Exampledocument.pdf")) # Keep after attached_to
196
+ )
197
+ end
198
+
199
+ authors = [
200
+ Decidim::UserGroup.where(decidim_organization_id: participatory_space.decidim_organization_id).verified.sample,
201
+ Decidim::User.where(decidim_organization_id: participatory_space.decidim_organization_id).all.sample
202
+ ]
203
+
204
+ authors.each do |author|
205
+ user_group = nil
206
+
207
+ if author.is_a?(Decidim::UserGroup)
208
+ user_group = author
209
+ author = user_group.users.sample
210
+ end
211
+
212
+ params = {
213
+ component: component,
214
+ scope: Faker::Boolean.boolean(0.5) ? global : scopes.sample,
215
+ category: participatory_space.categories.sample,
216
+ title: Decidim::Faker::Localized.sentence(2),
217
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
218
+ Decidim::Faker::Localized.paragraph(3)
219
+ end,
220
+ location: Decidim::Faker::Localized.sentence,
221
+ location_hints: Decidim::Faker::Localized.sentence,
222
+ start_time: 3.weeks.from_now,
223
+ end_time: 3.weeks.from_now + 4.hours,
224
+ address: "#{Faker::Address.street_address} #{Faker::Address.zip} #{Faker::Address.city}",
225
+ latitude: Faker::Address.latitude,
226
+ longitude: Faker::Address.longitude,
227
+ registrations_enabled: [true, false].sample,
228
+ available_slots: (10..50).step(10).to_a.sample,
229
+ author: author,
230
+ user_group: user_group
231
+ }
232
+
233
+ Decidim.traceability.create!(
234
+ Decidim::Meetings::Meeting,
235
+ authors[0],
236
+ params,
237
+ visibility: "all"
183
238
  )
184
239
  end
185
240
  end
@@ -17,7 +17,7 @@ module Decidim
17
17
  isolate_namespace Decidim::Meetings
18
18
 
19
19
  routes do
20
- resources :meetings, only: [:index, :show] do
20
+ resources :meetings, only: [:index, :show, :new, :create, :edit, :update] do
21
21
  resource :registration, only: [:create, :destroy] do
22
22
  collection do
23
23
  get :create
@@ -26,7 +26,8 @@ module Decidim
26
26
  post :answer
27
27
  end
28
28
  end
29
- resource :meeting_widget, only: :show, path: "embed"
29
+ resources :versions, only: [:show, :index]
30
+ resource :widget, only: :show, path: "embed"
30
31
  end
31
32
  root to: "meetings#index"
32
33
  resource :calendar, only: [:show], format: :text
@@ -54,10 +55,6 @@ module Decidim
54
55
  end
55
56
  end
56
57
 
57
- Decidim.view_hooks.register(:current_participatory_space_meetings, priority: Decidim::ViewHooks::HIGH_PRIORITY) do |view_context|
58
- view_context.cell("decidim/meetings/highlighted_meetings", view_context.current_participatory_space)
59
- end
60
-
61
58
  # This view hook is used in card cells. It renders the next upcoming
62
59
  # meeting for the given participatory space.
63
60
  Decidim.view_hooks.register(:upcoming_meeting_for_card, priority: Decidim::ViewHooks::LOW_PRIORITY) do |view_context|
@@ -40,7 +40,7 @@ module Decidim
40
40
  address: meeting.address,
41
41
  location: meeting.location,
42
42
  reference: meeting.reference,
43
- comments: meeting.comments.count,
43
+ comments: meeting.comments_count,
44
44
  attachments: meeting.attachments.count,
45
45
  followers: meeting.followers.count,
46
46
  url: url,
@@ -10,6 +10,14 @@ FactoryBot.define do
10
10
  name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :meetings).i18n_name }
11
11
  manifest_name { :meetings }
12
12
  participatory_space { create(:participatory_process, :with_steps, organization: organization) }
13
+
14
+ trait :with_creation_enabled do
15
+ settings do
16
+ {
17
+ creation_enabled_for_participants: true
18
+ }
19
+ end
20
+ end
13
21
  end
14
22
 
15
23
  factory :meeting, class: "Decidim::Meetings::Meeting" do
@@ -24,18 +32,41 @@ FactoryBot.define do
24
32
  end_time { start_time.advance(hours: 2) }
25
33
  private_meeting { false }
26
34
  transparent { true }
27
- services do
28
- [
29
- { title: generate_localized_title, description: generate_localized_title },
30
- { title: generate_localized_title, description: generate_localized_title }
31
- ]
32
- end
33
35
  questionnaire { build(:questionnaire) }
34
36
  registration_form_enabled { true }
35
37
  component { build(:component, manifest_name: "meetings") }
36
38
 
37
- organizer do
38
- create(:user, organization: component.organization) if component
39
+ author do
40
+ component.try(:organization)
41
+ end
42
+
43
+ trait :official do
44
+ author { component.organization if component }
45
+ end
46
+
47
+ trait :not_official do
48
+ author { create(:user, organization: component.organization) if component }
49
+ end
50
+
51
+ trait :with_services do
52
+ transient do
53
+ services do
54
+ nil
55
+ end
56
+ end
57
+
58
+ after(:build) do |meeting, evaluator|
59
+ meeting.services = evaluator.services || build_list(:service, 2, meeting: meeting)
60
+ end
61
+ end
62
+
63
+ trait :user_group_author do
64
+ author do
65
+ create(:user, organization: component.organization) if component
66
+ end
67
+ user_group do
68
+ create(:user_group, :verified, organization: component.organization, users: [author]) if component
69
+ end
39
70
  end
40
71
 
41
72
  trait :closed do
@@ -121,4 +152,10 @@ FactoryBot.define do
121
152
  rejected_at { Time.current }
122
153
  end
123
154
  end
155
+
156
+ factory :service, class: "Decidim::Meetings::Service" do
157
+ meeting
158
+ title { generate_localized_title }
159
+ description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
160
+ end
124
161
  end