- Clone the repository:
$ git clone https://github.com/IlyaTorch/demo-test-task.git
$ cd demo-test-task
- Fill in .env file or use .env_example:
$ mv .env_example .env
- Build docker containers:
$ docker-compose up -d
- Run migrations:
$ docker exec -it documents-app bash
$ python src/manage.py makemigrations app
$ python src/manage.py migrate
- Application started. Navigate to http://127.0.0.1:8000 (documents API is here)
Follow instructions below to run only the application:
- Repeat steps 1,2 above
- Create a virtual environment:
$ pip install -U pipenv
$ pipenv shell
- Install the dependencies:
$ pipenv install --system
- Run server and navigate to http://127.0.0.1:8000
python src/manage.py runserver
- Run migrations:
$ python src/manage.py makemigrations app
$ python src/manage.py migrate
POST/api/v1/users/register/ : Sign-up
curl --location 'http://127.0.0.1:8000/api/v1/users/register/' \
--header 'Content-Type: application/json' \
--data-raw '{
"username": "new_user",
"password": "some_password",
"email": "some@mail.ru"
}'
POST/api/v1/users/token/ : Get token
curl --location 'http://127.0.0.1:8000/api/v1/users/token/' \
--header 'Content-Type: application/json' \
--data '{
"username": "new_user",
"password": "some_password"
}'
POST/api/v1/document/ : Create new document (Auth is required)
curl --location 'http://127.0.0.1:8000/api/v1/document/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
"title": "Title",
"content": "Text Example"
}'
GET/api/v1/document/ : Get document detail (Auth is required)
curl --location 'http://127.0.0.1:8000/api/v1/document/1' \
--header 'Authorization: Bearer <TOKEN>'
GET/api/v1/document/list : Get documents list, filters optional (Auth is required)
curl --location 'http://127.0.0.1:8000/api/v1/document/list?status=draft' \
--header 'Authorization: Bearer <TOKEN>'
DELETE/api/v1/document//archive/ : Archive(delete) document (Auth is required)
curl --location --request DELETE 'http://127.0.0.1:8000/api/v1/document/1/archive/' \
--header 'Authorization: Bearer <TOKEN>'
PATCH|PUT/api/v1/document/ : Update document (Auth is required)
curl --location --request PATCH 'http://127.0.0.1:8000/api/v1/document/1/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
"title": "New Title"
}'