- This system optimizes the work of library administrators.
- Makes the service much more user-friendly.
- CRUD Functionality: Allows adding, viewing, updating, and deleting book records through the Books Service.
- Permissions: Only administrators can create, update, and delete books. All users, including unauthenticated ones, can see the list of books.
- JWT Token Authentication: Uses JWT tokens for secure user authentication.
- CRUD Functionality: Allows adding, viewing, updating, and deleting book records through the Users Service.
- JWT Support: Supports JWT tokens for secure user authentication.
- Create Borrowing Endpoint: Enables users to borrow books with checks for available inventory and user association.
- Filtering: Non-admin users can only view their own borrowings, enhancing privacy and security.
- Return Borrowing Functionality: Implements the ability to return borrowed books while ensuring it cannot be done more than once and updates book inventory accordingly.
- Notifications: Sends notifications via Telegram API for each new borrowing.
- Telegram Integration: Sets up communication with Telegram for sending notifications.
- Chrome Extension Compatibility: Enhances user experience with the ModHeader Chrome extension by customizing the default Authorization header to Authorize for JWT authentication.
- Swagger UI: Provides interactive API documentation at
/api/doc/swagger/
. - Redoc UI: Offers clear and readable API documentation at
/api/doc/redoc/
. - Schema Endpoint: Accesses the API schema at
/api/schema/
.
- Initialization of the Project: - Set up the initial Django project structure.
- Creating the Books service: - Implement models, serializers, views, and URLs specific to managing books.
- Creating Users Service: - Develop user models, serializers, views, and URLs for managing user profiles.
- Adding Access Rights to the Books Service: - Integrate permissions to control access to book CRUD operations.
- Creating the Borrowings Service: - Design models, serializers, views, and URLs to handle book borrowing transactions.
- Implementation of Borrowings Filtering and List Endpoint: - Enhance the Borrowings API to support filtering for different user roles.
- Implementation of Borrowing Return Functionality: - Develop features to facilitate the return of borrowed books.
- Implementation of Tests for Borrowing and Book: - Create comprehensive unit tests to validate the functionality of book and borrowing APIs.
- Documentation of the Project: - Generate API documentation using tools like drf-spectacular.
- Integration of Sending Notifications when Creating a Borrowing: - Configure integration with Telegram API to send notifications for each new borrowing transaction.
- Registration of Models in the Admin Panel: - Register relevant models (Books, Users, Borrowings) in the Django admin interface.
- Update README.md: - Maintain an up-to-date README.md file with essential project information, setup instructions, and usage guidelines.
- Configure project settings such as database connection and Django applications.
- Define CRUD operations for books, allowing creation, retrieval, update, and deletion.
- Implement user authentication and authorization functionalities using JWT tokens.
- Ensure only administrators have permissions for create, update, and delete actions.
- Implement borrowing functionality with validations for inventory availability and user associations.
- Allow non-admin users to view only their own borrowing records, ensuring privacy and security.
- Include validations to prevent duplicate returns and update book inventory accordingly.
- Ensure test coverage across models, views, serializers, and permissions.
- Provide interactive API documentation through Swagger UI and Redoc UI for clarity and usability.
- Set up communication channels and message formats for notification delivery.
- Enable administrators to manage and monitor data through the admin panel efficiently.
- Include details about environment variables, installation steps, and accessing API endpoints.
- Stmts (Statements): Represents the total number of executable statements in the codebase, including lines of code that are evaluated during testing.
- Miss (Missed Statements): Indicates the number of statements that were not executed during testing. This typically occurs when certain parts of the code were not covered by the test cases.
- Cover (Coverage Percentage): Shows the percentage of statements that were executed during testing out of the total executable statements. It is calculated as (Stmts - Miss) / Stmts * 100.
Name Stmts Miss Cover
-------------------------------------------------------------------------------------------
books\__init__.py 0 0 100%
books\admin.py 3 2 33%
books\apps.py 4 0 100%
books\migrations\0001_initial.py 5 0 100%
books\migrations\__init__.py 0 0 100%
books\models.py 12 1 92%
books\permissions.py 4 0 100%
books\serializers.py 6 0 100%
books\tests\__init__.py 0 0 100%
books\tests\test_book_api.py 72 0 100%
books\urls.py 6 0 100%
books\views.py 8 0 100%
borrowings\__init__.py 0 0 100%
borrowings\admin.py 7 6 14%
borrowings\apps.py 4 0 100%
borrowings\migrations\0001_initial.py 7 0 100%
borrowings\migrations\0002_borrowing_borrow_date_not_past_and_more.py 7 0 100%
borrowings\migrations\0003_remove_borrowing_borrow_date_not_past.py 4 0 100%
borrowings\migrations\__init__.py 0 0 100%
borrowings\models.py 27 2 93%
borrowings\serializers.py 44 0 100%
borrowings\tests\__init__.py 0 0 100%
borrowings\tests\test_borrowing_api.py 137 0 100%
borrowings\urls.py 6 0 100%
borrowings\views.py 49 0 100%
library_service_api\__init__.py 0 0 100%
library_service_api\settings.py 26 0 100%
library_service_api\urls.py 4 0 100%
manage.py 12 2 83%
telegram_api\__init__.py 0 0 100%
telegram_api\telegram_helper.py 12 2 83%
users\__init__.py 0 0 100%
users\admin.py 12 11 8%
users\apps.py 4 0 100%
users\migrations\0001_initial.py 7 0 100%
users\migrations\__init__.py 0 0 100%
users\models.py 36 8 78%
users\serializers.py 17 7 59%
users\tests\__init__.py 0 0 100%
users\tests\test_user_api.py 0 0 100%
users\urls.py 5 0 100%
users\views.py 13 1 92%
-------------------------------------------------------------------------------------------
TOTAL 560 42 92%
- Python 3.10 must be already installed.
- Clone the repository.
- Set up environment variables using ".env.sample" as a guide.
- Run the application.
- Feel free to explore and contribute!
git clone https://github.com/ArtemLeo/library-service-api.git
(for Windows)
python -m venv venv
source venv/Scripts/activate
(for Mac/Linux)
python3 -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
set DJANGO_SECRET_KEY=<your django secret key>
set DJANGO_ALLOWED_HOSTS=<your allowed hosts>
set DJANGO_DEBUG=<your debug value>
set TELEGRAM_BOT_TOKEN=<your telegram secret key>
set TELEGRAM_CHAT_ID=<your telegram chat id>
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
- create a user via /api/user/register
- get access token via /api/user/token