1
|
|
|
class Participant < ActiveRecord::Base |
2
|
|
|
has_many :sessions |
3
|
|
|
has_many :attendances |
4
|
|
|
has_many :sessions_attending, :through => :attendances, :source => :session |
5
|
|
|
has_many :presentations |
6
|
|
|
has_many :sessions_presenting, :through => :presentations, :source => :session |
7
|
|
|
has_many :presenter_timeslot_restrictions, dependent: :destroy |
8
|
|
|
|
9
|
|
|
validates_presence_of :name |
10
|
|
|
validates_uniqueness_of :email, :case_sensitive => false, :allow_blank => true |
11
|
|
|
|
12
|
|
|
acts_as_authentic do |config| |
13
|
|
|
config.crypto_provider = Authlogic::CryptoProviders::BCrypt |
14
|
|
|
config.require_password_confirmation = false |
15
|
|
|
end |
16
|
|
|
|
17
|
|
|
def restrict_after(datetime, weight=1, event=Event.current_event) |
18
|
|
|
event.timeslots.select do |timeslot| |
19
|
|
|
if timeslot.ends_at >= datetime |
20
|
|
|
self.presenter_timeslot_restrictions.create!( |
21
|
|
|
timeslot: timeslot, |
22
|
|
|
weight: weight) |
23
|
|
|
end |
24
|
|
|
end |
25
|
|
|
end |
26
|
|
|
|
27
|
|
|
def restrict_before(datetime, weight=1, event=Event.current_event) |
28
|
|
|
event.timeslots.select do |timeslot| |
29
|
|
|
if timeslot.starts_at <= datetime |
30
|
|
|
self.presenter_timeslot_restrictions.create!( |
31
|
|
|
timeslot: timeslot, |
32
|
|
|
weight: weight) |
33
|
|
|
end |
34
|
|
|
end |
35
|
|
|
end |
36
|
|
|
|
37
|
|
|
def deliver_password_reset_instructions! |
38
|
|
|
reset_perishable_token! |
39
|
|
|
Notifier.password_reset_instructions(self).deliver_now! |
40
|
|
|
end |
41
|
|
|
|
42
|
|
|
def attending_session?(session) |
43
|
|
|
sessions_attending.include?(session) |
44
|
|
|
end |
45
|
|
|
|
46
|
|
|
def github_profile_url |
47
|
|
|
"https://github.com/#{self.github_profile_username}" |
48
|
|
|
end |
49
|
|
|
|
50
|
|
|
def tokenized_name |
51
|
|
|
# sessions created via Admin::SessionsController may not set a name |
52
|
|
|
return [] unless name |
53
|
|
|
name.split(' ') |
54
|
|
|
end |
55
|
|
|
end |
56
|
|
|
|