Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update reservation_seralizer.py #822

Merged
merged 5 commits into from
Aug 27, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/kontres/serializer/reservation_seralizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def validate_time_and_overlapping(self, data):
# Check if this is an update operation and if start_time is being modified.
is_update_operation = self.instance is not None
start_time_being_modified = "start_time" in data
end_time_being_modified = "end_time" in data

# Retrieve the start and end times from the data if provided, else from the instance.
start_time = data.get(
Expand All @@ -137,7 +138,7 @@ def validate_time_and_overlapping(self, data):
"bookable_item", self.instance.bookable_item if self.instance else None
)
# Check for overlapping reservations only if necessary fields are present
if bookable_item and start_time and end_time:
if bookable_item and (start_time_being_modified or end_time_being_modified):
# Build the query for overlapping reservations
overlapping_reservations_query = Q(
bookable_item=bookable_item,
Expand Down
Loading