/test_news

Primary LanguageJavaScript

TEST_NEWS

A simple python backend service "News blog with nested comments".

Tested on Ubuntu 20.04 and
Python==3.8.10
Django==4.0.4
django_environ==0.8.1
django_mptt==0.13.4
environ==1.0
requests==2.27.1
pip==22.0.4

CONTENTS:

Description
Deploy
Test

Description

The system have API methods that provide:

  • ✓ Adding an article.

  • ✓ Adding a comment to an article.

  • ✓ Adding a comment in response to another comment (any nesting is possible).

  • × Retrieve all comments on an article up to 3 levels of nesting.
    ✓ Retrieve all comments on an article up to 20 levels of nesting.

  • ✓ Retrieve all nested comments for a level 3 comment.

  • × A tree structure can be recreated from the comment API response.
    ✓ A tree structure is recreated from the comment API response. Via html, css, js.

Non-functional properties:

  • ✓ Using Django ORM.
  • ✓ Following the principles of REST.
  • ✓ The number of queries to the database doesn't directly depend on the number of comments, nesting level.
  • ✓ Solution in the form of a repository on Github.
  • ✓ README.md, which shows how to build and run the project.
  • ✓ Specify dependencies in requirements.txt.
  • ✓ Using the latest versions of python and Django.

Additionally:

  • × Using PostgreSQL.
  • ✓ docker-compose to run api and database.
  • × Swagger or other API documentation.

Getting Started

These instructions will get you a copy of the project up and running on your local machine. There are two ways to run a project.

  1. run without Docker
  2. run with Docker

Build Without Docker

Git

Clone the repository

git clone https:github.com/Alexander671/test_news

Navigate into the test_news directory

cd test_news/test_news

.env file

For correct work you need to create .env file in ~/PROJECT_DIR/test_news/test_news/.env with the following content:

nano .env 
SECRET_KEY = <your_secret_key>
DEBUG = <True/False>
ALLOWED_HOSTS = <list_hosts>

Dependencies

Install, using pip:

pip install -r requirements.txt

Usage

python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py runserver

Build Using Docker

Git

Clone the repository

git clone https:github.com/Alexander671/test_news

Navigate into the test_news directory

cd test_news/test_news

.env file

For correct work you need to create .env file in ~/PROJECT_DIR/test_news/test_news/.env with the following content:

nano .env 
SECRET_KEY = <your_secret_key>
DEBUG = <True/False>
ALLOWED_HOSTS = <list_hosts>

Usage

  1. Build the image

docker build .

  1. Сompiling the image with the team

docker-compose build

  1. Run container:

docker-compose up -d

Some examples and test

Some edge-cases examples are available on the examples folder.

Authors