Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Update views.py
Browse files Browse the repository at this point in the history
  • Loading branch information
DeyanVNikolov committed Feb 21, 2024
1 parent d76a104 commit 602bcc5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions website/home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def hotels(request):
for photo in photos:
host = request.get_host()
scheme = request.scheme

r = requests.get(f'{scheme}://{host}/static/cover/hotel/{hotel.id}/{photo}')
if r.status_code == 200:
img = photo
Expand Down Expand Up @@ -107,10 +107,17 @@ def hotel(request, hotel_id):
hotel_images = []
BASE_DIR = Path(__file__).resolve().parent.parent

image_dir = f'{BASE_DIR}/static/cover/hotel/{hotel.id}'
if os.path.isdir(image_dir):
for filename in os.listdir(image_dir):
hotel_images.append(filename)
photos = str(hotel.photos).split('|PHOTO|')
for photo in photos:
img = None
scheme = request.scheme
host = request.get_host()
r = requests.get(f'{scheme}://{host}/static/cover/hotel/{hotel.id}/{photo}')
if r.status_code == 200:
img = photo
hotel_images.append(img)



rooms = Room.objects.filter(hotel=hotel)

Expand Down

0 comments on commit 602bcc5

Please sign in to comment.