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
dfd64a4510
commit
354e15a76d
12 changed files with 71 additions and 61 deletions
|
|
@ -249,13 +249,6 @@ class Event < ActiveRecord::Base
|
|||
(100 * result.values.count(true) / result.values.compact.count).to_s
|
||||
end
|
||||
|
||||
##
|
||||
# Returns end of the event
|
||||
#
|
||||
def end_time
|
||||
self.scheduled_start_time + self.event_type.length.minutes
|
||||
end
|
||||
|
||||
##
|
||||
# Returns the room in which the event is scheduled
|
||||
#
|
||||
|
|
@ -270,25 +263,18 @@ class Event < ActiveRecord::Base
|
|||
selected_event_schedule.try(:start_time)
|
||||
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
|
||||
|
||||
# returns the event_schedule for this event and the schedule given in case that it exists
|
||||
def event_schedule(schedule_id)
|
||||
event_schedules.find_by(schedule_id: schedule_id)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# returns the event_schedule for this event and for the selected_schedule
|
||||
def selected_event_schedule
|
||||
event_schedules.find_by(schedule_id: program.try(:selected_schedule))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
# Do not allow, for the event, more attendees than the size of the room
|
||||
def max_attendees_no_more_than_room_size
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class Program < ActiveRecord::Base
|
|||
joins(:event_schedules).where('event_schedules.schedule_id = ? AND event_schedules.start_time IS NOT NULL AND event_schedules.room_id IS NOT NULL', schedule_id)
|
||||
end
|
||||
|
||||
def unscheduled(schedule_id=nil)
|
||||
def unscheduled(schedule_id)
|
||||
select{ |e| e.unscheduled?(schedule_id) }
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue