Skip to content

Dashboard-Manager/job-schedule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apps Results
pre-commit pre-commit.ci status
coverage Coverage Status

Job-schedule

The project presents interactiv dashboard for managing the enterprise, employees, budget and statistics.

Needed to install

Program Version Links
Python 3.11.1 link
Docker 20.10.22 link
Poetry 1.3.2 link
Node.js 9.5.21 link
PostgreSQL 15.1 link
DBeaver 22.3.4 link

Clone the project

  git clone https://github.com/kwiats/job-schedule job-schedule

Run project

  docker-compose up --build

Run only one django container

  #run only django
  docker-compose up <container-name> --build
  # names you can use in project:
  # postgres, django, redis, frontend, celery_worker, celery_beat, flower

install only postgres

To your connection in Dbeaver or other you use:

Host: localhost
Port: 5433
Database: job-schedule
Username: job-schedule
Password: django-app

To navigate if database is builded

  #to start
  docker-compose start postgres
  #to stop
  docker-compose stop postgres

Packages

Install backend packages

  # you can use version-number or latest
  cd backend
  poetry install <package-name>@latest
  # or
  poetry install <package-name>@latest --dev
  poetry export --with production --with dev -f requirements.txt --output requirements.txt

Install frontend packages

  # you can use version-number or latest
  cd frontend
  npm i <package-name>@latest
  # or
  npm i <package-name>@latest --save-dev
  npm i # to install all frontend dependencies

If you install some new dependencies, again build app.

  docker-compose up frontend --build # to build only frontend package
  docker-compose up --build # to build full api

Backend Django

Create app in apps

  # connect container django
  cd backend
  # create new app
  python manage.py startapp <app-name>
  # move app to folder apps in project
  mv <app-name> apps

The next you need do some steps with app

  # change apps.py in your app folder
  in apps/<app-name>/apps.py change name to: "apps.<app-name>"
  # add your app to project LOCAL_APPS
  in config/settings.base LOCAL_APPS add "apps.<app-name>"
  # create urls.py in app dir and create empty urlpatterns
  in apps/<app-name> create urls.py with urlpatterns = []
  # in config urls add paths to your app
  in config/urls.py add path("api/<app-name>/", include("apps.<app-name>.urls")),

Makemigrations app

  # remove migration
  rm -rf backend/apps/<app>/migrations/
  # use if django don't stand up
  docker-compose run --rm django sh -c "python manage.py makemigrations <app-name>"
  # use when django is running
  docker-compose exec -it django sh -c "python manage.py makemigrations <app-name>"
  # if you got "No changes detected in app '<app-name>'"
  # and you dont have makemigrations folder in your app
  docker-compose run --rm django sh -c "python manage.py makemigrations --empty <app-name>"
  # if you need you can remove postgres database
  docker volume rm job_schedule_postgres_data
  # remeber you can connect commands like remove migrations and add changes in one step
  rm -rf backend/apps/<app>/migrations/ && docker-compose run --rm django python manage.py makemigrations <app-name>

Testing

Backend tests

Run tests and linters after deployment app

  # checks:pytest, coverage, mypy tests
  # -flake8, isort styles
  docker-compose exec -it django bash -c "docker/debug/run.sh"

Run one test or linter only

  # pytest
  docker-compose exec -it django pytest -s -v --no-migrations
  # coverage
  docker-compose exec -it django pytest --cov=apps --cov=config --cov-config=.coveragerc && coverage html
  # mypy
  docker-compose exec -it django mypy . --config-file mypy.ini
  # flake8
  docker-compose exec -it django flake8 . --config=setup.cfg
  # isort
  docker-compose exec -it django isort . --settings-path=.isort.cfg

You can still do this commands inside virtual enviroments like:

  docker-compose exec -it django bash

then you are logged in container as root:

  root@some_number:/some_path# flake8 . --config=setup.cfg

and do this same commands

Frontend tests

Functional tests with cypress and e2e

For functional tests you do:

  cd frontend
  npm run cypress:open

and then chose e2e tests or

  cd frontend
  npm run cypress:run

Integration tests

For integration tests, you can use two ways:

  cd frontend
  npm test

or with coverage

  cd frontend
  npm coverage

Local run frontend

  cd frontend
  npm i
  npm run dev #port 3000
  #or
  npm run local #port 5173