49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
import uuid
|
|
from django.db import models
|
|
|
|
|
|
class ScheduleEntry(models.Model):
|
|
STATUS_CHOICES = [
|
|
('busy', 'Occupé'),
|
|
('free', 'Disponible'),
|
|
('unavailable', 'Indisponible'),
|
|
]
|
|
|
|
title = models.CharField(max_length=120, blank=True)
|
|
description = models.TextField(blank=True)
|
|
start_date = models.DateField()
|
|
end_date = models.DateField()
|
|
start_time = models.TimeField()
|
|
end_time = models.TimeField()
|
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='busy')
|
|
color = models.CharField(max_length=16, blank=True, default='')
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
ordering = ['start_date', 'start_time']
|
|
indexes = [models.Index(fields=['start_date', 'end_date'], name='planning_schedule_dates')]
|
|
|
|
|
|
class AvailabilityRequest(models.Model):
|
|
STATUS_CHOICES = [
|
|
('pending', 'En attente'),
|
|
('accepted', 'Acceptée'),
|
|
('refused', 'Refusée'),
|
|
]
|
|
|
|
public_token = models.UUIDField(default=uuid.uuid4, unique=True, editable=False)
|
|
guest_name = models.CharField(max_length=80)
|
|
message = models.CharField(max_length=500, blank=True)
|
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
|
|
duration_minutes = models.PositiveIntegerField(null=True, blank=True)
|
|
available_until = models.DateTimeField(null=True, blank=True)
|
|
response_message = models.CharField(max_length=500, blank=True)
|
|
requested_at = models.DateTimeField(auto_now_add=True)
|
|
responded_at = models.DateTimeField(null=True, blank=True)
|
|
requester_ip = models.GenericIPAddressField(null=True, blank=True)
|
|
|
|
class Meta:
|
|
ordering = ['-requested_at']
|
|
indexes = [models.Index(fields=['status', 'requested_at'], name='planning_request_status')]
|