Created and activated the booking integrity ExecPlan, then implemented staff availability, overlap prevention, and duration validation with backend tests.

Added a staff availability model and migration, a booking validation service, and serializer enforcement.
This commit is contained in:
2026-02-28 12:05:57 +03:00
parent d40bb10876
commit 411180e312
9 changed files with 467 additions and 7 deletions
+3 -4
View File
@@ -1,7 +1,6 @@
from rest_framework import serializers
from django.utils.translation import gettext_lazy as _
from apps.bookings.models import Booking
from apps.bookings.services import validate_booking_request
from apps.salons.models import Service, StaffProfile
@@ -42,12 +41,12 @@ class BookingCreateSerializer(serializers.ModelSerializer):
class Meta:
model = Booking
fields = ["service", "staff", "start_time", "end_time", "notes"]
extra_kwargs = {"staff": {"required": True}}
def validate(self, attrs):
service: Service = attrs["service"]
staff = attrs.get("staff")
if staff and staff.salon_id != service.salon_id:
raise serializers.ValidationError(_("Selected staff does not belong to this salon"))
validate_booking_request(service, staff, attrs["start_time"], attrs["end_time"])
return attrs
def create(self, validated_data):