| Class | Booking |
| In: |
app/models/booking.rb
|
| Parent: | ActiveRecord::Base |
A booking for a client to see a Clinician in a specified ClinicalSession.
Bookings are controlled mainly through the SessionController
Checks for clashes with existing bookings.
There are three types of possible clashes:
If both 2 and 3 occur, the new booked session occurs entirely within a booked session. This is an external conflict.
A booking may finish at the exact same time as another starts.
# File app/models/booking.rb, line 31
31: def validate
32: if clinical_session and client
33: #Check to see if this session is already booked
34: errors.add :clinical_session, "is already booked" if clinical_session.booked?
35:
36: errors.add :clinical_session, "is invalid. Client is already booked at this time" if client.is_booked?(clinical_session.start, clinical_session.finish)
37: errors.add :clinical_session, "is already booked for this client" if clinical_session.booking_for(client_id)
38: else
39: errors.add :clinical_session, "is required" if !clinical_session_id
40: errors.add :client, "is required" if !client_id
41: end
42: end