Skip to content

Commit

Permalink
Fix saving logic for available beds and add new fields to serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
SirSanctified committed Mar 7, 2024
1 parent 2d3bdad commit bc888df
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class Meta:
updated_at = models.DateTimeField(auto_now=True)

def save(self, *args, **kwargs):
if not self.pk:
if not self.pk and self.occupied_beds == 0:
self.available_beds = self.num_beds
else:
self.available_beds = self.num_beds - self.occupied_beds
Expand Down
2 changes: 2 additions & 0 deletions backend/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class Meta:
"url",
"owner",
"room",
"status",
"start_date",
"end_date",
"created_at",
Expand Down Expand Up @@ -189,6 +190,7 @@ class Meta:
"location",
"street",
"number",
"reviews",
"amenities",
"is_published",
"created_at",
Expand Down
1 change: 0 additions & 1 deletion backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class RoomViewSet(ModelViewSet):
A viewset for viewing and editing user instances.
"""

parser_classes = [MultiPartParser, FormParser]
permission_classes = [IsAuthenticatedOrReadOnly]
search_fields = [
"name",
Expand Down

0 comments on commit bc888df

Please sign in to comment.