Models ====== .. module:: booking.Models .. class:: 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. .. attribute:: user The user that created/requested the booking. .. attribute:: 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. .. attribute:: start_date The date and time that the booking will start. .. attribute:: end_date The date and time that the booking will end. .. attribute:: booking_reason A description by the user making the booking describing why then need the kit and what they will use it for. .. attribute:: approved Has the booking been approved. This is set once the booking has been reviewed by a WTV admin. .. attribute:: rejected Has the booking been rejected by and admin, in which case they should have provided a reason that goes into :attr:`rejection_reason`. .. attribute:: approved_rejected_by A foreign key ref pointing to the person that approved the booking. .. attribute:: rejection_reason Why has the booking been rejected, this is to be shown to the :attr:`user` so that they can take appropriate action. .. attribute:: kits A ``ManyToManyField`` pointing at all the :class:`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 :attr:`parent` for more info. .. method:: 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:: KitType(models.Model) Represents a single type of kit e.g. A single camera model, or cable type and length. .. attribute:: name Easy to read name of kit type e.g. Cable - XLR 5m .. attribute:: description Detail about the kit type. Most useful for things like cameras that have numerous specifications. .. class:: Kit(models.Model) A single piece of kit. Every item that can be booked out should be represented by a Kit object. .. attribute:: type A foreign key pointing at a :class:`KitType`. .. attribute:: serial A unique number to identify the real world bit of kit by. This *needs* to be unique and is enforced. .. attribute:: 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. .. method:: booked_out Checks to see if the kit is booked out between two dates. :param from_date: The date to check from. :param to_date: The date to check to. :param ignore: A booking to ignore, used when a :class:`Booking` performs validation. :type ignore: Primary Key