diff --git a/backend/README.md b/backend/README.md new file mode 100644 index 0000000..fe936b9 --- /dev/null +++ b/backend/README.md @@ -0,0 +1,74 @@ +# OLA Flask APP + +BackEnd pour l'application du livret de l'altrenant + +## Installer les dépendances + +Required : + +* python >= 3.4 with pip (Un VirtualEnv est conseillé !) +* bower >= 1.8 + +## Python + +Si vous utiliser un virtualenv: +Creer et activerle virtualenv : + +``` + cd backend + virtualenv . + bin/activate +``` + +Installer les dépendances via pip : +``` + pip install -r requirements/common.txt +``` + + + +## Run the App + +### Fichier Configuration + +Dans app/config.py: +* Configuration les parametres de la base de données +* Changer la SECRET_KEY en production + +### Init App + +First you need to create the db and seed it with an admin user (admin@admin.com/admin). + +Migration database is handle via flask-migrate using alembic. +See command available : +``` + python manage.py db +``` + +#### Init db +Installet la derniere version de mariadb +Lancer le script : +``` + mysql -u root < ola_export.mysql +``` + + +### Launch the App + +#### For production server + +``` + python manage.py runserver +``` + +#### For Debug server + +``` + python manage.py -d runserver +``` + +## Run Tests + +``` + python manage.py runtests +``` diff --git a/backend/app/api/exampleapi/controller.py b/backend/app/api/exampleapi.py similarity index 100% rename from backend/app/api/exampleapi/controller.py rename to backend/app/api/exampleapi.py diff --git a/backend/app/api/exampleapi/model.py b/backend/app/api/exampleapi/model.py deleted file mode 100644 index 5cdc0bb..0000000 --- a/backend/app/api/exampleapi/model.py +++ /dev/null @@ -1,33 +0,0 @@ -from passlib.apps import custom_app_context as pwd_context - -from app.core import db - -users_roles = db.Table('users_roles', - db.Column('user_id', - db.Integer, - db.ForeignKey('user.id') - ), - db.Column('role_id', - db.Integer, - db.ForeignKey('role.id') - ) - ) - - -class Role(db.Model): - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(80), unique=True, nullable=False) - description = db.Column(db.String(255), nullable=False) - - -class User(db.Model): - id = db.Column(db.Integer, primary_key=True) - email = db.Column(db.String(255), index=True, unique=True, nullable=False) - password_hash = db.Column(db.String(64), nullable=False) - roles = db.relationship('Role', secondary=users_roles) - - def hash_password(self, password): - self.password_hash = pwd_context.encrypt(password) - - def verify_password(self, password): - return pwd_context.verify(password, self.password_hash) diff --git a/backend/app/fusion_pdf.py b/backend/app/tools/fusion_pdf.py similarity index 100% rename from backend/app/fusion_pdf.py rename to backend/app/tools/fusion_pdf.py