Class: Decidim::Meetings::Meeting
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Meetings::Meeting
- Includes:
- Comments::Commentable, Followable, HasAttachmentCollections, HasAttachments, HasCategory, HasComponent, HasReference, Loggable, Resourceable, ScopableComponent, Searchable, Traceable
- 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.
Class Method Summary collapse
Instance Method Summary collapse
-
#accepts_new_comments? ⇒ Boolean
Public: Overrides the ‘accepts_new_comments?` Commentable concern method.
-
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
- #can_be_joined_by?(user) ⇒ Boolean
-
#can_participate?(user) ⇒ Boolean
rubocop:disable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity.
- #closed? ⇒ Boolean
-
#commentable? ⇒ Boolean
Public: Overrides the ‘commentable?` Commentable concern method.
-
#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?(current_user) ⇒ Boolean
- #has_available_slots? ⇒ Boolean
- #has_registration_for?(user) ⇒ Boolean
-
#meeting_duration ⇒ Object
Return the duration of the meeting in minutes.
- #official? ⇒ Boolean
-
#organizer_belongs_to_organization ⇒ Object
rubocop:enable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity.
- #remaining_slots ⇒ Object
- #resource_visible? ⇒ Boolean
-
#users_to_notify_on_comment_created ⇒ Object
Public: Override Commentable concern method ‘users_to_notify_on_comment_created`.
Class Method Details
.log_presenter_class_for(_log) ⇒ Object
54 55 56 |
# File 'app/models/decidim/meetings/meeting.rb', line 54 def self.log_presenter_class_for(_log) Decidim::Meetings::AdminLog::MeetingPresenter end |
Instance Method Details
#accepts_new_comments? ⇒ Boolean
Public: Overrides the ‘accepts_new_comments?` Commentable concern method.
85 86 87 |
# File 'app/models/decidim/meetings/meeting.rb', line 85 def accepts_new_comments? commentable? && !component.current_settings.comments_blocked end |
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
90 91 92 |
# File 'app/models/decidim/meetings/meeting.rb', line 90 def component.settings. end |
#can_be_joined_by?(user) ⇒ Boolean
58 59 60 |
# File 'app/models/decidim/meetings/meeting.rb', line 58 def can_be_joined_by?(user) !closed? && registrations_enabled? && can_participate?(user) end |
#can_participate?(user) ⇒ Boolean
rubocop:disable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity
110 111 112 113 114 115 116 117 118 |
# File 'app/models/decidim/meetings/meeting.rb', line 110 def can_participate?(user) return true unless participatory_space.try(:private_space?) || private_meeting? return true if (participatory_space.try(:private_space?) && participatory_space.users.include?(user)) || (private_meeting? && registrations.exists?(decidim_user_id: user.try(:id))) return false if (participatory_space.try(:private_space?) && participatory_space.try(:transparent?)) || (private_meeting? && transparent?) end |
#closed? ⇒ Boolean
62 63 64 |
# File 'app/models/decidim/meetings/meeting.rb', line 62 def closed? closed_at.present? end |
#commentable? ⇒ Boolean
Public: Overrides the ‘commentable?` Commentable concern method.
80 81 82 |
# File 'app/models/decidim/meetings/meeting.rb', line 80 def commentable? component.settings.comments_enabled? end |
#comments_have_alignment? ⇒ Boolean
Public: Overrides the ‘comments_have_alignment?` Commentable concern method.
95 96 97 |
# File 'app/models/decidim/meetings/meeting.rb', line 95 def comments_have_alignment? true end |
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
100 101 102 |
# File 'app/models/decidim/meetings/meeting.rb', line 100 def comments_have_votes? true end |
#current_user_can_visit_meeting?(current_user) ⇒ Boolean
130 131 132 133 |
# File 'app/models/decidim/meetings/meeting.rb', line 130 def current_user_can_visit_meeting?(current_user) (private_meeting? && registrations.exists?(decidim_user_id: current_user.try(:id))) || !private_meeting? || (private_meeting? && transparent?) end |
#has_available_slots? ⇒ Boolean
66 67 68 69 |
# File 'app/models/decidim/meetings/meeting.rb', line 66 def has_available_slots? return true if available_slots.zero? (available_slots - reserved_slots) > registrations.count end |
#has_registration_for?(user) ⇒ Boolean
75 76 77 |
# File 'app/models/decidim/meetings/meeting.rb', line 75 def has_registration_for?(user) registrations.where(user: user).any? end |
#meeting_duration ⇒ Object
Return the duration of the meeting in minutes
136 137 138 |
# File 'app/models/decidim/meetings/meeting.rb', line 136 def meeting_duration @meeting_duration ||= ((end_time - start_time) / 1.minute).abs end |
#official? ⇒ Boolean
126 127 128 |
# File 'app/models/decidim/meetings/meeting.rb', line 126 def official? organizer.nil? end |
#organizer_belongs_to_organization ⇒ Object
rubocop:enable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity
121 122 123 124 |
# File 'app/models/decidim/meetings/meeting.rb', line 121 def organizer_belongs_to_organization return if !organizer || !organization errors.add(:organizer, :invalid) unless organizer.organization == organization end |
#remaining_slots ⇒ Object
71 72 73 |
# File 'app/models/decidim/meetings/meeting.rb', line 71 def remaining_slots available_slots - reserved_slots - registrations.count end |
#resource_visible? ⇒ Boolean
140 141 142 |
# File 'app/models/decidim/meetings/meeting.rb', line 140 def resource_visible? !private_meeting? || transparent? end |
#users_to_notify_on_comment_created ⇒ Object
Public: Override Commentable concern method ‘users_to_notify_on_comment_created`
105 106 107 |
# File 'app/models/decidim/meetings/meeting.rb', line 105 def users_to_notify_on_comment_created followers end |