improve events
This commit is contained in:
@ -14,10 +14,21 @@ class Member < ApplicationRecord
|
||||
Profile.where( member_id: self.id).where(kind: kind).first
|
||||
end
|
||||
end
|
||||
|
||||
def profile( kind )
|
||||
Profile.where( member_id: self.id).where(kind: kind).first
|
||||
end
|
||||
|
||||
def teacher
|
||||
profile( :teacher )
|
||||
end
|
||||
|
||||
def future_events
|
||||
teacher = profile( :teacher )
|
||||
return [] unless teacher
|
||||
teacher.future_events
|
||||
end
|
||||
|
||||
def admin?
|
||||
email == "torsten@villataika.fi"
|
||||
end
|
||||
|
@ -16,4 +16,8 @@ class Profile < ApplicationRecord
|
||||
def Kind
|
||||
self.kind.capitalize
|
||||
end
|
||||
|
||||
def future_events
|
||||
self.events.where( "start_date > ?" , Date.today)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user