Handle cancelation of scheduled events

This commit is contained in:
Nishanth Vijayan 2016-07-13 18:36:22 +05:30
parent 63750345e7
commit a071d4497b
5 changed files with 50 additions and 0 deletions

View file

@ -38,6 +38,8 @@ class Event < ActiveRecord::Base
validate :max_attendees_no_more_than_room_size
scope :confirmed, -> { where(state: 'confirmed') }
scope :canceled, -> { where(state: 'canceled') }
scope :withdrawn, -> { where(state: 'withdrawn') }
scope :highlighted, -> { where(is_highlight: true) }
state_machine initial: :new do
@ -230,6 +232,13 @@ class Event < ActiveRecord::Base
self.start_time + self.event_type.length.minutes
end
##
# Returns events that are scheduled in the same room and start_time as event
#
def intersecting_events
room.events.where(start_time: start_time).where.not(id: id)
end
private
##