Class: Decidim::Meetings::Meeting

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.

Direct Known Subclasses

ConferenceMeeting

Constant Summary collapse

TYPE_OF_MEETING =
%w(in_person online hybrid).freeze
REGISTRATION_TYPE =
%w(registration_disabled on_this_platform on_different_platform).freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Publicable

#publish!, #published?, #unpublish!

Methods included from Searchable

searchable_resources, 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

Methods included from HasAttachments

#attachment_context

Class Method Details

.log_presenter_class_for(_log) ⇒ Object


134
135
136
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 134

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.

Returns:

  • (Boolean)

179
180
181
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 179

def accepts_new_comments?
  commentable? && !component.current_settings.comments_blocked
end

#allow_resource_permissions?Boolean

Public: Overrides the `allow_resource_permissions?` Resourceable concern method.

Returns:

  • (Boolean)

184
185
186
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 184

def allow_resource_permissions?
  component.settings.resources_permissions_enabled
end

#authored_proposalsObject


243
244
245
246
247
248
249
250
251
252
253
254
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 243

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

Returns:

  • (Boolean)

138
139
140
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 138

def can_be_joined_by?(user)
  !closed? && registrations_enabled? && can_participate?(user)
end

#can_participate?(user) ⇒ Boolean

Returns:

  • (Boolean)

208
209
210
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 208

def can_participate?(user)
  can_participate_in_space?(user) && can_participate_in_meeting?(user)
end

#can_register_invitation?(user) ⇒ Boolean

Returns:

  • (Boolean)

142
143
144
145
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 142

def can_register_invitation?(user)
  !closed? && registrations_enabled? &&
    can_participate_in_space?(user) && user_has_invitation_for_meeting?(user)
end

#closed?Boolean

Returns:

  • (Boolean)

147
148
149
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 147

def closed?
  closed_at.present?
end

#commentable?Boolean

Public: Overrides the `commentable?` Commentable concern method.

Returns:

  • (Boolean)

174
175
176
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 174

def commentable?
  component.settings.comments_enabled?
end

#comments_have_alignment?Boolean

Public: Overrides the `comments_have_alignment?` Commentable concern method.

Returns:

  • (Boolean)

189
190
191
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 189

def comments_have_alignment?
  true
end

#comments_have_votes?Boolean

Public: Overrides the `comments_have_votes?` Commentable concern method.

Returns:

  • (Boolean)

194
195
196
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 194

def comments_have_votes?
  true
end

#current_user_can_visit_meeting?(user) ⇒ Boolean

Returns:

  • (Boolean)

212
213
214
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 212

def current_user_can_visit_meeting?(user)
  Decidim::Meetings::Meeting.visible_meeting_for(user).exists?(id: id)
end

#has_attendees?Boolean

Returns:

  • (Boolean)

293
294
295
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 293

def has_attendees?
  !!attendees_count && attendees_count.positive?
end

#has_available_slots?Boolean

Returns:

  • (Boolean)

155
156
157
158
159
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 155

def has_available_slots?
  return true if available_slots.zero?

  (available_slots - reserved_slots) > registrations.count
end

#has_contributions?Boolean

Returns:

  • (Boolean)

289
290
291
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 289

def has_contributions?
  !!contributions_count && contributions_count.positive?
end

#has_registration_for?(user) ⇒ Boolean

Returns:

  • (Boolean)

165
166
167
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 165

def has_registration_for?(user)
  registrations.where(user: user).any?
end

#maps_enabled?Boolean

Returns:

  • (Boolean)

169
170
171
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 169

def maps_enabled?
  component.settings.maps_enabled?
end

#meeting_durationObject

Return the duration of the meeting in minutes


217
218
219
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 217

def meeting_duration
  @meeting_duration ||= ((end_time - start_time) / 1.minute).abs
end

#minutes_data?Boolean

Returns:

  • (Boolean)

297
298
299
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 297

def minutes_data?
  [video_url, audio_url].any?(&:present?)
end

#on_different_platform?Boolean

Returns:

  • (Boolean)

285
286
287
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 285

def on_different_platform?
  registration_type == "on_different_platform"
end

#on_this_platform?Boolean

Returns:

  • (Boolean)

281
282
283
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 281

def on_this_platform?
  registration_type == "on_this_platform"
end

#pad_is_visible?Boolean

Overwrites method from Paddable to add custom rules in order to know when to display a pad or not.

Returns:

  • (Boolean)

229
230
231
232
233
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 229

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.

Returns:

  • (Boolean)

237
238
239
240
241
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 237

def pad_is_writable?
  return false unless pad_is_visible?

  (Time.current - end_time) < 72.hours
end

#past?Boolean

Returns:

  • (Boolean)

151
152
153
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 151

def past?
  end_time < Time.current
end

#presenterObject

Returns the presenter for this author, to be used in the views. Required by ActsAsAuthor.


130
131
132
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 130

def presenter
  Decidim::Meetings::MeetingPresenter.new(self)
end

#registration_disabled?Boolean

Returns:

  • (Boolean)

277
278
279
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 277

def registration_disabled?
  registration_type == "registration_disabled"
end

#remaining_slotsObject


161
162
163
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 161

def remaining_slots
  available_slots - reserved_slots - registrations.count
end

#reported_attributesObject

Public: Overrides the `reported_attributes` Reportable concern method.


262
263
264
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 262

def reported_attributes
  [:description]
end

#reported_content_urlObject

Public: Overrides the `reported_content_url` Reportable concern method.


257
258
259
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 257

def reported_content_url
  ResourceLocatorPresenter.new(self).url
end

#reported_searchable_content_extrasObject

Public: Overrides the `reported_searchable_content_extras` Reportable concern method.


267
268
269
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 267

def reported_searchable_content_extras
  [normalized_author.name]
end

#resource_visible?Boolean

Returns:

  • (Boolean)

221
222
223
224
225
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 221

def resource_visible?
  return false if hidden?

  !private_meeting? || transparent?
end

#user_allowed_to_comment?(user) ⇒ Boolean

Public: Whether the object can have new comments or not.

Returns:

  • (Boolean)

204
205
206
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 204

def user_allowed_to_comment?(user)
  can_participate?(user)
end

#user_group_registrationsObject

Return registrations of a particular meeting made by users representing a group


124
125
126
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 124

def user_group_registrations
  registrations.where.not(decidim_user_group_id: nil)
end

#users_to_notify_on_comment_createdObject

Public: Override Commentable concern method `users_to_notify_on_comment_created`


199
200
201
# File 'decidim-meetings/app/models/decidim/meetings/meeting.rb', line 199

def users_to_notify_on_comment_created
  followers
end