Merge branch 'pycharm' into 'development'
Fixed project structure for pycharm See merge request !16
@ -1,12 +1,14 @@
|
||||
FROM debian8_python3
|
||||
|
||||
COPY app/requirements.txt /requirements.txt
|
||||
COPY requirements.txt /requirements.txt
|
||||
RUN pip3 install -r /requirements.txt; \
|
||||
mkdir /data
|
||||
|
||||
ADD app /app
|
||||
ADD main.py /main.py
|
||||
ADD config.py /config.py
|
||||
|
||||
VOLUME ["/data"]
|
||||
VOLUME ["/app/config]
|
||||
EXPOSE 5000
|
||||
ENTRYPOINT python3 /app/main.py
|
||||
ENTRYPOINT python3 /main.py
|
||||
|
@ -26,8 +26,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 --rm --name rollerverbrauch -ti -v $PWD/app:/app -v $PWD/../rollerverbrauch_config:/app/config -v /tmp/pitstops/:/data -e DEBUG=True -e config=../config/config.py --link pitstops_db:database -p 5000:5000 rollerverbrauch`
|
||||
|
||||
`docker run --rm --name rollerverbrauch -ti -v $PWD/app:/app --link pitstops_db:database -p 5000:5000 -e SECURITY_PASSWORD_SALT=XXX -e SECRET_KEY=XXX -e MAIL_SERVER=XXX -e MAIL_USERNAME=XXX -e MAIL_PASSWORD=XXX rollerverbrauch`
|
||||
## run in production
|
||||
`docker run --name pitstops -d -v /data/pitstops/:/data -v /configs/pitstops/:/app/config -p 80:5000 rollerverbrauch`
|
||||
|
||||
|
@ -1,31 +1,21 @@
|
||||
from datetime import date
|
||||
|
||||
from flask import Flask
|
||||
from flask import redirect, g
|
||||
from flask import render_template
|
||||
from flask import url_for
|
||||
from flask.ext.mail import Mail
|
||||
from flask.ext.security import Security, SQLAlchemyUserDatastore, \
|
||||
UserMixin, RoleMixin, login_required, roles_required
|
||||
from flask.ext.security import user_registered
|
||||
from flask_mail import Mail
|
||||
from flask_security import Security, SQLAlchemyUserDatastore, \
|
||||
login_required, roles_required, user_registered
|
||||
from flask_security.core import current_user
|
||||
from flask_security.forms import LoginForm
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
import os
|
||||
from config import config
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from flask.ext.security.forms import LoginForm
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['SECURITY_PASSWORD_HASH'] = 'pbkdf2_sha512'
|
||||
app.config['SECURITY_REGISTERABLE'] = True
|
||||
app.config['SECURITY_CHANGEABLE'] = True
|
||||
app.config['SECURITY_RECOVERABLE'] = True
|
||||
app.config.from_envvar('config')
|
||||
app.config.from_object(__name__)
|
||||
|
||||
db = SQLAlchemy(app)
|
||||
mail = Mail(app)
|
||||
|
||||
import rollerverbrauch.tools as tools
|
||||
|
||||
from rollerverbrauch.forms import \
|
||||
from .forms import \
|
||||
CreatePitstopForm, \
|
||||
EditVehicleForm, \
|
||||
DeleteVehicleForm, \
|
||||
@ -38,7 +28,14 @@ from rollerverbrauch.forms import \
|
||||
DeletConsumableForm, \
|
||||
SelectConsumableForm
|
||||
|
||||
from rollerverbrauch.entities import \
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(config[os.getenv('FLASK_CONFIG') or 'default'])
|
||||
|
||||
db = SQLAlchemy(app)
|
||||
mail = Mail(app)
|
||||
|
||||
from .entities import \
|
||||
User, \
|
||||
Role, \
|
||||
Pitstop, \
|
||||
@ -46,7 +43,8 @@ from rollerverbrauch.entities import \
|
||||
Consumable
|
||||
|
||||
# required to activate the filters
|
||||
import rollerverbrauch.filters
|
||||
from .filters import *
|
||||
from .tools import *
|
||||
|
||||
|
||||
user_datastore = SQLAlchemyUserDatastore(db, User, Role)
|
||||
@ -92,7 +90,7 @@ def index():
|
||||
kilometers = 0
|
||||
for vehicle in vehicles:
|
||||
stats = tools.VehicleStats(vehicle)
|
||||
litres += stats.overall_litres
|
||||
#litres += stats.overall_litres
|
||||
kilometers += stats.overall_distance
|
||||
vehicle_count = len(vehicles)
|
||||
pitstop_count = len(Pitstop.query.all())
|
@ -1,5 +1,5 @@
|
||||
from rollerverbrauch import db
|
||||
from flask.ext.security import UserMixin, RoleMixin
|
||||
from app import db
|
||||
from flask_security import UserMixin, RoleMixin
|
||||
|
||||
roles_users = db.Table('roles_users',
|
||||
db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
|
@ -1,4 +1,4 @@
|
||||
from rollerverbrauch import app
|
||||
from app import app
|
||||
import hashlib
|
||||
|
||||
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 980 B After Width: | Height: | Size: 980 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
@ -1,8 +1,7 @@
|
||||
import logging
|
||||
from datetime import date
|
||||
|
||||
from rollerverbrauch.entities import \
|
||||
Pitstop
|
||||
from .entities import Pitstop
|
||||
|
||||
|
||||
class ConsumableStats:
|
46
config.py
Normal file
@ -0,0 +1,46 @@
|
||||
import os
|
||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
class Config:
|
||||
SECURITY_PASSWORD_HASH = 'pbkdf2_sha512'
|
||||
SECURITY_REGISTERABLE = True
|
||||
SECURITY_CHANGEABLE = True
|
||||
SECURITY_RECOVERABLE = True
|
||||
SECURITY_PASSWORD_SALT = os.environ.get('SECURITY_PASSWORD_SALT') or 'SOME SECRET STRING'
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY') or 'SOME SECRET STRING'
|
||||
SECURITY_EMAIL_SENDER = 'no-reply@lusiardi.de'
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
MAIL_SERVER = 'mail.nerd2nerd.org'
|
||||
MAIL_PORT = 25
|
||||
MAIL_USE_TLS = True
|
||||
MAIL_USE_SSL = False
|
||||
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
|
||||
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
|
||||
|
||||
@staticmethod
|
||||
def init_app(app):
|
||||
pass
|
||||
|
||||
|
||||
class DevelopmentConfig(Config):
|
||||
SECURITY_SEND_REGISTER_EMAIL = False
|
||||
DEBUG = True
|
||||
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:%s@database/pitstops_old' % (os.environ['DATABASE_ENV_MYSQL_ROOT_PASSWORD'])
|
||||
|
||||
|
||||
class TestingConfig(Config):
|
||||
TESTING = True
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'data_testing.sqlite')
|
||||
|
||||
|
||||
class ProductionConfig(Config):
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'data.sqlite')
|
||||
|
||||
|
||||
config = {
|
||||
'development': DevelopmentConfig,
|
||||
'testing': TestingConfig,
|
||||
'production': ProductionConfig,
|
||||
'default': DevelopmentConfig
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import os
|
||||
from rollerverbrauch import app
|
||||
from app import app
|
||||
import logging
|
||||
|
||||
|