Ejemplo n.º 1
0
    def unstretch_slot(self, slot_id):
        slot = self.get_one(slot_id, strict=True)
        if not slot.can_be_unstretched: raise CannotBeUnstretched()
        slot.duration -= 60

        new_slot = Slot(room=slot.room, status='empty', blocked=slot.blocked, duration=60)
        new_slot.begins = slot.begins + timedelta(minutes=slot.duration)

        db.session.add(new_slot)
        db.session.add(slot)
        db.session.commit()
        return slot