Class: Decidim::Meetings::Meeting
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Meetings::Meeting
- Includes:
- ActsAsAuthor, Authorable, Comments::Commentable, Followable, Forms::HasQuestionnaire, HasAttachmentCollections, HasAttachments, HasCategory, HasComponent, HasReference, Loggable, Paddable, Reportable, Resourceable, ScopableResource, Searchable, 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.
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.
- #authored_proposals ⇒ Object
- #can_be_joined_by?(user) ⇒ Boolean
- #can_participate?(user) ⇒ Boolean
- #can_register_invitation?(user) ⇒ Boolean
- #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?(user) ⇒ Boolean
- #has_available_slots? ⇒ Boolean
- #has_registration_for?(user) ⇒ 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.
-
#presenter ⇒ Object
Returns the presenter for this author, to be used in the views.
- #remaining_slots ⇒ Object
-
#reported_content_url ⇒ Object
Public: Overrides the ‘reported_content_url` Reportable concern method.
- #resource_visible? ⇒ Boolean
-
#user_allowed_to_comment?(user) ⇒ Boolean
Public: Whether the object can have new comments or not.
-
#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`.
Class Method Details
.log_presenter_class_for(_log) ⇒ Object
106 107 108 |
# File 'app/models/decidim/meetings/meeting.rb', line 106 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.
143 144 145 |
# File 'app/models/decidim/meetings/meeting.rb', line 143 def accepts_new_comments? commentable? && !component.current_settings.comments_blocked end |
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
148 149 150 |
# File 'app/models/decidim/meetings/meeting.rb', line 148 def component.settings. end |
#authored_proposals ⇒ Object
205 206 207 208 209 210 211 212 213 214 |
# File 'app/models/decidim/meetings/meeting.rb', line 205 def 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
110 111 112 |
# File 'app/models/decidim/meetings/meeting.rb', line 110 def can_be_joined_by?(user) !closed? && registrations_enabled? && can_participate?(user) end |
#can_participate?(user) ⇒ Boolean
172 173 174 |
# File 'app/models/decidim/meetings/meeting.rb', line 172 def can_participate?(user) can_participate_in_space?(user) && can_participate_in_meeting?(user) end |
#can_register_invitation?(user) ⇒ Boolean
114 115 116 117 |
# File 'app/models/decidim/meetings/meeting.rb', line 114 def can_register_invitation?(user) !closed? && registrations_enabled? && can_participate_in_space?(user) && user_has_invitation_for_meeting?(user) end |
#closed? ⇒ Boolean
119 120 121 |
# File 'app/models/decidim/meetings/meeting.rb', line 119 def closed? closed_at.present? end |
#commentable? ⇒ Boolean
Public: Overrides the ‘commentable?` Commentable concern method.
138 139 140 |
# File 'app/models/decidim/meetings/meeting.rb', line 138 def commentable? component.settings.comments_enabled? end |
#comments_have_alignment? ⇒ Boolean
Public: Overrides the ‘comments_have_alignment?` Commentable concern method.
153 154 155 |
# File 'app/models/decidim/meetings/meeting.rb', line 153 def comments_have_alignment? true end |
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
158 159 160 |
# File 'app/models/decidim/meetings/meeting.rb', line 158 def comments_have_votes? true end |
#current_user_can_visit_meeting?(user) ⇒ Boolean
176 177 178 |
# File 'app/models/decidim/meetings/meeting.rb', line 176 def current_user_can_visit_meeting?(user) Decidim::Meetings::Meeting.visible_meeting_for(user).find_by(id: id) end |
#has_available_slots? ⇒ Boolean
123 124 125 126 127 |
# File 'app/models/decidim/meetings/meeting.rb', line 123 def has_available_slots? return true if available_slots.zero? (available_slots - reserved_slots) > registrations.count end |
#has_registration_for?(user) ⇒ Boolean
133 134 135 |
# File 'app/models/decidim/meetings/meeting.rb', line 133 def has_registration_for?(user) registrations.where(user: user).any? end |
#meeting_duration ⇒ Object
Return the duration of the meeting in minutes
181 182 183 |
# File 'app/models/decidim/meetings/meeting.rb', line 181 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.
191 192 193 194 195 |
# File 'app/models/decidim/meetings/meeting.rb', line 191 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.
199 200 201 202 203 |
# File 'app/models/decidim/meetings/meeting.rb', line 199 def pad_is_writable? return false unless pad_is_visible? (Time.current - end_time) < 72.hours end |
#presenter ⇒ Object
Returns the presenter for this author, to be used in the views. Required by ActsAsAuthor.
102 103 104 |
# File 'app/models/decidim/meetings/meeting.rb', line 102 def presenter Decidim::Meetings::MeetingPresenter.new(self) end |
#remaining_slots ⇒ Object
129 130 131 |
# File 'app/models/decidim/meetings/meeting.rb', line 129 def remaining_slots available_slots - reserved_slots - registrations.count end |
#reported_content_url ⇒ Object
Public: Overrides the ‘reported_content_url` Reportable concern method.
217 218 219 |
# File 'app/models/decidim/meetings/meeting.rb', line 217 def reported_content_url ResourceLocatorPresenter.new(self).url end |
#resource_visible? ⇒ Boolean
185 186 187 |
# File 'app/models/decidim/meetings/meeting.rb', line 185 def resource_visible? !private_meeting? || transparent? end |
#user_allowed_to_comment?(user) ⇒ Boolean
Public: Whether the object can have new comments or not.
168 169 170 |
# File 'app/models/decidim/meetings/meeting.rb', line 168 def user_allowed_to_comment?(user) can_participate?(user) end |
#user_group_registrations ⇒ Object
Return registrations of a particular meeting made by users representing a group
96 97 98 |
# File 'app/models/decidim/meetings/meeting.rb', line 96 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`
163 164 165 |
# File 'app/models/decidim/meetings/meeting.rb', line 163 def users_to_notify_on_comment_created followers end |