Class: Decidim::Meetings::Meeting
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Meetings::Meeting
- Includes:
- ActsAsAuthor, Authorable, Comments::CommentableWithComponent, Comments::HasAvailabilityAttributes, DownloadYourData, FilterableResource, Followable, Forms::HasQuestionnaire, HasAttachmentCollections, HasAttachments, HasCategory, HasComponent, HasReference, Loggable, Paddable, Publicable, Reportable, Resourceable, ScopableResource, Searchable, SoftDeletable, Taxonomizable, Traceable, TranslatableResource
- Defined in:
- 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
- .export_serializer ⇒ Object
- .log_presenter_class_for(_log) ⇒ Object
- .participants_iframe_embed_types ⇒ Object
- .ransack(params = {}, options = {}) ⇒ Object
- .ransackable_associations(_auth_object = nil) ⇒ Object
- .ransackable_attributes(auth_object = nil) ⇒ Object
- .ransackable_scopes(_auth_object = nil) ⇒ Object
- .sort_by_translated_title_asc ⇒ Object
- .sort_by_translated_title_desc ⇒ Object
Instance Method Summary collapse
-
#accepts_new_comments? ⇒ Boolean
Public: Overrides the ‘accepts_new_comments?` CommentableWithComponent concern method.
-
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
- #authored_proposals ⇒ Object
- #can_be_joined_by?(user) ⇒ Boolean
- #can_participate?(user) ⇒ Boolean
- #can_register_invitation?(user) ⇒ Boolean
- #closed? ⇒ Boolean
-
#comments_have_alignment? ⇒ Boolean
Public: Overrides the ‘comments_have_alignment?` Commentable concern method.
-
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
- #current_user_can_visit_meeting?(user) ⇒ Boolean
- #emendation? ⇒ Boolean
- #has_attendees? ⇒ Boolean
- #has_available_slots? ⇒ Boolean
- #has_contributions? ⇒ Boolean
- #has_registration_for?(user) ⇒ Boolean
- #iframe_access_level_allowed_for_user?(user) ⇒ Boolean
- #live? ⇒ Boolean
- #maps_enabled? ⇒ Boolean
-
#meeting_duration ⇒ Object
Return the duration of the meeting in minutes.
-
#pad_is_visible? ⇒ Boolean
Overwrites method from Paddable to add custom rules in order to know when to display a pad or not.
-
#pad_is_writable? ⇒ Boolean
Overwrites method from Paddable to add custom rules in order to know when a pad is writable or not.
- #past? ⇒ Boolean
-
#presenter ⇒ Object
Returns the presenter for this author, to be used in the views.
- #remaining_slots ⇒ Object
-
#reported_attributes ⇒ Object
Public: Overrides the ‘reported_attributes` Reportable concern method.
-
#reported_content_url ⇒ Object
Public: Overrides the ‘reported_content_url` Reportable concern method.
-
#reported_searchable_content_extras ⇒ Object
Public: Overrides the ‘reported_searchable_content_extras` Reportable concern method.
- #resource_visible? ⇒ Boolean
- #started? ⇒ Boolean
-
#user_group_registrations ⇒ Object
Return registrations of a particular meeting made by users representing a group.
-
#users_to_notify_on_comment_created ⇒ Object
Public: Override Commentable concern method ‘users_to_notify_on_comment_created`.
- #withdraw! ⇒ Object
-
#withdrawable_by?(user) ⇒ Boolean
Checks whether the user can withdraw the given meeting.
-
#withdrawn? ⇒ Boolean
Public: Checks if the author has withdrawn the meeting.
Class Method Details
.export_serializer ⇒ Object
160 161 162 |
# File 'app/models/decidim/meetings/meeting.rb', line 160 def self.export_serializer Decidim::Meetings::DownloadYourDataMeetingSerializer end |
.log_presenter_class_for(_log) ⇒ Object
179 180 181 |
# File 'app/models/decidim/meetings/meeting.rb', line 179 def self.log_presenter_class_for(_log) Decidim::Meetings::AdminLog::MeetingPresenter end |
.participants_iframe_embed_types ⇒ Object
164 165 166 |
# File 'app/models/decidim/meetings/meeting.rb', line 164 def self. .except(:open_in_live_event_page) end |
.ransack(params = {}, options = {}) ⇒ Object
398 399 400 |
# File 'app/models/decidim/meetings/meeting.rb', line 398 def self.ransack(params = {}, = {}) MeetingSearch.new(self, params, ) end |
.ransackable_associations(_auth_object = nil) ⇒ Object
394 395 396 |
# File 'app/models/decidim/meetings/meeting.rb', line 394 def self.ransackable_associations(_auth_object = nil) %w(taxonomies) end |
.ransackable_attributes(auth_object = nil) ⇒ Object
386 387 388 389 390 391 392 |
# File 'app/models/decidim/meetings/meeting.rb', line 386 def self.ransackable_attributes(auth_object = nil) base = %w(description id_string search_text title) return base unless auth_object&.admin? base + %w(is_upcoming closed_at) end |
.ransackable_scopes(_auth_object = nil) ⇒ Object
382 383 384 |
# File 'app/models/decidim/meetings/meeting.rb', line 382 def self.ransackable_scopes(_auth_object = nil) [:with_any_type, :with_any_date, :with_any_space, :with_any_origin, :with_any_taxonomies, :with_any_global_category] end |
.sort_by_translated_title_asc ⇒ Object
360 361 362 363 |
# File 'app/models/decidim/meetings/meeting.rb', line 360 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
365 366 367 368 |
# File 'app/models/decidim/meetings/meeting.rb', line 365 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
#accepts_new_comments? ⇒ Boolean
Public: Overrides the ‘accepts_new_comments?` CommentableWithComponent concern method.
227 228 229 |
# File 'app/models/decidim/meetings/meeting.rb', line 227 def accepts_new_comments? commentable? && !component.current_settings.comments_blocked && comments_allowed? end |
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
232 233 234 |
# File 'app/models/decidim/meetings/meeting.rb', line 232 def component.settings. end |
#authored_proposals ⇒ Object
317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'app/models/decidim/meetings/meeting.rb', line 317 def 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
183 184 185 |
# File 'app/models/decidim/meetings/meeting.rb', line 183 def can_be_joined_by?(user) !started? && registrations_enabled? && can_participate?(user) end |
#can_participate?(user) ⇒ Boolean
251 252 253 |
# File 'app/models/decidim/meetings/meeting.rb', line 251 def can_participate?(user) can_participate_in_space?(user) && can_participate_in_meeting?(user) end |
#can_register_invitation?(user) ⇒ Boolean
187 188 189 190 |
# File 'app/models/decidim/meetings/meeting.rb', line 187 def can_register_invitation?(user) !closed? && registrations_enabled? && can_participate_in_space?(user) && user_has_invitation_for_meeting?(user) end |
#closed? ⇒ Boolean
192 193 194 |
# File 'app/models/decidim/meetings/meeting.rb', line 192 def closed? closed_at.present? end |
#comments_have_alignment? ⇒ Boolean
Public: Overrides the ‘comments_have_alignment?` Commentable concern method.
237 238 239 |
# File 'app/models/decidim/meetings/meeting.rb', line 237 def comments_have_alignment? true end |
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
242 243 244 |
# File 'app/models/decidim/meetings/meeting.rb', line 242 def comments_have_votes? true end |
#current_user_can_visit_meeting?(user) ⇒ Boolean
255 256 257 |
# File 'app/models/decidim/meetings/meeting.rb', line 255 def current_user_can_visit_meeting?(user) Decidim::Meetings::Meeting.visible_for(user).exists?(id:) end |
#emendation? ⇒ Boolean
204 205 206 |
# File 'app/models/decidim/meetings/meeting.rb', line 204 def emendation? false end |
#has_attendees? ⇒ Boolean
349 350 351 |
# File 'app/models/decidim/meetings/meeting.rb', line 349 def has_attendees? !!attendees_count && attendees_count.positive? end |
#has_available_slots? ⇒ Boolean
208 209 210 211 212 |
# File 'app/models/decidim/meetings/meeting.rb', line 208 def has_available_slots? return true if available_slots.zero? (available_slots - reserved_slots) > registrations.count end |
#has_contributions? ⇒ Boolean
345 346 347 |
# File 'app/models/decidim/meetings/meeting.rb', line 345 def has_contributions? !!contributions_count && contributions_count.positive? end |
#has_registration_for?(user) ⇒ Boolean
218 219 220 |
# File 'app/models/decidim/meetings/meeting.rb', line 218 def has_registration_for?(user) registrations.where(user:).any? end |
#iframe_access_level_allowed_for_user?(user) ⇒ Boolean
259 260 261 262 263 264 265 266 267 268 |
# File 'app/models/decidim/meetings/meeting.rb', line 259 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
353 354 355 356 357 358 |
# File 'app/models/decidim/meetings/meeting.rb', line 353 def live? start_time && end_time && Time.current >= (start_time - 10.minutes) && Time.current <= end_time end |
#maps_enabled? ⇒ Boolean
222 223 224 |
# File 'app/models/decidim/meetings/meeting.rb', line 222 def maps_enabled? component.settings.maps_enabled? end |
#meeting_duration ⇒ Object
Return the duration of the meeting in minutes
271 272 273 |
# File 'app/models/decidim/meetings/meeting.rb', line 271 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.
303 304 305 306 307 |
# File 'app/models/decidim/meetings/meeting.rb', line 303 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.
311 312 313 314 315 |
# File 'app/models/decidim/meetings/meeting.rb', line 311 def pad_is_writable? return false unless pad_is_visible? (Time.current - end_time) < 72.hours end |
#past? ⇒ Boolean
200 201 202 |
# File 'app/models/decidim/meetings/meeting.rb', line 200 def past? end_time < Time.current end |
#presenter ⇒ Object
Returns the presenter for this author, to be used in the views. Required by ActsAsAuthor.
175 176 177 |
# File 'app/models/decidim/meetings/meeting.rb', line 175 def presenter Decidim::Meetings::MeetingPresenter.new(self) end |
#remaining_slots ⇒ Object
214 215 216 |
# File 'app/models/decidim/meetings/meeting.rb', line 214 def remaining_slots available_slots - reserved_slots - registrations.count end |
#reported_attributes ⇒ Object
Public: Overrides the ‘reported_attributes` Reportable concern method.
336 337 338 |
# File 'app/models/decidim/meetings/meeting.rb', line 336 def reported_attributes [:description] end |
#reported_content_url ⇒ Object
Public: Overrides the ‘reported_content_url` Reportable concern method.
331 332 333 |
# File 'app/models/decidim/meetings/meeting.rb', line 331 def reported_content_url ResourceLocatorPresenter.new(self).url end |
#reported_searchable_content_extras ⇒ Object
Public: Overrides the ‘reported_searchable_content_extras` Reportable concern method.
341 342 343 |
# File 'app/models/decidim/meetings/meeting.rb', line 341 def reported_searchable_content_extras [] end |
#resource_visible? ⇒ Boolean
275 276 277 278 279 |
# File 'app/models/decidim/meetings/meeting.rb', line 275 def resource_visible? return false if hidden? !private_meeting? || transparent? end |
#started? ⇒ Boolean
196 197 198 |
# File 'app/models/decidim/meetings/meeting.rb', line 196 def started? start_time < Time.current end |
#user_group_registrations ⇒ Object
Return registrations of a particular meeting made by users representing a group
169 170 171 |
# File 'app/models/decidim/meetings/meeting.rb', line 169 def user_group_registrations registrations.where.not(decidim_user_group_id: nil) end |
#users_to_notify_on_comment_created ⇒ Object
Public: Override Commentable concern method ‘users_to_notify_on_comment_created`
247 248 249 |
# File 'app/models/decidim/meetings/meeting.rb', line 247 def users_to_notify_on_comment_created followers end |
#withdraw! ⇒ Object
296 297 298 299 |
# File 'app/models/decidim/meetings/meeting.rb', line 296 def withdraw! self.withdrawn_at = Time.zone.now save 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
292 293 294 |
# File 'app/models/decidim/meetings/meeting.rb', line 292 def withdrawable_by?(user) user && !withdrawn? && !past? && (user) end |
#withdrawn? ⇒ Boolean
Public: Checks if the author has withdrawn the meeting.
Returns Boolean.
284 285 286 |
# File 'app/models/decidim/meetings/meeting.rb', line 284 def withdrawn? withdrawn_at.present? end |