Class: Decidim::Conference

Inherits:
ApplicationRecord
  • Object
show all
Includes:
Followable, HasAttachmentCollections, HasAttachments, HasReference, Loggable, Participable, ParticipatorySpaceResourceable, Publicable, Scopable, Searchable, Traceable
Defined in:
app/models/decidim/conference.rb

Overview

Interaction between a user and an organization can be done via an Conference. It’s a unit of action from the Organization point of view that groups several components (proposals, debates…) that can be enabled or disabled.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.log_presenter_class_for(_log) ⇒ Object



78
79
80
# File 'app/models/decidim/conference.rb', line 78

def self.log_presenter_class_for(_log)
  Decidim::Conferences::AdminLog::ConferencePresenter
end

Scope to return only the promoted conferences.

Returns an ActiveRecord::Relation.



74
75
76
# File 'app/models/decidim/conference.rb', line 74

def self.promoted
  where(promoted: true)
end

Instance Method Details

#closed?Boolean

Returns:

  • (Boolean)


114
115
116
117
118
# File 'app/models/decidim/conference.rb', line 114

def closed?
  return false if end_date.blank?

  end_date < Date.current
end

#diploma_sent?Boolean

Returns:

  • (Boolean)


108
109
110
111
112
# File 'app/models/decidim/conference.rb', line 108

def diploma_sent?
  return false if diploma_sent_at.nil?

  true
end

#has_available_slots?Boolean

Returns:

  • (Boolean)


98
99
100
101
102
# File 'app/models/decidim/conference.rb', line 98

def has_available_slots?
  return true if available_slots.zero?

  available_slots > conference_registrations.count
end

#has_registration_for?(user) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'app/models/decidim/conference.rb', line 90

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

#has_registration_for_user_and_registration_type?(user, registration_type) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
# File 'app/models/decidim/conference.rb', line 94

def has_registration_for_user_and_registration_type?(user, registration_type)
  conference_registrations.where(user: user, registration_type: registration_type).any?
end

#hashtagObject



82
83
84
# File 'app/models/decidim/conference.rb', line 82

def hashtag
  attributes["hashtag"].to_s.delete("#")
end

#remaining_slotsObject



104
105
106
# File 'app/models/decidim/conference.rb', line 104

def remaining_slots
  available_slots - conference_registrations.count
end

#to_paramObject



86
87
88
# File 'app/models/decidim/conference.rb', line 86

def to_param
  slug
end

#user_roles(role_name = nil) ⇒ Object



120
121
122
123
124
125
# File 'app/models/decidim/conference.rb', line 120

def user_roles(role_name = nil)
  roles = Decidim::ConferenceUserRole.where(conference: self)
  return roles if role_name.blank?

  roles.where(role: role_name)
end