get_a_room/rooms/models.py
def check_time_slot(self, new_data):
        """
        Checks if the time slot in new_data is available.
        If a booking is getting updated then it is skipped
        when checking the availability of the room.
        """
        bookings_on_room = Booking.objects.filter(
            room_number=new_data['room_number'])
        id = None
        if self is not None:
            id = self.id
        for booking in bookings_on_room:
            if id is not None and id == booking.id:
                continue

            if booking.day_of_week == new_data['day_of_week']:
                if (booking.end_date >= new_data['start_date'] and
                   booking.start_date <= new_data['end_date']):
                    if (booking.end_time > new_data['start_time'] and
                       booking.start_time < new_data['end_time']):
                        raise serializers.ValidationError(
                            "Time slot is not available for that room")

        Checks if the time slot in new_data is available.
        If a booking is getting updated then it is skipped
        when checking the availability of the room.
        
Checks if the time slot in new_data is available.
If a booking is getting updated then it is skipped
when checking the availability of the room.
Checks if the time slot in new_data is available . If a booking is getting updated then it is skipped when checking the availability of the room .
def check_time_slot(self, new_data):
        bookings_on_room = Booking.objects.filter(
            room_number=new_data['room_number'])
        id = None
        if self is not None:
            id = self.id
        for booking in bookings_on_room:
            if id is not None and id == booking.id:
                continue
            if booking.day_of_week == new_data['day_of_week']:
                if (booking.end_date >= new_data['start_date'] and
                   booking.start_date <= new_data['end_date']):
                    if (booking.end_time > new_data['start_time'] and
                       booking.start_time < new_data['end_time']):
                        raise serializers.ValidationError(
                            "Time slot is not available for that room")
def check_time_slot ( self , new_data ) : bookings_on_room = Booking . objects . filter ( room_number = new_data [ 'room_number' ] ) id = None if self is not None : id = self . id for booking in bookings_on_room : if id is not None and id == booking . id : continue if booking . day_of_week == new_data [ 'day_of_week' ] : if ( booking . end_date >= new_data [ 'start_date' ] and booking . start_date <= new_data [ 'end_date' ] ) : if ( booking . end_time > new_data [ 'start_time' ] and booking . start_time < new_data [ 'end_time' ] ) : raise serializers . ValidationError ( "Time slot is not available for that room" )
Checks if the time slot in new_data is available.
Checks if the time slot in new_data is available .
"""
        Checks if the time slot in new_data is available.
        If a booking is getting updated then it is skipped
        when checking the availability of the room.
        """
self
new_data