Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.7 kB
2
Indexable
Never
from django.db import models
from django.db.models.deletion import CASCADE



class Floor(models.Model):
    number = models.SmallIntegerField()


class Status(models.Model):
    types = (
        ('e', 'empty'),
        ('f', 'full')
    )
    name = models.CharField(max_length=1, choices=types, verbose_name='Status')


class Type(models.Model):
    types = (
        ('1', 'premium'),
        ('2', 'luxurious'),
        ('3', 'normal')
    )
    name = models.CharField(max_length=1, choices=types, verbose_name='Type')
    price = models.IntegerField(verbose_name='Price')


class Room(models.Model):
    phone = models.CharField(max_length=20, verbose_name='Phone number')
    type_id = models.ForeignKey(Type, on_delete=models.CASCADE)
    status_id = models.ForeignKey(Status, on_delete=CASCADE)
    floor_id = models.ForeignKey(Floor, on_delete=CASCADE)


class Guest(models.Model):
    first_name = models.CharField(max_length=30, verbose_name='First name')
    last_name = models.CharField(max_length=30, verbose_name='Last name')
    middle_name = models.CharField(max_length=30, verbose_name='Middle name', blank=True, null=True)
    date_of_birth = models.DateField(verbose_name='Birthday')
    address = models.CharField(max_length=50, verbose_name='Address')
    city = models.CharField(max_length=30, verbose_name='City')
    email = models.CharField(max_length=50, verbose_name='Email',blank=True, null=True)
    phone = models.CharField(max_length=20, verbose_name='Phone number')
    passport = models.CharField(max_length=15)


class Staff(models.Model):
    first_name = models.CharField(max_length=30, verbose_name='First name')
    last_name = models.CharField(max_length=30, verbose_name='Last name')
    middle_name = models.CharField(max_length=30, verbose_name='Middle name',blank=True, null=True)
    date_of_birth = models.DateField(verbose_name='Birthday', null=True)
    phone = models.CharField(max_length=20, verbose_name='Phone number', null=True)
    address = models.CharField(max_length=50, verbose_name='Address', null=True)



class Reservation(models.Model):
    Date = models.DateField(verbose_name='Date')
    check_in = models.DateField(verbose_name='Check in')
    check_out = models.DateField(verbose_name='Check out')
    adults = models.SmallIntegerField()
    children = models.SmallIntegerField(blank=True, null=True)
    amount = models.IntegerField()
    room_id = models.ForeignKey(Room, on_delete=models.CASCADE)
    guest_id = models.ForeignKey(Guest, on_delete=models.CASCADE)


class Schedule(models.Model):
    date = models.DateField(verbose_name='Date')
    staff_id = models.ForeignKey(Staff, on_delete=models.CASCADE)
    floor_id = models.ForeignKey(Floor, on_delete=models.CASCADE)