Class: Decidim::Conference

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

Methods included from HasUploadValidations

#maximum_avatar_size, #maximum_upload_size

Methods included from Searchable

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

#publish!, #published?, #unpublish!

Class Method Details

.log_presenter_class_for(_log) ⇒ Object


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

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

Scope to return only the promoted conferences.

Returns an ActiveRecord::Relation.


85
86
87
# File 'decidim-conferences/app/models/decidim/conference.rb', line 85

def self.promoted
  where(promoted: true)
end

Instance Method Details

#attachment_contextObject


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

def attachment_context
  :admin
end

#closed?Boolean

Returns:

  • (Boolean)

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

def closed?
  return false if end_date.blank?

  end_date < Date.current
end

#diploma_sent?Boolean

Returns:

  • (Boolean)

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

def diploma_sent?
  return false if diploma_sent_at.nil?

  true
end

#has_available_slots?Boolean

Returns:

  • (Boolean)

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

def has_available_slots?
  return true if available_slots.zero?

  available_slots > conference_registrations.count
end

#has_registration_for?(user) ⇒ Boolean

Returns:

  • (Boolean)

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

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)

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

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

#hashtagObject


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

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

#remaining_slotsObject


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

def remaining_slots
  available_slots - conference_registrations.count
end

#to_paramObject


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

def to_param
  slug
end

#user_roles(role_name = nil) ⇒ Object


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

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

  roles.where(role: role_name)
end