Update readme and gitignore
This commit is contained in:
parent
9283638ba8
commit
db20d9730b
|
@ -1,124 +1,20 @@
|
|||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
# Django #
|
||||
*.log
|
||||
*.pot
|
||||
*.pyc
|
||||
__pycache__
|
||||
db.sqlite3
|
||||
*.sql
|
||||
media
|
||||
*.yaml
|
||||
*.json
|
||||
staticfiles/
|
||||
.coverage
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
bin/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
# Python #
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
|
@ -127,60 +23,29 @@ venv/
|
|||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
data/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
# Visual Studio Code #
|
||||
.vscode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.tox/
|
||||
.coverage
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
# Mr Developer
|
||||
.mr.developer.cfg
|
||||
.project
|
||||
.pydevproject
|
||||
|
||||
# Rope
|
||||
.ropeproject
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
*.pot
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# OS X
|
||||
# Mac OS
|
||||
.DS_Store
|
||||
|
||||
# Project Specific
|
||||
static/js/plugins/fullcalendar/locales/*
|
||||
static/js/plugins/fullcalendar/locales-all.js
|
||||
static/js/plugins/fullcalendar/locales-all.min.js
|
||||
|
||||
*.db
|
||||
*.bkp
|
||||
*.drawio*
|
||||
*.docx
|
||||
*.pdf
|
||||
|
||||
tested_solution*
|
126
README.md
126
README.md
|
@ -18,3 +18,129 @@ un PDF généré automatiquement pour facturer un client.
|
|||
La génération est assez simple : elle prend toutes les prestations d'un contrat (pour un seul
|
||||
client) et en fait un PDF avec le détail des prestations, l'acompte, … et indique sur quel
|
||||
compte payer ainsi que la communication à utiliser lors de ce versement.
|
||||
|
||||
## Déploiement en local (Docker)
|
||||
|
||||
- installer Docker (+ drivers PGSQL)
|
||||
- créer un fichier `docker-compose.yml` :
|
||||
```
|
||||
version: "3"
|
||||
services:
|
||||
db:
|
||||
image: "postgres:14"
|
||||
restart: always
|
||||
container_name: "compta_inde_db_container"
|
||||
environment:
|
||||
POSTGRES_DB: "compta_inde_db"
|
||||
POSTGRES_USER: "Greg&Arnaud"
|
||||
POSTGRES_PASSWORD: "K&kP4t4t0r1!"
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- ./data:/var/lib/postgresql/data
|
||||
```
|
||||
- tapez la commande `docker-compose up -d`
|
||||
- `pip install -r requirements.txt`
|
||||
- `python manage.py createsuperuser`
|
||||
- `python manage.py runserver`
|
||||
|
||||
Aller dans l'administration de django -> Group. Là, il faut créer deux groupes : "trainer" et "gymnast".
|
||||
Ensuite, attribuer au super user créé le groupe "trainer".
|
||||
|
||||
### Installation de weasyprint
|
||||
En plus du `pip install weasyprint` et `pip install django-weasyprint`, il faut installer weasyprint (via homebrew, …)
|
||||
puis, **pour les mac M1** exécuter les commandes :
|
||||
```bash
|
||||
sudo ln -s /opt/homebrew/opt/glib/lib/libgobject-2.0.0.dylib /usr/local/lib/gobject-2.0
|
||||
sudo ln -s /opt/homebrew/opt/pango/lib/libpango-1.0.dylib /usr/local/lib/pango-1.0
|
||||
sudo ln -s /opt/homebrew/opt/harfbuzz/lib/libharfbuzz.dylib /usr/local/lib/harfbuzz
|
||||
sudo ln -s /opt/homebrew/opt/fontconfig/lib/libfontconfig.1.dylib /usr/local/lib/fontconfig-1
|
||||
sudo ln -s /opt/homebrew/opt/pango/lib/libpangoft2-1.0.dylib /usr/local/lib/pangoft2-1.0
|
||||
```
|
||||
|
||||
### Tests
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Pylint
|
||||
|
||||
Dans le répertoire racine, tapez la commande suivante :
|
||||
|
||||
```bash
|
||||
pylint ./jarvis/followup
|
||||
```
|
||||
|
||||
### Djlint
|
||||
(à venir)
|
||||
|
||||
### Coverage
|
||||
```bash
|
||||
pip install coverage
|
||||
```
|
||||
|
||||
#### Configuration
|
||||
```bash
|
||||
touch .coveragerc
|
||||
vim .coveragerc
|
||||
```
|
||||
|
||||
Ajoutez les lignes suivantes :
|
||||
|
||||
```bash
|
||||
omit = *__init__.py,*/migrations/*,*test*,*settings*,*urls*,*wsgi*,manage.py,*apps*
|
||||
```
|
||||
|
||||
#### Utilisation
|
||||
|
||||
```bash
|
||||
coverage run -m pytest
|
||||
```
|
||||
|
||||
|
||||
## Déploiement sur Heroku
|
||||
|
||||
- Créer l'application sur Heroku
|
||||
|
||||
- Ajouter le Buildpacks : heroku/python
|
||||
|
||||
- Créer les variables d'environnement :
|
||||
- ALLOWED_HOSTS : <a-definir>
|
||||
- DATABASE_NAME : compta_inde_db
|
||||
- DISABLE_COLLECTSTATIC : 1
|
||||
- SECRET_KEY : mvu)=%+ocv3n9dljxq0===$v!01@rw2j$++i&h6#65cu1#0ff@
|
||||
- DATABASE_URL : créé automatiquement lorsqu'on ajoute l' `element` PostgreSQL
|
||||
|
||||
Exemple :
|
||||
|
||||
```
|
||||
heroku config:set DISABLE_COLLECTSTATIC="1"
|
||||
heroku config:set ALLOWED_HOSTS="<a-definir>"
|
||||
heroku config:set SECRET_KEY="mvu)=%+ocv3n9dljxq0===$v!01@rw2j$++i&h6#65cu1#0ff@"
|
||||
heroku config:set DATABASE_NAME="compta_inde_db"
|
||||
```
|
||||
|
||||
- Se connecter à Héroku (via l'invite de commande) : `heroku login`
|
||||
|
||||
- Ajouter Heroku à Git : `git remote add heroku https://git.heroku.com/comptainde.git`
|
||||
|
||||
- Push de l'application : `git push heroku master`
|
||||
|
||||
- Création du super user : `heroku run python manage.py createsuperuser`
|
||||
|
||||
|
||||
## Récupération des données :
|
||||
Pour transferer des données d'un site à un autre, le plus simple est d'utiliser la commande
|
||||
`./manage.py dumpdata > db.json`.
|
||||
|
||||
Pour ne pas récupérer les user, les authorisation et les content-type, utilisez la commande :
|
||||
|
||||
```bash
|
||||
python manage.py dumpdata --natural-foreign --exclude contenttypes --exclude auth.permission --exclude admin.logentry --exclude sessions.session --indent 4 > save.json
|
||||
```
|
||||
|
||||
Pour charger les données, tapez ensuite :
|
||||
```bash
|
||||
python manage.py loaddata save.json
|
||||
```
|
Loading…
Reference in New Issue