Hotel/hotel/rooms/models.py

46 lines
1.1 KiB
Python
Raw Normal View History

from django.db import models
from django.core.validators import MinValueValidator
class RoomType(models.Model):
room_type = models.CharField(max_length=40)
def __str__(self):
return self.room_type
class Room(models.Model):
room_number = models.IntegerField(
primary_key=True,
validators=[
MinValueValidator(1)
]
)
price = models.IntegerField(
validators=[
MinValueValidator(1)
]
)
room_type = models.ForeignKey(RoomType, on_delete=models.CASCADE)
reserved = models.BooleanField()
2019-01-13 19:10:01 +01:00
def __str__(self):
return str(self.room_number)
class Client(models.Model):
id_number = models.CharField(max_length=9, primary_key=True)
name = models.CharField(max_length=40)
surname = models.CharField(max_length=40)
def __str__(self):
return self.name, self.surname
class Reservation(models.Model):
room_number = models.ForeignKey(Room, on_delete=models.CASCADE)
client_id = models.ForeignKey(Client, on_delete=models.CASCADE)
begin_date = models.DateField()
end_date = models.DateField()