Class: Decidim::Conference

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

Overview

Interaction between a user and an organization can be done via a Conference. It is 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



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

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

Scope to return only the promoted conferences.

Returns an ActiveRecord::Relation.



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

def self.promoted
  where(promoted: true)
end

Instance Method Details

#attachment_contextObject



145
146
147
# File 'app/models/decidim/conference.rb', line 145

def attachment_context
  :admin
end

#closed?Boolean

Returns:

  • (Boolean)


132
133
134
135
136
# File 'app/models/decidim/conference.rb', line 132

def closed?
  return false if end_date.blank?

  end_date < Date.current
end

#diploma_sent?Boolean

Returns:

  • (Boolean)


126
127
128
129
130
# File 'app/models/decidim/conference.rb', line 126

def diploma_sent?
  return false if diploma_sent_at.nil?

  true
end

#has_available_slots?Boolean

Returns:

  • (Boolean)


110
111
112
113
114
# File 'app/models/decidim/conference.rb', line 110

def has_available_slots?
  return true if available_slots.zero?

  available_slots > conference_registrations.count
end

#has_published_registration_types?Boolean

Returns:

  • (Boolean)


116
117
118
119
120
# File 'app/models/decidim/conference.rb', line 116

def has_published_registration_types?
  return false if registration_types.empty?

  registration_types.any?(&:published_at?)
end

#has_registration_for?(user) ⇒ Boolean

Returns:

  • (Boolean)


102
103
104
# File 'app/models/decidim/conference.rb', line 102

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

#has_registration_for_user_and_registration_type?(user, registration_type) ⇒ Boolean

Returns:

  • (Boolean)


106
107
108
# File 'app/models/decidim/conference.rb', line 106

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

#hashtagObject



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

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

#remaining_slotsObject



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

def remaining_slots
  available_slots - conference_registrations.count
end

#to_paramObject



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

def to_param
  slug
end

#user_roles(role_name = nil) ⇒ Object



138
139
140
141
142
143
# File 'app/models/decidim/conference.rb', line 138

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

  roles.where(role: role_name)
end