Models

class booking.Models.Booking(models.Model)

This object represents your basic booking object, it contains data on the start and end of the a booking, rejection or approval and other key booking information.

user

The user that created/requested the booking.

parent

The parent booking, allows booking to be grouped. This is useful if single pieces of kit are booked out for less time than other pieces of kit.

This means that infant bookings will not cover the same time period as the parent but instead only a small sub period of time.

               | Day 1 | Day 2 | Day 3 | Day 4 | Day 5 | Day 6 |
---------------+-------+-------+-------+-------+-------+-------+
Parent booking | ##### | ##### | ##### | ##### | ##### |       |
Infant         |       |       | ##### | ##### |       |       |

#### : Booking in effect

Note that the infant only effects days that the parent already covers.

start_date

The date and time that the booking will start.

end_date

The date and time that the booking will end.

booking_reason

A description by the user making the booking describing why then need the kit and what they will use it for.

approved

Has the booking been approved. This is set once the booking has been reviewed by a WTV admin.

rejected

Has the booking been rejected by and admin, in which case they should have provided a reason that goes into rejection_reason.

approved_rejected_by

A foreign key ref pointing to the person that approved the booking.

rejection_reason

Why has the booking been rejected, this is to be shown to the user so that they can take appropriate action.

kits

A ManyToManyField pointing at all the kit‘s that have been booked out under this booking.

It may be necessary to look infant bookings to get a complete list, note that infant bookings will not cover the same time period as the parent. See parent for more info.

clean()

Validation code that checks to make sure the booking is valid, to this end it checks the following:

  • All kit is available to be booked out.
  • That the booking is either approved or rejected, not both.
  • That there is no rejection reason if the booking is not rejected.
class booking.Models.KitType(models.Model)

Represents a single type of kit e.g. A single camera model, or cable type and length.

name

Easy to read name of kit type e.g. Cable - XLR 5m

description

Detail about the kit type. Most useful for things like cameras that have numerous specifications.

class booking.Models.Kit(models.Model)

A single piece of kit. Every item that can be booked out should be represented by a Kit object.

type

A foreign key pointing at a KitType.

serial

A unique number to identify the real world bit of kit by. This needs to be unique and is enforced.

in_store

Is the item currently in the store room, this is not the same as being booked out, it is possible for an item to be booked out and in store at the same time.

booked_out()

Checks to see if the kit is booked out between two dates.

Parameters:
  • from_date – The date to check from.
  • to_date – The date to check to.
  • ignore (Primary Key) – A booking to ignore, used when a Booking performs validation.

Project Versions

Previous topic

The Plan

This Page