Skip to content

Commit

Permalink
update test garden
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolan4ik2003 committed Dec 2, 2024
1 parent c03d043 commit 0cb0403
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions django/tamprog/garden/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,14 @@ def rent_beds(field, user, beds_count):
@staticmethod
def release_beds(field, beds_count):
rented_beds = Bed.objects.filter(field=field, is_rented=True)[:beds_count]
if not rented_beds:
log.warning(f"No rented beds available to release in field {field.id}")
return
for bed in rented_beds:
bed.is_rented = False
bed.rented_by = None
bed.save()
field.count_free_beds += len(rented_beds)

field.count_free_beds += beds_count
field.save()
log.info(f"{len(rented_beds)} beds released successfully.")
log.info(f"{beds_count} beds released successfully.")

@staticmethod
def get_user_beds(user):
Expand Down

0 comments on commit 0cb0403

Please sign in to comment.