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



93
94
95
# File 'decidim-conferences/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 'decidim-conferences/app/models/decidim/conference.rb', line 89

def self.promoted
  where(promoted: true)
end

.ransackable_associations(_auth_object = nil) ⇒ Object



167
168
169
# File 'decidim-conferences/app/models/decidim/conference.rb', line 167

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

.ransackable_attributes(auth_object = nil) ⇒ Object



159
160
161
162
163
164
165
# File 'decidim-conferences/app/models/decidim/conference.rb', line 159

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



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

def attachment_context
  :admin
end

#closed?Boolean

Returns:

  • (Boolean)


135
136
137
138
139
# File 'decidim-conferences/app/models/decidim/conference.rb', line 135

def closed?
  return false if end_date.blank?

  end_date < Date.current
end

#diploma_sent?Boolean

Returns:

  • (Boolean)


129
130
131
132
133
# File 'decidim-conferences/app/models/decidim/conference.rb', line 129

def diploma_sent?
  return false if diploma_sent_at.nil?

  true
end

#has_available_slots?Boolean

Returns:

  • (Boolean)


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

def has_available_slots?
  return true if available_slots.zero?

  available_slots > conference_registrations.count
end

#has_published_registration_types?Boolean

Returns:

  • (Boolean)


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

def has_published_registration_types?
  return false if registration_types.empty?

  registration_types.any?(&:published_at?)
end

#has_registration_for?(user) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_registration_for_user_and_registration_type?(user, registration_type) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#hashtagObject



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

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

#remaining_slotsObject



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

def remaining_slots
  available_slots - conference_registrations.count
end

#shareable_url(share_token) ⇒ Object



152
153
154
# File 'decidim-conferences/app/models/decidim/conference.rb', line 152

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

#to_paramObject



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

def to_param
  slug
end

#user_roles(role_name = nil) ⇒ Object



141
142
143
144
145
146
# File 'decidim-conferences/app/models/decidim/conference.rb', line 141

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

  roles.where(role: role_name)
end