Fixed project structure for pycharm

This commit is contained in:
Joachim Lusiardi 2016-07-03 19:29:30 +02:00
parent 820063837d
commit 738bcb9f89
48 changed files with 71 additions and 28 deletions

View File

@ -1,12 +1,14 @@
FROM debian8_python3 FROM debian8_python3
COPY app/requirements.txt /requirements.txt COPY requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt; \ RUN pip3 install -r /requirements.txt; \
mkdir /data mkdir /data
ADD app /app ADD app /app
ADD main.py /main.py
ADD config.py /config.py
VOLUME ["/data"] VOLUME ["/data"]
VOLUME ["/app/config] VOLUME ["/app/config]
EXPOSE 5000 EXPOSE 5000
ENTRYPOINT python3 /app/main.py ENTRYPOINT python3 /main.py

View File

@ -1,30 +1,19 @@
from datetime import date from datetime import date
from flask import Flask from flask import Flask
from flask import redirect, g from flask import redirect, g
from flask import render_template from flask import render_template
from flask import url_for from flask import url_for
from flask.ext.mail import Mail from flask_mail import Mail
from flask.ext.security import Security, SQLAlchemyUserDatastore, \ from flask_security import Security, SQLAlchemyUserDatastore, \
UserMixin, RoleMixin, login_required, roles_required login_required, roles_required, user_registered
from flask.ext.security import user_registered
from flask_security.core import current_user from flask_security.core import current_user
from flask_security.forms import LoginForm
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from flask.ext.security.forms import LoginForm import os
from config import config
app = Flask(__name__) from .forms import \
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 \
CreatePitstopForm, \ CreatePitstopForm, \
EditVehicleForm, \ EditVehicleForm, \
DeleteVehicleForm, \ DeleteVehicleForm, \
@ -32,15 +21,22 @@ from rollerverbrauch.forms import \
DeleteAccountForm, \ DeleteAccountForm, \
DeletePitStopForm, \ DeletePitStopForm, \
EditPitstopForm EditPitstopForm
from .tools import *
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, \ User, \
Role, \ Role, \
Pitstop, \ Pitstop, \
Vehicle Vehicle
from .filters import *
#import rollerverbrauch.tools as tools
# required to activate the filters # required to activate the filters
import rollerverbrauch.filters
user_datastore = SQLAlchemyUserDatastore(db, User, Role) user_datastore = SQLAlchemyUserDatastore(db, User, Role)

View File

@ -1,5 +1,5 @@
from rollerverbrauch import db from app import db
from flask.ext.security import UserMixin, RoleMixin from flask_security import UserMixin, RoleMixin
roles_users = db.Table('roles_users', roles_users = db.Table('roles_users',
db.Column('user_id', db.Integer(), db.ForeignKey('user.id')), db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),

View File

@ -1,4 +1,4 @@
from rollerverbrauch import app from app import app
import hashlib import hashlib

View File

@ -31,6 +31,7 @@ def edit_costs_check(form, field):
if costs_check_required and field.data is not None and field.data <= 0: if costs_check_required and field.data is not None and field.data <= 0:
raise ValidationError('Costs must be above 0.01 €.') raise ValidationError('Costs must be above 0.01 €.')
class SelectVehicleForm(Form): class SelectVehicleForm(Form):
vehicle = SelectField('Vehicle', coerce=int) vehicle = SelectField('Vehicle', coerce=int)
submit = SubmitField(label='Do it!') submit = SubmitField(label='Do it!')

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 980 B

After

Width:  |  Height:  |  Size: 980 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

44
config.py Normal file
View File

@ -0,0 +1,44 @@
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'
SQLALCHEMY_TRACK_MODIFICATIONS = False
MAIL_SERVER = 'smtp.googlemail.com'
MAIL_PORT = 587
MAIL_USE_TLS = True
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 = 'sqlite:///' + os.path.join(basedir, 'data_dev.sqlite')
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
}

View File

@ -1,5 +1,5 @@
import os import os
from rollerverbrauch import app from app import app
import logging import logging