Class: Decidim::Conference

Inherits:
ApplicationRecord
  • Object
show all
Includes:
FilterableResource, Followable, HasAttachmentCollections, HasAttachments, HasReference, HasUploadValidations, Loggable, Participable, ParticipatorySpaceResourceable, Publicable, ScopableParticipatorySpace, Searchable, ShareableWithToken, SoftDeletable, Taxonomizable, 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



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

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

Scope to return only the promoted conferences.

Returns an ActiveRecord::Relation.



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

def self.promoted
  where(promoted: true)
end

.ransackable_associations(_auth_object = nil) ⇒ Object



163
164
165
# File 'app/models/decidim/conference.rb', line 163

def self.ransackable_associations(_auth_object = nil)
  %w(taxonomies)
end

.ransackable_attributes(auth_object = nil) ⇒ Object



155
156
157
158
159
160
161
# File 'app/models/decidim/conference.rb', line 155

def self.ransackable_attributes(auth_object = nil)
  base = %w(title short_description description id)

  return base unless auth_object&.admin?

  base + %w(published_at)
end

Instance Method Details

#attachment_contextObject



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

def attachment_context
  :admin
end

#closed?Boolean

Returns:

  • (Boolean)


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

def closed?
  return false if end_date.blank?

  end_date < Date.current
end

#diploma_sent?Boolean

Returns:

  • (Boolean)


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

def diploma_sent?
  return false if diploma_sent_at.nil?

  true
end

#has_available_slots?Boolean

Returns:

  • (Boolean)


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

def has_available_slots?
  return true if available_slots.zero?

  available_slots > conference_registrations.count
end

#has_published_registration_types?Boolean

Returns:

  • (Boolean)


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

def has_published_registration_types?
  return false if registration_types.empty?

  registration_types.any?(&:published_at?)
end

#has_registration_for?(user) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_registration_for_user_and_registration_type?(user, registration_type) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#remaining_slotsObject



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

def remaining_slots
  available_slots - conference_registrations.count
end

#shareable_url(share_token) ⇒ Object



148
149
150
# File 'app/models/decidim/conference.rb', line 148

def shareable_url(share_token)
  EngineRouter.main_proxy(self).conference_url(self, share_token: share_token.token)
end

#to_paramObject



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

def to_param
  slug
end

#user_roles(role_name = nil) ⇒ Object



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

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

  roles.where(role: role_name)
end