Class: Decidim::Meetings::Meeting
- Inherits:
-
ApplicationRecord
show all
- Includes:
- ActsAsAuthor, Authorable, Comments::CommentableWithComponent, Comments::HasAvailabilityAttributes, FilterableResource, Followable, Forms::HasQuestionnaire, HasAttachmentCollections, HasAttachments, HasCategory, HasComponent, HasReference, Loggable, Paddable, Publicable, Reportable, Resourceable, ScopableResource, Searchable, Traceable, TranslatableResource
- Defined in:
- decidim-meetings/app/models/decidim/meetings/meeting.rb
Overview
The data store for a Meeting in the Decidim::Meetings component. It stores a title, description and any other useful information to render a custom meeting.
Constant Summary
collapse
- TYPE_OF_MEETING =
{ in_person: 0, online: 10, hybrid: 20 }.freeze
- REGISTRATION_TYPES =
{ registration_disabled: 0, on_this_platform: 10, on_different_platform: 20 }.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Publicable
#previously_published?, #publish!, #published?, #unpublish!
Methods included from Searchable
searchable_resources, searchable_resources_by_type, searchable_resources_of_type_comment, searchable_resources_of_type_component, searchable_resources_of_type_participant, searchable_resources_of_type_participatory_space
Methods included from Followable
#followers
#attachment_context
Class Method Details
.log_presenter_class_for(_log) ⇒ Object
.participants_iframe_embed_types ⇒ Object
153
154
155
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 153
def self.participants_iframe_embed_types
iframe_embed_types.except(:open_in_live_event_page)
end
|
.ransack(params = {}, options = {}) ⇒ Object
366
367
368
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 366
def self.ransack(params = {}, options = {})
MeetingSearch.new(self, params, options)
end
|
.ransackable_scopes(_auth_object = nil) ⇒ Object
362
363
364
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 362
def self.ransackable_scopes(_auth_object = nil)
[:with_any_type, :with_any_date, :with_any_space, :with_any_origin, :with_any_scope, :with_any_category, :with_any_global_category]
end
|
.sort_by_translated_title_asc ⇒ Object
340
341
342
343
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 340
def self.sort_by_translated_title_asc
field = Arel::Nodes::InfixOperation.new("->>", arel_table[:title], Arel::Nodes.build_quoted(I18n.locale))
order(Arel::Nodes::InfixOperation.new("", field, Arel.sql("ASC")))
end
|
.sort_by_translated_title_desc ⇒ Object
345
346
347
348
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 345
def self.sort_by_translated_title_desc
field = Arel::Nodes::InfixOperation.new("->>", arel_table[:title], Arel::Nodes.build_quoted(I18n.locale))
order(Arel::Nodes::InfixOperation.new("", field, Arel.sql("DESC")))
end
|
Instance Method Details
Public: Overrides the ‘accepts_new_comments?` CommentableWithComponent concern method.
212
213
214
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 212
def
&& !component.current_settings. &&
end
|
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
217
218
219
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 217
def allow_resource_permissions?
component.settings.resources_permissions_enabled
end
|
#authored_proposals ⇒ Object
297
298
299
300
301
302
303
304
305
306
307
308
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 297
def authored_proposals
return [] unless Decidim::Meetings.enable_proposal_linking
Decidim::Proposals::Proposal
.joins(:coauthorships)
.where(
decidim_coauthorships: {
decidim_author_type: "Decidim::Meetings::Meeting",
decidim_author_id: id
}
)
end
|
#can_be_joined_by?(user) ⇒ Boolean
172
173
174
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 172
def can_be_joined_by?(user)
!closed? && registrations_enabled? && can_participate?(user)
end
|
#can_participate?(user) ⇒ Boolean
236
237
238
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 236
def can_participate?(user)
can_participate_in_space?(user) && can_participate_in_meeting?(user)
end
|
#can_register_invitation?(user) ⇒ Boolean
176
177
178
179
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 176
def can_register_invitation?(user)
!closed? && registrations_enabled? &&
can_participate_in_space?(user) && user_has_invitation_for_meeting?(user)
end
|
#closed? ⇒ Boolean
181
182
183
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 181
def closed?
closed_at.present?
end
|
Public: Overrides the ‘comments_have_alignment?` Commentable concern method.
222
223
224
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 222
def
true
end
|
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
227
228
229
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 227
def
true
end
|
#current_user_can_visit_meeting?(user) ⇒ Boolean
240
241
242
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 240
def current_user_can_visit_meeting?(user)
Decidim::Meetings::Meeting.visible_for(user).exists?(id:)
end
|
#emendation? ⇒ Boolean
189
190
191
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 189
def emendation?
false
end
|
#has_attendees? ⇒ Boolean
329
330
331
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 329
def has_attendees?
!!attendees_count && attendees_count.positive?
end
|
#has_available_slots? ⇒ Boolean
193
194
195
196
197
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 193
def has_available_slots?
return true if available_slots.zero?
(available_slots - reserved_slots) > registrations.count
end
|
#has_contributions? ⇒ Boolean
325
326
327
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 325
def has_contributions?
!!contributions_count && contributions_count.positive?
end
|
#has_registration_for?(user) ⇒ Boolean
203
204
205
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 203
def has_registration_for?(user)
registrations.where(user:).any?
end
|
#iframe_access_level_allowed_for_user?(user) ⇒ Boolean
244
245
246
247
248
249
250
251
252
253
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 244
def iframe_access_level_allowed_for_user?(user)
case iframe_access_level
when "all"
true
when "signed_in"
user.present?
else
has_registration_for?(user)
end
end
|
#live? ⇒ Boolean
333
334
335
336
337
338
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 333
def live?
start_time &&
end_time &&
Time.current >= (start_time - 10.minutes) &&
Time.current <= end_time
end
|
#maps_enabled? ⇒ Boolean
207
208
209
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 207
def maps_enabled?
component.settings.maps_enabled?
end
|
#meeting_duration ⇒ Object
Return the duration of the meeting in minutes
256
257
258
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 256
def meeting_duration
@meeting_duration ||= ((end_time - start_time) / 1.minute).abs
end
|
#pad_is_visible? ⇒ Boolean
Overwrites method from Paddable to add custom rules in order to know when to display a pad or not.
283
284
285
286
287
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 283
def pad_is_visible?
return false unless pad
(start_time - Time.current) <= 24.hours
end
|
#pad_is_writable? ⇒ Boolean
Overwrites method from Paddable to add custom rules in order to know when a pad is writable or not.
291
292
293
294
295
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 291
def pad_is_writable?
return false unless pad_is_visible?
(Time.current - end_time) < 72.hours
end
|
#past? ⇒ Boolean
185
186
187
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 185
def past?
end_time < Time.current
end
|
#presenter ⇒ Object
Returns the presenter for this author, to be used in the views. Required by ActsAsAuthor.
#remaining_slots ⇒ Object
199
200
201
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 199
def remaining_slots
available_slots - reserved_slots - registrations.count
end
|
#reported_attributes ⇒ Object
Public: Overrides the ‘reported_attributes` Reportable concern method.
316
317
318
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 316
def reported_attributes
[:description]
end
|
#reported_content_url ⇒ Object
Public: Overrides the ‘reported_content_url` Reportable concern method.
311
312
313
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 311
def reported_content_url
ResourceLocatorPresenter.new(self).url
end
|
Public: Overrides the ‘reported_searchable_content_extras` Reportable concern method.
321
322
323
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 321
def
[normalized_author.name]
end
|
#resource_visible? ⇒ Boolean
260
261
262
263
264
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 260
def resource_visible?
return false if hidden?
!private_meeting? || transparent?
end
|
#user_group_registrations ⇒ Object
Return registrations of a particular meeting made by users representing a group
158
159
160
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 158
def user_group_registrations
registrations.where.not(decidim_user_group_id: nil)
end
|
Public: Override Commentable concern method ‘users_to_notify_on_comment_created`
232
233
234
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 232
def
followers
end
|
#withdrawable_by?(user) ⇒ Boolean
Checks whether the user can withdraw the given meeting.
user - the user to check for withdrawability. past meetings cannot be withdrawn
277
278
279
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 277
def withdrawable_by?(user)
user && !withdrawn? && !past? && authored_by?(user)
end
|
#withdrawn? ⇒ Boolean
Public: Checks if the author has withdrawn the meeting.
Returns Boolean.
269
270
271
|
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 269
def withdrawn?
state == "withdrawn"
end
|