Проект YaMDb собирает отзывы пользователей на произведения. Произведения делятся на категории: «Книги», «Фильмы», «Музыка». Список категорий может быть расширен администратором.
- ✨Magic ✨Python
- Django rest_framework
- Django rest_framework_simplejwt
- Django django_filters
- Git
Клонировать репозиторий и перейти в него в командной строке:
git clone https://github.com/Margarita-pyth/api_yamdb.git
cd api_yamdb
Cоздать и активировать виртуальное окружение:
python3 -m venv env
source env/Scripts/activate
Установить зависимости из файла requirements.txt:
python3 -m pip install --upgrade pip
pip install -r requirements.txt
Выполнить миграции:
python3 manage.py migrate
Запустить проект:
python3 manage.py runserver
После запуска сервера можно ознакомится с документацией по проекту, в которой описана основная логика приложения, документация доступна по ссылке: http://127.0.0.1:8000/redoc/
Запустить файл csv2json.py в консоли, находясь в директории /c/Dev/api_yamdb/api_yamdb:
python csv2json.py
Выполнить команду в консоли:
python manage.py loaddata reviews/fixtures/*.json
- Аноним — может просматривать описания произведений, читать отзывы и комментарии.
- Аутентифицированный пользователь (user) — может читать всё, как и Аноним, может публиковать отзывы и ставить оценки произведениям (фильмам/книгам/песенкам), может комментировать отзывы; может редактировать и удалять свои отзывы и комментарии, редактировать свои оценки произведений. Эта роль присваивается по умолчанию каждому новому пользователю.
- Модератор (moderator) — те же права, что и у Аутентифицированного пользователя, плюс право удалять и редактировать любые отзывы и комментарии.
- Администратор (admin) — полные права на управление всем контентом проекта. Может создавать и удалять произведения, категории и жанры. Может назначать роли пользователям.
- Суперюзер Django должен всегда обладать правами администратора, пользователя с правами admin. Даже если изменить пользовательскую роль суперюзера — это не лишит его прав администратора. Суперюзер — всегда администратор, но администратор — не обязательно суперюзер.
- Пользователь отправляет POST-запрос с параметрами email и username на эндпоинт /api/v1/auth/signup/.
- Сервис YaMDB отправляет письмо с кодом подтверждения (confirmation_code) на указанный адрес email.
- Пользователь отправляет POST-запрос с параметрами username и confirmation_code на эндпоинт /api/v1/auth/token/, в ответе на запрос ему приходит token (JWT-токен).
- В результате пользователь получает токен и может работать с API проекта, отправляя этот токен с каждым запросом.
- После регистрации и получения токена пользователь может отправить PATCH-запрос на эндпоинт /api/v1/users/me/ и заполнить поля в своём профайле (описание полей — в документации по ссылке: http://127.0.0.1:8000/redoc/).
- Пользователя может создать администратор — через админ-зону сайта или через POST-запрос на специальный эндпоинт api/v1/users/ (описание полей запроса для этого случая — в документации).
-
- В этот момент письмо с кодом подтверждения пользователю отправлять не нужно. После этого пользователь должен самостоятельно отправить свой email и username на эндпоинт /api/v1/auth/signup/ , в ответ ему должно прийти письмо с кодом подтверждения.
- Далее пользователь отправляет POST-запрос с параметрами username и confirmation_code на эндпоинт /api/v1/auth/token/, в ответе на запрос ему приходит token (JWT-токен), как и при самостоятельной регистрации.
- auth: аутентификация.
- users: пользователи.
- titles: произведения, к которым пишут отзывы (определённый фильм, книга или песенка).
- categories: категории (типы) произведений («Фильмы», «Книги», «Музыка»).
- genres: жанры произведений. Одно произведение может быть привязано к нескольким жанрам.
- reviews: отзывы на произведения. Отзыв привязан к определённому произведению.
- comments: комментарии к отзывам. Комментарий привязан к определённому отзыву.
**Подготовлено командой разработчиков:
evgenlit, Aleksandr-Fedotov, Margarita-pyth **
The YaMDb project collects user reviews of works. The works are divided into categories: "Books", "Films", "Music". The list of categories can be expanded by the administrator.
- ✨Magic ✨Python
- Django rest_framework
- Django rest_framework_simplejwt
- Django django_filters
- Git
Clone the repository and go to it on the command line:
git clone https://github.com/Margarita-pyth/api_yamdb.git
cd api_yamdb
Create and activate a virtual environment:
python3 -m venv env
source env/Scripts/activate
Install dependencies from a file requirements.txt:
python3 -m pip install --upgrade pip
pip install -r requirements.txt
Perform migrations:
python3 manage.py migrate
Launch a project:
python3 manage.py runserver
After starting the server, you can get acquainted with the project documentation, which describes the main logic of the application, the documentation is available at the link: http://127.0.0.1:8000/redoc/
Run the file csv2json.py in the console, located in the directory /c/Dev/api_yamdb/api_yamdb:
python csv2json.py
Run the command in the console:
python manage.py loaddata reviews/fixtures/*.json
- Anonymous — can view descriptions of works, read reviews and comments.
- Authenticated user (user) — can read everything, as well as Anonymous, can publish reviews and rate works (films / books / songs), can comment on reviews; can edit and delete their reviews and comments, edit their ratings of works. This role is assigned by default to each new user.
- Moderator — the same rights as an Authenticated User, plus the right to delete and edit any reviews and comments.
- Admin — full rights to manage all the content of the project. Can create and delete works, categories and genres. Can assign roles to users.
- The Django superuser must always have administrator rights, a user with admin rights. Even if you change the user role of the superuser, it will not deprive him of administrator rights. A superuser is always an administrator, but an administrator is not necessarily a superuser.
- The user sends a POST request with the email and username parameters to the endpoint /api/v1/auth/signup/. -The YaMDB service sends an email with a confirmation code (confirmation_code) to the specified email address.
- The user sends a POST request with the username and confirmation_code parameters to the endpoint /api/v1/auth/token/, in response to the request he receives a token (JWT token).
- As a result, the user receives a token and can work with the project API by sending this token with each request.
- After registering and receiving the token, the user can send a PATCH request to the endpoint /api/v1/users/me/ and fill in the fields in his profile (the description of the fields is in the documentation at the link: http://127.0.0.1:8000/redoc /).
- The user can be created by an administrator — through the site's admin zone or through a POST request to a special api endpoint/v1/users/ (the description of the request fields for this case is in the documentation).
-
- At this point, the user does not need to send an email with a confirmation code. After that, the user must independently send his email and username to the endpoint /api/v1/auth/signup/, in response he should receive an email with a confirmation code.
- Next, the user sends a POST request with the username and confirmation_code parameters to the endpoint /api/v1/auth/token/, in response to the request, he receives a token (JWT token), as with self-registration.
- auth: authentication.
- users: users.
- titles: works that are reviewed (a certain movie, book or song).
- categories: categories (types) of works ("Movies", "Books", "Music").
- genres: genres of works. One work can be linked to several genres.
- reviews: reviews of works. The review is tied to a specific work.
- comments: comments on reviews. The comment is linked to a specific review.
**Prepared by the development team:
evgenlit, Aleksandr-Fedotov, Margarita-pyth **