registrierung wurde hinzugefügt
This commit is contained in:
parent
ba16743fde
commit
4384d18fab
|
@ -39,6 +39,7 @@ 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)
|
||||
|
@ -46,3 +47,4 @@ app.register_blueprint(finanzer)
|
|||
app.register_blueprint(user)
|
||||
app.register_blueprint(vorstand)
|
||||
app.register_blueprint(gastrouser)
|
||||
app.register_blueprint(registration)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from ..mainController import Singleton
|
||||
from geruecht import db
|
||||
from ..databaseController import dbUserController, dbCreditListController, dbJobKindController, dbPricelistController, dbWorkerController, dbWorkgroupController, dbJobInviteController, dbJobRequesController, dbAccessTokenController
|
||||
from ..databaseController import dbUserController, dbCreditListController, dbJobKindController, dbPricelistController, dbWorkerController, dbWorkgroupController, dbJobInviteController, dbJobRequesController, dbAccessTokenController, dbRegistrationController
|
||||
from geruecht.exceptions import DatabaseExecption
|
||||
import traceback
|
||||
from MySQLdb._exceptions import IntegrityError
|
||||
|
@ -14,6 +14,7 @@ class DatabaseController(dbUserController.Base,
|
|||
dbJobInviteController.Base,
|
||||
dbJobRequesController.Base,
|
||||
dbAccessTokenController.Base,
|
||||
dbRegistrationController.Base,
|
||||
metaclass=Singleton):
|
||||
'''
|
||||
DatabaesController
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import traceback
|
||||
from geruecht.exceptions import DatabaseExecption
|
||||
|
||||
class Base:
|
||||
def setNewRegistration(self, data):
|
||||
try:
|
||||
cursor = self.db.connection.cursor()
|
||||
if data['entryDate']:
|
||||
sql = "insert into registration_list (firstname, lastname, clubname, email, keynumber, birthdate, entrydate) VALUES ('{}', '{}', '{}', '{}', {}, '{}', '{}')".format(
|
||||
data['firstName'],
|
||||
data['lastName'],
|
||||
data['clubName'] if data['clubName'] else 'NULL',
|
||||
data['mail'],
|
||||
data['keynumber'] if data['keynumber'] else 'NULL',
|
||||
data['birthDate'],
|
||||
data['entryDate']
|
||||
)
|
||||
else:
|
||||
sql = "insert into registration_list (firstname, lastname, clubname, email, keynumber, birthdate) VALUES ('{}', '{}', '{}', '{}', {}, '{}')".format(
|
||||
data['firstName'],
|
||||
data['lastName'],
|
||||
data['clubName'] if data['clubName'] else 'NULL',
|
||||
data['mail'],
|
||||
data['keynumber'] if data['keynumber'] else 'NULL',
|
||||
data['birthDate']
|
||||
)
|
||||
cursor.execute(sql)
|
||||
self.db.connection.commit()
|
||||
except Exception as err:
|
||||
traceback.print_exc()
|
||||
self.db.connection.rollback()
|
||||
raise DatabaseExecption("Something went worng with Databes: {}".format(err))
|
|
@ -5,7 +5,7 @@ import geruecht.controller.emailController as ec
|
|||
from geruecht.model.user import User
|
||||
from datetime import datetime, timedelta
|
||||
from geruecht.logger import getDebugLogger
|
||||
from ..mainController import mainJobKindController, mainCreditListController, mainPricelistController, mainUserController, mainWorkerController, mainWorkgroupController, mainJobInviteController, mainJobRequestController
|
||||
from ..mainController import mainJobKindController, mainCreditListController, mainPricelistController, mainUserController, mainWorkerController, mainWorkgroupController, mainJobInviteController, mainJobRequestController, mainRegistrationController
|
||||
|
||||
db = dc.DatabaseController()
|
||||
ldap = lc.LDAPController()
|
||||
|
@ -22,6 +22,7 @@ class MainController(mainJobKindController.Base,
|
|||
mainWorkgroupController.Base,
|
||||
mainJobInviteController.Base,
|
||||
mainJobRequestController.Base,
|
||||
mainRegistrationController.Base,
|
||||
metaclass=Singleton):
|
||||
|
||||
def __init__(self):
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
from datetime import date
|
||||
|
||||
import geruecht.controller.databaseController as dc
|
||||
from geruecht.logger import getDebugLogger
|
||||
|
||||
db = dc.DatabaseController()
|
||||
debug = getDebugLogger()
|
||||
|
||||
class Base:
|
||||
def setNewRegistration(self, data):
|
||||
debug.info("set new registration {{ {} }}".format(data))
|
||||
data['birthDate'] = date(int(data['birthDate']['year']), int(data['birthDate']['month']), int(data['birthDate']['day']))
|
||||
data['entryDate'] = date(int(data['entryDate']['year']), int(data['entryDate']['month']), int(data['entryDate']['day'])) if data['entryDate'] else None
|
||||
db.setNewRegistration(data)
|
|
@ -0,0 +1,15 @@
|
|||
from flask import Blueprint, request, jsonify
|
||||
import geruecht.controller.mainController as mc
|
||||
from geruecht.logger import getDebugLogger
|
||||
|
||||
registration = Blueprint("registration", __name__)
|
||||
|
||||
mainController = mc.MainController()
|
||||
|
||||
debug = getDebugLogger()
|
||||
|
||||
@registration.route("/registration", methods=['PUT'])
|
||||
def __registration():
|
||||
data = request.get_json()
|
||||
mainController.setNewRegistration(data)
|
||||
return jsonify({"ok":"ok"})
|
Loading…
Reference in New Issue