Do not use JS to initialize the schedule
- Only use JS for the drag&drop functionality and to the set/alter the time and rooms of the EventSchedule object. - Introduce has_many :events, through: :event_schedules association to get unscheduled event easily
This commit is contained in:
parent
71dab6b79c
commit
a394293500
12 changed files with 66 additions and 125 deletions
|
|
@ -78,15 +78,6 @@ class Event < ActiveRecord::Base
|
|||
selected_event_schedule.present?
|
||||
end
|
||||
|
||||
##
|
||||
# Checkes if the event has a start_time and a room for the given schedule
|
||||
# (given by its id) or for the selected one if there is any.
|
||||
# ====Returns
|
||||
# * +true+ or +false+
|
||||
def unscheduled?(schedule_id)
|
||||
state == 'confirmed' && !event_schedule(schedule_id).present?
|
||||
end
|
||||
|
||||
def registration_possible?
|
||||
return false unless require_registration && state == 'confirmed'
|
||||
return true if max_attendees.nil?
|
||||
|
|
@ -138,15 +129,6 @@ class Event < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def as_json(options={})
|
||||
json = super({ include: { event_schedules: { methods: [:room_guid] } } }.merge(options))
|
||||
json[:track_color] = track.try(:color) || '#FFFFFF'
|
||||
json[:track_text_color] = ApplicationController.helpers.contrast_color(json[:track_color])
|
||||
json[:length] = event_type.try(:length) || EventType::LENGTH_STEP
|
||||
|
||||
json
|
||||
end
|
||||
|
||||
def transition_possible?(transition)
|
||||
self.class.state_machine.events_for(current_state).include?(transition)
|
||||
end
|
||||
|
|
@ -263,11 +245,6 @@ class Event < ActiveRecord::Base
|
|||
selected_event_schedule.try(:start_time)
|
||||
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
|
||||
|
||||
# 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_id))
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@ class Program < ActiveRecord::Base
|
|||
joins(:event_schedules).where('event_schedules.schedule_id = ?', schedule_id)
|
||||
end
|
||||
|
||||
def unscheduled(schedule_id)
|
||||
select{ |e| e.unscheduled?(schedule_id) }
|
||||
end
|
||||
|
||||
def highlights
|
||||
where(state: :confirmed, is_highlight: true)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
class Schedule < ActiveRecord::Base
|
||||
belongs_to :program
|
||||
has_many :event_schedules, dependent: :destroy
|
||||
has_many :events, through: :event_schedules
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue