Public schedule adapted to the new relations
Public schedule and all events adapted to the new relations and models to allow having several schedules in the admin shcedule.
This commit is contained in:
parent
8f3dcda2f7
commit
2aee0158f8
12 changed files with 70 additions and 60 deletions
|
|
@ -3,7 +3,25 @@ class EventSchedule < ActiveRecord::Base
|
|||
belongs_to :event
|
||||
belongs_to :room
|
||||
|
||||
scope :confirmed, -> { joins(:event).where('state = ?', 'confirmed') }
|
||||
scope :canceled, -> { joins(:event).where('state = ?', 'canceled') }
|
||||
scope :withdrawn, -> { joins(:event).where('state = ?', 'withdrawn') }
|
||||
|
||||
def room_guid
|
||||
room.try(:guid)
|
||||
end
|
||||
|
||||
##
|
||||
# Returns end of the event
|
||||
#
|
||||
def end_time
|
||||
start_time + event.event_type.length.minutes
|
||||
end
|
||||
|
||||
##
|
||||
# Returns events that are scheduled in the same room and start_time as event
|
||||
#
|
||||
def intersecting_events
|
||||
room.event_schedules.where(start_time: start_time, schedule: schedule).where.not(id: id)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue