The Hotel Booking System is a convenient application that allows users to easily and quickly book rooms in a hotel. With its help, you can find and book the perfect accommodation for your stay.
- View available rooms: users can easily find suitable rooms using filters and sorting by price and room's capacity.
- Search for vacant rooms: the system allows users to search for available rooms within a specified time interval.
- Room booking: book your desired room in just a few clicks. Booking is available only to registered users.
- Administrative panel: the superuser can manage rooms and bookings through the Django administrative panel.
- Registration and authentication: users can register to view their bookings and log in to the system to book rooms.
- Django.
- Django REST Framework: for API.
- Djoser for authorization.
- PostgreSQL.
- PyTest.
- Linters: isort + flake8.
- drf-yasg for API docs.
All actions should be executed from the source directory of the project and only after installing all requirements.
- Firstly, create and activate a new virtual environment:
python3.9 -m venv ../venv source ../venv/bin/activate - Install packages:
pip install --upgrade pip pip install -r requirements.txt - Run project dependencies, migrations, tests, fill the database with the fixture data etc.:
python manage.py migrate python manage.py loaddata fixtures/data.json pytest python manage.py runserver
DEBUG=bool
SECRET_KEY=django_secret_key
DATABASE_NAME=name
DATABASE_USER=user
DATABASE_PASSWORD=password
DATABASE_HOST=host
DATABASE_PORT=1234
docs you can read on http://127.0.0.1:8000/swagger/
Main endpoints:
- POST http://127.0.0.1:8000/api-token-auth/ - for obtaining auth token for our superuser
- GET http://127.0.0.1:8000/api/auth/users/ - returns list of authorized users
- POST http://127.0.0.1:8000/api/auth/users/ - registers new user
- POST http://127.0.0.1:8000/api/auth/token/login/ - returns auth token which can be used by user for auth
- POST http://127.0.0.1:8000/api/auth/token/logout/ - deactivates auth token for user (should place auth token in header)
- GET http://127.0.0.1:8000/api/rooms/ - returns list of rooms
Sort and filter with query params:- Sort by = (price, -price, capacity, -capacity) http://127.0.0.1:8000/api/rooms/?sort_by=price
- Filter by min capacity of room capacity http://127.0.0.1:8000/api/rooms/?capacity=3
- Filter by min and max cost http://127.0.0.1:8000/api/rooms/?current_price__lt=200000¤t_price__gt=3000
- Filter by rooms availability http://127.0.0.1:8000/api/rooms/?checkin=2024-10-9&checkout=2024-10-10
- GET http://127.0.0.1:8000/api/rooms/ - returns specific of room
- POST http://127.0.0.1:8000/api/rooms/ - creates room (Admin only)
- PATCH http://127.0.0.1:8000/api/rooms/(pk:int)/ - patch specific room (Admin only)
- DEL http://127.0.0.1:8000/api/rooms/(pk:int)/ - delete specific room (Admin only)
- GET http://127.0.0.1:8000/api/bookings/ - returns list of user's bookings (for admin returns all bookings)
- POST http://127.0.0.1:8000/api/bookings/ - creates booking (if this room is not already booked for these dates)
- PATCH http://127.0.0.1:8000/api/bookings/(pk:int)/cancel/ - cancels user's booking (Admin can cancel any booking)
- PATCH http://127.0.0.1:8000/api/bookings/(pk:int)/ - patch specific booking (Admin only)
- DEL http://127.0.0.1:8000/api/bookings/(pk:int)/ - delete specific booking (Admin only)
(If it doesn't open in preview you can always download it)