app/models/shift.rb
def shift_is_within_time_slot
    unless self.power_signed_up
      if (self.calendar.default || self.calendar.active)
        c = TimeSlot.where("location_id = ? AND start <= ? AND end >= ? AND active  = ?", self.location_id, self.start, self.end, true).count
      else
        #If users are signing up into a non-active calendar, we want to make sure we still respect the (non-active) timeslots present in that calendar
        c = TimeSlot.where("location_id = ? AND start <= ? AND end >= ? AND calendar_id = ?", self.location_id, self.start, self.end, self.calendar_id).count
      end
      errors.add(:base, "You can only sign up for a shift during a time slot.") if c == 0
    end
  end
#TODO: Fix this to check timeslots by time_increment
Fix this to check timeslots by time_increment
Fix this to check timeslots by time_increment
def shift_is_within_time_slot
    unless self.power_signed_up
      if (self.calendar.default || self.calendar.active)
        c = TimeSlot.where("location_id = ? AND start <= ? AND end >= ? AND active  = ?", self.location_id, self.start, self.end, true).count
      else
        c = TimeSlot.where("location_id = ? AND start <= ? AND end >= ? AND calendar_id = ?", self.location_id, self.start, self.end, self.calendar_id).count
      end
      errors.add(:base, "You can only sign up for a shift during a time slot.") if c == 0
    end
  end
def shift_is_within_time_slot unless self . power_signed_up if ( self . calendar . default || self . calendar . active ) c = TimeSlot . where ( "location_id = ? AND start <= ? AND end >= ? AND active  = ?" , self . location_id , self . start , self . end , true ) . count else c = TimeSlot . where ( "location_id = ? AND start <= ? AND end >= ? AND calendar_id = ?" , self . location_id , self . start , self . end , self . calendar_id ) . count end errors . add ( :base , "You can only sign up for a shift during a time slot." ) if c == 0 end end
TODO: Fix this to check timeslots by time_increment
TODO : Fix this to check timeslots by time_increment
#If users are signing up into a non-active calendar, we want to make sure we still respect the (non-active) timeslots present in that calendar