Skip to content

8area8/work-calendar

Repository files navigation

Work Calendar

A calendar application to manage its employees.

tutorial employee creation

Stack

  • Python3 and Django Rest Framework
  • NodeJS and Nuxt.js, SCSS, Typescript, Buefy
  • PostgreSQL
  • Travis-ci
  • Heroku

Workflows

Installation

This project uses NodeJs v12 and Python v3.7. You also need a PostgreSQL database. Clone this repository, then run the following commands at the root of the repository:

# frontend installation
$ cd front && npm install && npm run generate && cd ..

# backend installation
$ pip install pipenv && pipenv install && pipenv run python manage.py migrate

The project uses some env variables. It is recommended to create an .env file at the root of the project. Pipenv will generate the virtual environment.

The environment variables are :

SECRET_KEY  # Django secret key
IS_DEBUG  # Define this variable if you want a DEBUG app

DB_USER  # database user name
DB_PASS  # database user password
DB_NAME  # database name
DB_HOST  # database host
DB_PORT  # database port

Usage

Run pipenv run python manage.py runserver then go to http://localhost:8000/

Local developement

Rather than generating the frontend at each modification, you can simply use the cd front; npm run serve command. The command will generate the front-end Nuxt server at http://localhot:3000 with the Hot Reload. Run pipenv run python manage.py runserver to launch the backend API.

Authentication system

The authentication system is strong in the backend, but very simple in the frontend. To access the administration components, all you have to do is connect with a username that is worth admin. It is therefore advisable to create a backend superuser whose name is admin.

Note : you can customize this feature in the authenticate method of the auth service (front\src\clean_architecture\services\auth.ts)

In fact, the permissions system in Frontend is based on a right variable stored in the localStorage. The admin components expect the value admin for the right variable (localStorage.getItem("right")).

Note : having access to the admin components does not allow you to have write or read admin permissions. The backend will always act as a barrier if the frontend is hacked.

Tests

The project uses :

# End2end tests
$ cd front; npm run test:e2e  # need a running server.
# Javascript unit tests
$ cd front; npm run test:unit
# Python unit tests
$ pipenv run python pytest back/tests
# Postman : import the project from the documentation
# and open your Postman application and run the tests inside.

Continuous Developement

The project uses Travis-ci. Add your fork to travis-ci.com and enjoy ! Read .travis.yml for more informations about the configuration.

Note: Travis-ci only launches unit tests, the end2end tests being very heavy to set up in CI.

Continuous Integration

Travis-ci is configured to automatically deploy the code on Heroku if the tests pass. For more information, see the documentation on this topic.

Postman documentation

The backend part of the application was designed with the Postman tool. The different use cases are exposed and some automations have been made. Get the API documentation and tests here !

deployment

At the time of deployment, it is necessary:

  • create an administrator user
  • create a simple user
  • generate the days on Django with the command pipenv run python manage.py create_initial_days

Note : use pipenv run if you are not yet in your virtual environment. Avoid it on Heroku.

Example for Heroku CLI (read the doc here) :

# In your local CLI
heroku run bash -a <your-app-name>
# In your remote CLI
python manage.py migrate
python manage.py create_initial_days
python manage.py createsuperuser
python manage.py shell
# In your Django shell
>>> from django.contrib.auth.models import User
>>> user = User.objects.create_user('user', '[email protected]', 'yourpassword')
>>> quit()
# In your remote CLI
exit

It is also necessary to install a Cron job at the start of each month to update the data (delete the oldest month and create the new one): pipenv run python manage.py update_days

Exemple for Heroku tasks scheduler (Thanks to this article):

if [ "$(date +%d)" = 01 ]; then python manage.py update_days; fi

Credits

License

MIT License - For more informations, Read the LICENSE file.

About

App for the funtains - a bar in Paris

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published