Class: Decidim::Conference

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

Methods included from HasUploadValidations

#attached_uploader, #maximum_avatar_size, #maximum_upload_size

Methods included from Searchable

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

#previously_published?, #publish!, #published?, #unpublish!

Class Method Details

.log_presenter_class_for(_log) ⇒ Object



90
91
92
# File 'decidim-conferences/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 'decidim-conferences/app/models/decidim/conference.rb', line 86

def self.promoted
  where(promoted: true)
end

Instance Method Details

#attachment_contextObject



139
140
141
# File 'decidim-conferences/app/models/decidim/conference.rb', line 139

def attachment_context
  :admin
end

#closed?Boolean

Returns:

  • (Boolean)


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

def closed?
  return false if end_date.blank?

  end_date < Date.current
end

#diploma_sent?Boolean

Returns:

  • (Boolean)


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

def diploma_sent?
  return false if diploma_sent_at.nil?

  true
end

#has_available_slots?Boolean

Returns:

  • (Boolean)


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

def has_available_slots?
  return true if available_slots.zero?

  available_slots > conference_registrations.count
end

#has_registration_for?(user) ⇒ Boolean

Returns:

  • (Boolean)


102
103
104
# File 'decidim-conferences/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 'decidim-conferences/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 'decidim-conferences/app/models/decidim/conference.rb', line 94

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

#remaining_slotsObject



116
117
118
# File 'decidim-conferences/app/models/decidim/conference.rb', line 116

def remaining_slots
  available_slots - conference_registrations.count
end

#to_paramObject



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

def to_param
  slug
end

#user_roles(role_name = nil) ⇒ Object



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

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

  roles.where(role: role_name)
end