From 93fcbe72ae515641b35ba2fc369d57b5918a8b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Fri, 5 Jun 2020 22:53:27 +0200 Subject: [PATCH] fixed ##279 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wenn user noch nicht in der datenbank existiert, wird er hinzugefügt. wenn er noch kein gerücht besitzt, wird eins angelegt. --- geruecht/baruser/routes.py | 1 + .../databaseController/dbCreditListController.py | 10 +++++++--- .../mainController/mainUserController.py | 1 + required.txt | 15 +++++++-------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/geruecht/baruser/routes.py b/geruecht/baruser/routes.py index 61e793c..e86a6c4 100644 --- a/geruecht/baruser/routes.py +++ b/geruecht/baruser/routes.py @@ -210,3 +210,4 @@ def _lockbar(**kwargs): accToken.lock_bar = data['value'] debug.debug('return {{ "value": {} }}'.format(accToken.lock_bar)) return jsonify({'value': accToken.lock_bar}) + diff --git a/geruecht/controller/databaseController/dbCreditListController.py b/geruecht/controller/databaseController/dbCreditListController.py index f8098b5..ddbc262 100644 --- a/geruecht/controller/databaseController/dbCreditListController.py +++ b/geruecht/controller/databaseController/dbCreditListController.py @@ -3,6 +3,7 @@ from datetime import datetime from geruecht.exceptions import DatabaseExecption from geruecht.model.creditList import CreditList +from geruecht.model.user import User class Base: @@ -10,12 +11,14 @@ class Base: try: cursor = self.db.connection.cursor() if 'year' in kwargs: - sql = "select * from creditList where user_id={} and year_date={}".format(user.id, kwargs['year']) + sql = "select * from creditList where user_id={} and year_date={}".format(user.id if type(user) is User else user, kwargs['year']) else: - sql = "select * from creditList where user_id={}".format(user.id) + sql = "select * from creditList where user_id={}".format(user.id if type(user) is User else user) cursor.execute(sql) data = cursor.fetchall() - if len(data) == 1: + if len(data) == 0: + return self.createCreditList(user_id=user.id, year=datetime.now().year) + elif len(data) == 1: return [CreditList(data[0])] else: return [CreditList(value) for value in data] @@ -30,6 +33,7 @@ class Base: cursor = self.db.connection.cursor() cursor.execute("insert into creditList (year_date, user_id) values ({},{})".format(year, user_id)) self.db.connection.commit() + return self.getCreditListFromUser(user_id) except Exception as err: traceback.print_exc() self.db.connection.rollback() diff --git a/geruecht/controller/mainController/mainUserController.py b/geruecht/controller/mainController/mainUserController.py index a021a11..03371b8 100644 --- a/geruecht/controller/mainController/mainUserController.py +++ b/geruecht/controller/mainController/mainUserController.py @@ -4,6 +4,7 @@ from geruecht.exceptions import UsernameExistLDAP, LDAPExcetpion, PermissionDeni import geruecht.controller.databaseController as dc import geruecht.controller.ldapController as lc from geruecht.logger import getDebugLogger +from geruecht.model.user import User db = dc.DatabaseController() ldap = lc.LDAPController() diff --git a/required.txt b/required.txt index 9b2b3bc..1a818f2 100644 --- a/required.txt +++ b/required.txt @@ -1,15 +1,14 @@ -Click==7.0 -Flask==1.1.1 +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.0 -ldap3==2.6.1 +Jinja2==2.11.2 +ldap3==2.7 MarkupSafe==1.1.1 mysqlclient==1.4.6 pyasn1==0.4.8 -PyMySQL==0.9.3 -PyYAML==5.3 -six==1.14.0 -Werkzeug==0.16.1 +PyYAML==5.3.1 +six==1.15.0 +Werkzeug==1.0.1