diff --git a/Dockerfile b/Dockerfile index 08db488..96c10bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,5 +7,6 @@ RUN pip3 install -r /requirements.txt; \ ADD app /app VOLUME ["/data"] +VOLUME ["/app/config] EXPOSE 5000 ENTRYPOINT python3 /app/main.py diff --git a/README.md b/README.md index 5054800..c0aff72 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,14 @@ ## build `docker build --tag=$(basename $PWD) .` +## general configuration + +Look at *app/config/email.py.example** for the configuration of the +parameters required for sending emails. Copy the file as *email.py* to +a folder that will serve as configuration directory and fill in the +information. The directory will be used as volume during container +operation. + ## run in development Include the development version of the code as volume, so the app gets @@ -10,7 +18,7 @@ reloaded automatically. The sqlite file will be stored in *tmp* so it can be inspected with tools like *sqlite3*. The switch *DEBUG* enables debugging during development. -`docker run --name rollerverbrauch -ti -v `pwd`/app:/app -v /tmp/pitstops/:/data -e DEBUG=True -p 5000:5000 rollerverbrauch` +`docker run --rm --name rollerverbrauch -ti -v `pwd`/app:/app -v `pwd`/../rollerverbrauch_config:/app/config -v /tmp/pitstops/:/data -e DEBUG=True -p 5000:5000 rollerverbrauch` ## run in production -`docker run --name pitstops -d -v /data/pitstops/:/data -p 80:5000 rollerverbrauch` \ No newline at end of file +`docker run --name pitstops -d -v /data/pitstops/:/data -v /configs/pitstops/:/app/config -p 80:5000 rollerverbrauch` diff --git a/app/main.py b/app/main.py index 4a75aa5..4dfe233 100644 --- a/app/main.py +++ b/app/main.py @@ -1,5 +1,4 @@ from datetime import date -from datetime import datetime from flask import Flask from flask import render_template, make_response from flask import request, redirect, g @@ -7,9 +6,7 @@ from flask import url_for from flask_sqlalchemy import SQLAlchemy from flask.ext.security import Security, SQLAlchemyUserDatastore, \ UserMixin, RoleMixin, login_required, utils -import uuid -import hashlib -from functools import wraps +from flask.ext.mail import Mail, Message from flask_wtf import Form from wtforms import DateField, IntegerField, DecimalField from wtforms.validators import DataRequired, ValidationError @@ -23,8 +20,12 @@ db = SQLAlchemy(app) app.config['SECRET_KEY'] = 'development key' app.config['SECURITY_PASSWORD_HASH'] = 'pbkdf2_sha512' app.config['SECURITY_PASSWORD_SALT'] = 'xxxxxxxxxxxxxxxxxxxxxx' +app.config['SECURITY_REGISTERABLE'] = True +app.config['SECURITY_EMAIL_SENDER'] = 'pitstops@lusiardi.de' +app.config.from_object('config.email') app.config.from_object(__name__) +mail = Mail(app) roles_users = db.Table('roles_users', db.Column('user_id', db.Integer(), db.ForeignKey('user.id')), @@ -77,6 +78,7 @@ class Pitstop(db.Model): user_datastore = SQLAlchemyUserDatastore(db, User, Role) security = Security(app, user_datastore) + @app.before_first_request def before_first_request(): db.create_all() diff --git a/app/templates/layout.html b/app/templates/layout.html index f6ada95..d0ea304 100644 --- a/app/templates/layout.html +++ b/app/templates/layout.html @@ -1,9 +1,12 @@ {% macro navigation() -%} -