diff --git a/flaschengeist/.app.py.swp b/flaschengeist/.app.py.swp new file mode 100644 index 0000000..cfc7fad Binary files /dev/null and b/flaschengeist/.app.py.swp differ diff --git a/flaschengeist/__init__.py b/flaschengeist/__init__.py new file mode 100644 index 0000000..2cbd85f --- /dev/null +++ b/flaschengeist/__init__.py @@ -0,0 +1,5 @@ +""" Server-package +""" + +from pathlib import Path +_modpath = Path(__file__).parent diff --git a/geruecht/__init__.py b/flaschengeist/app.py similarity index 61% rename from geruecht/__init__.py rename to flaschengeist/app.py index 2687a9a..3fc4b3c 100644 --- a/geruecht/__init__.py +++ b/flaschengeist/app.py @@ -4,8 +4,8 @@ Initialize also a singelton for the AccesTokenControler and start the Thread. """ -from .logger import getDebugLogger -from geruecht.controller import dbConfig, ldapConfig +from .system.logger import getDebugLogger +from .system.controller import dbConfig, ldapConfig from flask_mysqldb import MySQL from flask_ldapconn import LDAPConn import ssl @@ -19,6 +19,7 @@ from flask_cors import CORS DEBUG.info("Build APP") app = Flask(__name__) CORS(app) + app.config['SECRET_KEY'] = '0a657b97ef546da90b2db91862ad4e29' app.config['MYSQL_HOST'] = dbConfig['URL'] app.config['MYSQL_USER'] = dbConfig['user'] @@ -42,18 +43,30 @@ app.config['FORCE_ATTRIBUTE_VALUE_AS_LIST'] = True ldap = LDAPConn(app) db = MySQL(app) -from geruecht import routes -from geruecht.baruser.routes import baruser -from geruecht.finanzer.routes import finanzer -from geruecht.user.routes import user -from geruecht.vorstand.routes import vorstand -from geruecht.gastro.routes import gastrouser -from geruecht.registration_route import registration +import pkg_resources + +discovered_plugins = { + entry_point.name: entry_point.load() + for entry_point + in pkg_resources.iter_entry_points('geruecht.plugins') +} + +#from geruecht import routes +#from geruecht.baruser.routes import baruser +#from geruecht.finanzer.routes import finanzer +#from geruecht.user.routes import user +#from geruecht.vorstand.routes import vorstand +#from geruecht.gastro.routes import gastrouser +#from geruecht.registration_route import registration DEBUG.info("Registrate bluebrints") -app.register_blueprint(baruser) -app.register_blueprint(finanzer) -app.register_blueprint(user) -app.register_blueprint(vorstand) -app.register_blueprint(gastrouser) -app.register_blueprint(registration) +for k, v in discovered_plugins: + DEBUG("Register %s" % k) + app.register_blueprint(v()) + +#app.register_blueprint(baruser) +#app.register_blueprint(finanzer) +#app.register_blueprint(user) +#app.register_blueprint(vorstand) +#app.register_blueprint(gastrouser) +#app.register_blueprint(registration) diff --git a/geruecht/config.yml.example b/flaschengeist/config.example.yml similarity index 100% rename from geruecht/config.yml.example rename to flaschengeist/config.example.yml diff --git a/geruecht/logging.yml b/flaschengeist/logging.yml similarity index 100% rename from geruecht/logging.yml rename to flaschengeist/logging.yml diff --git a/flaschengeist/modules/baruser/.routes.py.swp b/flaschengeist/modules/baruser/.routes.py.swp new file mode 100644 index 0000000..c213588 Binary files /dev/null and b/flaschengeist/modules/baruser/.routes.py.swp differ diff --git a/geruecht/baruser/__init__.py b/flaschengeist/modules/baruser/__init__.py similarity index 100% rename from geruecht/baruser/__init__.py rename to flaschengeist/modules/baruser/__init__.py diff --git a/geruecht/baruser/routes.py b/flaschengeist/modules/baruser/routes.py similarity index 100% rename from geruecht/baruser/routes.py rename to flaschengeist/modules/baruser/routes.py diff --git a/geruecht/model/creditList.py b/flaschengeist/modules/creditList.py similarity index 100% rename from geruecht/model/creditList.py rename to flaschengeist/modules/creditList.py diff --git a/geruecht/finanzer/__init__.py b/flaschengeist/modules/finanzer/__init__.py similarity index 100% rename from geruecht/finanzer/__init__.py rename to flaschengeist/modules/finanzer/__init__.py diff --git a/geruecht/finanzer/routes.py b/flaschengeist/modules/finanzer/routes.py similarity index 100% rename from geruecht/finanzer/routes.py rename to flaschengeist/modules/finanzer/routes.py diff --git a/geruecht/gastro/__init__.py b/flaschengeist/modules/gastro/__init__.py similarity index 100% rename from geruecht/gastro/__init__.py rename to flaschengeist/modules/gastro/__init__.py diff --git a/geruecht/gastro/routes.py b/flaschengeist/modules/gastro/routes.py similarity index 100% rename from geruecht/gastro/routes.py rename to flaschengeist/modules/gastro/routes.py diff --git a/geruecht/registration_route.py b/flaschengeist/modules/registration_route.py similarity index 100% rename from geruecht/registration_route.py rename to flaschengeist/modules/registration_route.py diff --git a/geruecht/routes.py b/flaschengeist/modules/routes.py similarity index 100% rename from geruecht/routes.py rename to flaschengeist/modules/routes.py diff --git a/geruecht/model/user.py b/flaschengeist/modules/user.py similarity index 100% rename from geruecht/model/user.py rename to flaschengeist/modules/user.py diff --git a/geruecht/user/__init__.py b/flaschengeist/modules/user/__init__.py similarity index 100% rename from geruecht/user/__init__.py rename to flaschengeist/modules/user/__init__.py diff --git a/geruecht/user/routes.py b/flaschengeist/modules/user/routes.py similarity index 100% rename from geruecht/user/routes.py rename to flaschengeist/modules/user/routes.py diff --git a/geruecht/vorstand/__init__.py b/flaschengeist/modules/vorstand/__init__.py similarity index 100% rename from geruecht/vorstand/__init__.py rename to flaschengeist/modules/vorstand/__init__.py diff --git a/geruecht/vorstand/routes.py b/flaschengeist/modules/vorstand/routes.py similarity index 100% rename from geruecht/vorstand/routes.py rename to flaschengeist/modules/vorstand/routes.py diff --git a/flaschengeist/system/__init__.py b/flaschengeist/system/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/geruecht/configparser.py b/flaschengeist/system/configparser.py similarity index 100% rename from geruecht/configparser.py rename to flaschengeist/system/configparser.py diff --git a/flaschengeist/system/controller/.ldapController.py.swp b/flaschengeist/system/controller/.ldapController.py.swp new file mode 100644 index 0000000..673b1b5 Binary files /dev/null and b/flaschengeist/system/controller/.ldapController.py.swp differ diff --git a/geruecht/controller/__init__.py b/flaschengeist/system/controller/__init__.py similarity index 72% rename from geruecht/controller/__init__.py rename to flaschengeist/system/controller/__init__.py index b7f1734..7b2f4c6 100644 --- a/geruecht/controller/__init__.py +++ b/flaschengeist/system/controller/__init__.py @@ -1,10 +1,9 @@ -from geruecht.logger import getDebugLogger -from geruecht.configparser import ConifgParser +from ..logger import getDebugLogger +from ..configparser import ConifgParser +from flaschengeist import _modpath import os -print(os.getcwd()) - -config = ConifgParser('geruecht/config.yml') +config = ConifgParser(_modpath/'config.yml') LOGGER = getDebugLogger() diff --git a/geruecht/controller/accesTokenController.py b/flaschengeist/system/controller/accesTokenController.py similarity index 100% rename from geruecht/controller/accesTokenController.py rename to flaschengeist/system/controller/accesTokenController.py diff --git a/geruecht/controller/databaseController/__init__.py b/flaschengeist/system/controller/databaseController/__init__.py similarity index 100% rename from geruecht/controller/databaseController/__init__.py rename to flaschengeist/system/controller/databaseController/__init__.py diff --git a/geruecht/controller/databaseController/dbAccessTokenController.py b/flaschengeist/system/controller/databaseController/dbAccessTokenController.py similarity index 100% rename from geruecht/controller/databaseController/dbAccessTokenController.py rename to flaschengeist/system/controller/databaseController/dbAccessTokenController.py diff --git a/geruecht/controller/databaseController/dbCreditListController.py b/flaschengeist/system/controller/databaseController/dbCreditListController.py similarity index 100% rename from geruecht/controller/databaseController/dbCreditListController.py rename to flaschengeist/system/controller/databaseController/dbCreditListController.py diff --git a/geruecht/controller/databaseController/dbJobInviteController.py b/flaschengeist/system/controller/databaseController/dbJobInviteController.py similarity index 100% rename from geruecht/controller/databaseController/dbJobInviteController.py rename to flaschengeist/system/controller/databaseController/dbJobInviteController.py diff --git a/geruecht/controller/databaseController/dbJobKindController.py b/flaschengeist/system/controller/databaseController/dbJobKindController.py similarity index 100% rename from geruecht/controller/databaseController/dbJobKindController.py rename to flaschengeist/system/controller/databaseController/dbJobKindController.py diff --git a/geruecht/controller/databaseController/dbJobRequesController.py b/flaschengeist/system/controller/databaseController/dbJobRequesController.py similarity index 100% rename from geruecht/controller/databaseController/dbJobRequesController.py rename to flaschengeist/system/controller/databaseController/dbJobRequesController.py diff --git a/geruecht/controller/databaseController/dbPricelistController.py b/flaschengeist/system/controller/databaseController/dbPricelistController.py similarity index 100% rename from geruecht/controller/databaseController/dbPricelistController.py rename to flaschengeist/system/controller/databaseController/dbPricelistController.py diff --git a/geruecht/controller/databaseController/dbRegistrationController.py b/flaschengeist/system/controller/databaseController/dbRegistrationController.py similarity index 100% rename from geruecht/controller/databaseController/dbRegistrationController.py rename to flaschengeist/system/controller/databaseController/dbRegistrationController.py diff --git a/geruecht/controller/databaseController/dbUserController.py b/flaschengeist/system/controller/databaseController/dbUserController.py similarity index 100% rename from geruecht/controller/databaseController/dbUserController.py rename to flaschengeist/system/controller/databaseController/dbUserController.py diff --git a/geruecht/controller/databaseController/dbWorkerController.py b/flaschengeist/system/controller/databaseController/dbWorkerController.py similarity index 100% rename from geruecht/controller/databaseController/dbWorkerController.py rename to flaschengeist/system/controller/databaseController/dbWorkerController.py diff --git a/geruecht/controller/databaseController/dbWorkgroupController.py b/flaschengeist/system/controller/databaseController/dbWorkgroupController.py similarity index 100% rename from geruecht/controller/databaseController/dbWorkgroupController.py rename to flaschengeist/system/controller/databaseController/dbWorkgroupController.py diff --git a/geruecht/controller/emailController.py b/flaschengeist/system/controller/emailController.py similarity index 100% rename from geruecht/controller/emailController.py rename to flaschengeist/system/controller/emailController.py diff --git a/geruecht/controller/ldapController.py b/flaschengeist/system/controller/ldapController.py similarity index 99% rename from geruecht/controller/ldapController.py rename to flaschengeist/system/controller/ldapController.py index da3044e..e17d3e7 100644 --- a/geruecht/controller/ldapController.py +++ b/flaschengeist/system/controller/ldapController.py @@ -5,7 +5,7 @@ from geruecht.model import MONEY, USER, GASTRO, BAR, VORSTAND, EXTERN from geruecht.exceptions import PermissionDenied from . import Singleton from geruecht.exceptions import UsernameExistLDAP, LDAPExcetpion -from geruecht import ldapConfig +from . import ldapConfig from geruecht.logger import getDebugLogger debug = getDebugLogger() diff --git a/geruecht/controller/mainController/__init__.py b/flaschengeist/system/controller/mainController/__init__.py similarity index 100% rename from geruecht/controller/mainController/__init__.py rename to flaschengeist/system/controller/mainController/__init__.py diff --git a/geruecht/controller/mainController/mainCreditListController.py b/flaschengeist/system/controller/mainController/mainCreditListController.py similarity index 100% rename from geruecht/controller/mainController/mainCreditListController.py rename to flaschengeist/system/controller/mainController/mainCreditListController.py diff --git a/geruecht/controller/mainController/mainJobInviteController.py b/flaschengeist/system/controller/mainController/mainJobInviteController.py similarity index 100% rename from geruecht/controller/mainController/mainJobInviteController.py rename to flaschengeist/system/controller/mainController/mainJobInviteController.py diff --git a/geruecht/controller/mainController/mainJobKindController.py b/flaschengeist/system/controller/mainController/mainJobKindController.py similarity index 100% rename from geruecht/controller/mainController/mainJobKindController.py rename to flaschengeist/system/controller/mainController/mainJobKindController.py diff --git a/geruecht/controller/mainController/mainJobRequestController.py b/flaschengeist/system/controller/mainController/mainJobRequestController.py similarity index 100% rename from geruecht/controller/mainController/mainJobRequestController.py rename to flaschengeist/system/controller/mainController/mainJobRequestController.py diff --git a/geruecht/controller/mainController/mainPasswordReset.py b/flaschengeist/system/controller/mainController/mainPasswordReset.py similarity index 100% rename from geruecht/controller/mainController/mainPasswordReset.py rename to flaschengeist/system/controller/mainController/mainPasswordReset.py diff --git a/geruecht/controller/mainController/mainPricelistController.py b/flaschengeist/system/controller/mainController/mainPricelistController.py similarity index 100% rename from geruecht/controller/mainController/mainPricelistController.py rename to flaschengeist/system/controller/mainController/mainPricelistController.py diff --git a/geruecht/controller/mainController/mainRegistrationController.py b/flaschengeist/system/controller/mainController/mainRegistrationController.py similarity index 100% rename from geruecht/controller/mainController/mainRegistrationController.py rename to flaschengeist/system/controller/mainController/mainRegistrationController.py diff --git a/geruecht/controller/mainController/mainUserController.py b/flaschengeist/system/controller/mainController/mainUserController.py similarity index 100% rename from geruecht/controller/mainController/mainUserController.py rename to flaschengeist/system/controller/mainController/mainUserController.py diff --git a/geruecht/controller/mainController/mainWorkerController.py b/flaschengeist/system/controller/mainController/mainWorkerController.py similarity index 100% rename from geruecht/controller/mainController/mainWorkerController.py rename to flaschengeist/system/controller/mainController/mainWorkerController.py diff --git a/geruecht/controller/mainController/mainWorkgroupController.py b/flaschengeist/system/controller/mainController/mainWorkgroupController.py similarity index 100% rename from geruecht/controller/mainController/mainWorkgroupController.py rename to flaschengeist/system/controller/mainController/mainWorkgroupController.py diff --git a/geruecht/decorator.py b/flaschengeist/system/decorator.py similarity index 100% rename from geruecht/decorator.py rename to flaschengeist/system/decorator.py diff --git a/geruecht/exceptions/__init__.py b/flaschengeist/system/exceptions/__init__.py similarity index 100% rename from geruecht/exceptions/__init__.py rename to flaschengeist/system/exceptions/__init__.py diff --git a/geruecht/logger.py b/flaschengeist/system/logger.py similarity index 86% rename from geruecht/logger.py rename to flaschengeist/system/logger.py index 0348262..67c626f 100644 --- a/geruecht/logger.py +++ b/flaschengeist/system/logger.py @@ -2,6 +2,9 @@ import logging import logging.config import yaml from os import path, makedirs, getcwd +from .. import _modpath + +fname = _modpath/'logging.yml' if not path.exists("geruecht/log/debug"): a = path.join(path.curdir, "geruecht", "log", "debug") @@ -12,7 +15,7 @@ if not path.exists("geruecht/log/info"): makedirs(b) -with open("geruecht/logging.yml", 'rb') as file: +with fname.open(mode='rb') as file: config = yaml.safe_load(file.read()) logging.config.dictConfig(config) diff --git a/flaschengeist/system/model/__init__.py b/flaschengeist/system/model/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/geruecht/model/accessToken.py b/flaschengeist/system/model/accessToken.py similarity index 98% rename from geruecht/model/accessToken.py rename to flaschengeist/system/model/accessToken.py index 6e777f7..6072378 100644 --- a/geruecht/model/accessToken.py +++ b/flaschengeist/system/model/accessToken.py @@ -1,5 +1,5 @@ from datetime import datetime -from geruecht.logger import getDebugLogger +from ..logger import getDebugLogger debug = getDebugLogger() diff --git a/flaschengeist/system/model/user.py b/flaschengeist/system/model/user.py new file mode 100644 index 0000000..157a965 --- /dev/null +++ b/flaschengeist/system/model/user.py @@ -0,0 +1,49 @@ +from ..logger import getDebugLogger +from datetime import datetime +debug = getDebugLogger() + + +class User(): + """ Database Object for User + + Table for all safed User + + Attributes: + id: Id in Database as Primary Key. + username: Username of the User to Login + firstname: Firstname of the User + lastname: Lastname of the User + mail: mail address of the User + """ + def __init__(self, data): + debug.info("init user") + if 'id' in data: + self.id = int(data['id']) + self.firstname = data['firstname'] + self.lastname = data['lastname'] + if 'mail' in data: + self.mail = data['mail'] + else: + self.mail = '' + if 'username' in data: + self.username = data['username'] + else: + self.username = None + debug.debug("user is {{ {} }}".format(self)) + + def updateData(self, data): + debug.info("update data of user") + if 'firstname' in data: + self.firstname = data['firstname'] + if 'lastname' in data: + self.lastname = data['lastname'] + if 'mail' in data: + self.mail = data['mail'] + if 'username' in data: + self.username = data['username'] + + def __repr__(self): + return "User({}, {})".format(self.uid, self.username) + + +# TODO: user attributes (uid|key|value), getter, setter, has diff --git a/geruecht/model/__init__.py b/geruecht/model/__init__.py deleted file mode 100644 index 065f441..0000000 --- a/geruecht/model/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -MONEY = "moneymaster" -VORSTAND = "vorstand" -EXTERN = "extern" -GASTRO = "gastro" -USER = "user" -BAR = "bar" \ No newline at end of file diff --git a/packages.txt b/packages.txt deleted file mode 100644 index c852dc5..0000000 --- a/packages.txt +++ /dev/null @@ -1,20 +0,0 @@ -bcrypt==3.1.6 -cffi==1.12.3 -Click==7.0 -entrypoints==0.3 -flake8==3.7.7 -Flask==1.0.2 -Flask-Bcrypt==0.7.1 -Flask-Cors==3.0.7 -Flask-SQLAlchemy==2.4.0 -itsdangerous==1.1.0 -Jinja2==2.10.1 -MarkupSafe==1.1.1 -mccabe==0.6.1 -pkg-resources==0.0.0 -pycodestyle==2.5.0 -pycparser==2.19 -pyflakes==2.1.1 -six==1.12.0 -SQLAlchemy==1.3.3 -Werkzeug==0.15.2 diff --git a/required.txt b/required.txt deleted file mode 100644 index 1a818f2..0000000 --- a/required.txt +++ /dev/null @@ -1,14 +0,0 @@ -click==7.1.2 -Flask==1.1.2 -Flask-Cors==3.0.8 -Flask-LDAPConn==0.10.1 -Flask-MySQLdb==0.2.0 -itsdangerous==1.1.0 -Jinja2==2.11.2 -ldap3==2.7 -MarkupSafe==1.1.1 -mysqlclient==1.4.6 -pyasn1==0.4.8 -PyYAML==5.3.1 -six==1.15.0 -Werkzeug==1.0.1 diff --git a/run.py b/run_flaschengeist similarity index 67% rename from run.py rename to run_flaschengeist index b6d40ab..ab4b3b2 100644 --- a/run.py +++ b/run_flaschengeist @@ -1,4 +1,5 @@ -from geruecht import app +#!/usr/bin/python3 +from flaschengeist.app import app """ Main diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b142102 --- /dev/null +++ b/setup.py @@ -0,0 +1,19 @@ +from setuptools import setup, find_packages + +setup( + name='flaschengeist', + version='0.0.1', + url='https://wu5.de/redmine/projects/geruecht', + author='WU5 + Friends', + author_email='tim@groeger-clan.de', + description='Does things', + packages=find_packages(), + package_data={'': ['*.yml']}, + scripts=['run_flaschengeist'], + install_requires=['Flask >= 1.0.2', 'PyYAML>=5.3.1', "flask_mysqldb", "flask_ldapconn", "flask_cors"], + entry_points = { + 'flaschengeist.plugins': [ + 'users = flaschengeist.system.user:register' + ] + } +)