Initial commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
|
||||
from apps.salons.models import Salon, Service, StaffProfile
|
||||
|
||||
|
||||
class BookingStatus(models.TextChoices):
|
||||
PENDING = "pending", "Pending"
|
||||
CONFIRMED = "confirmed", "Confirmed"
|
||||
CANCELLED = "cancelled", "Cancelled"
|
||||
COMPLETED = "completed", "Completed"
|
||||
|
||||
|
||||
class Booking(models.Model):
|
||||
salon = models.ForeignKey(Salon, on_delete=models.CASCADE, related_name="bookings")
|
||||
customer = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="bookings",
|
||||
)
|
||||
service = models.ForeignKey(Service, on_delete=models.PROTECT)
|
||||
staff = models.ForeignKey(StaffProfile, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
start_time = models.DateTimeField()
|
||||
end_time = models.DateTimeField()
|
||||
status = models.CharField(max_length=20, choices=BookingStatus.choices, default=BookingStatus.PENDING)
|
||||
price_amount = models.DecimalField(max_digits=10, decimal_places=2)
|
||||
currency = models.CharField(max_length=10, default=getattr(settings, "DEFAULT_CURRENCY", "SAR"))
|
||||
notes = models.TextField(blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.customer.email} - {self.service.name}"
|
||||
Reference in New Issue
Block a user