last_seen hinzugefügt. dieser wert sagt an, wann das letzte mal vom bardienst etwas hinzugefügt wird

This commit is contained in:
Tim Gröger 2020-06-07 23:28:27 +02:00
parent 93978395e6
commit f1b957c6ea
4 changed files with 22 additions and 1 deletions

View File

@ -50,6 +50,7 @@ def _bar(**kwargs):
"type": type, "type": type,
"limit": user.limit "limit": user.limit
} }
dic[user.uid]['last_seen'] = {"year": user.last_seen.year, "month": user.last_seen.month, "day": user.last_seen.day, "hour": user.last_seen.hour, "minute": user.last_seen.minute, "second": user.last_seen.second} if user.last_seen else None
debug.debug("return {{ {} }}".format(dic)) debug.debug("return {{ {} }}".format(dic))
return jsonify(dic) return jsonify(dic)
except Exception as err: except Exception as err:
@ -89,6 +90,7 @@ def _baradd(**kwargs):
dic = user.toJSON() dic = user.toJSON()
dic['amount'] = all dic['amount'] = all
dic['type'] = type dic['type'] = type
dic['last_seen'] = {"year": user.last_seen.year, "month": user.last_seen.month, "day": user.last_seen.day, "hour": user.last_seen.hour, "minute": user.last_seen.minute, "second": user.last_seen.second} if user.last_seen else None
debug.debug("return {{ {} }}".format(dic)) debug.debug("return {{ {} }}".format(dic))
creditL.info("{} Baruser {} {} fügt {} {} {} € Schulden hinzu.".format( creditL.info("{} Baruser {} {} fügt {} {} {} € Schulden hinzu.".format(
date, kwargs['accToken'].user.firstname, kwargs['accToken'].user.lastname, user.firstname, user.lastname, amountl/100)) date, kwargs['accToken'].user.firstname, kwargs['accToken'].user.lastname, user.firstname, user.lastname, amountl/100))
@ -178,6 +180,7 @@ def _getUser(**kwargs):
retVal = user.toJSON() retVal = user.toJSON()
retVal['amount'] = amount retVal['amount'] = amount
retVal['type'] = type retVal['type'] = type
debug.debug("return {{ {} }}".format(retVal)) debug.debug("return {{ {} }}".format(retVal))
return jsonify(retVal) return jsonify(retVal)
except Exception as err: except Exception as err:

View File

@ -92,7 +92,6 @@ class Base:
def updateUser(self, user): def updateUser(self, user):
try: try:
cursor = self.db.connection.cursor() cursor = self.db.connection.cursor()
print('uid: {}; group: {}'.format(user.uid, user.group))
groups = self._convertGroupToString(user.group) groups = self._convertGroupToString(user.group)
sql = "update user set dn='{}', firstname='{}', lastname='{}', gruppe='{}', lockLimit={}, locked={}, autoLock={}, mail='{}' where uid='{}'".format( sql = "update user set dn='{}', firstname='{}', lastname='{}', gruppe='{}', lockLimit={}, locked={}, autoLock={}, mail='{}' where uid='{}'".format(
user.dn, user.firstname, user.lastname, groups, user.limit, user.locked, user.autoLock, user.mail, user.uid) user.dn, user.firstname, user.lastname, groups, user.limit, user.locked, user.autoLock, user.mail, user.uid)
@ -104,6 +103,20 @@ class Base:
self.db.connection.rollback() self.db.connection.rollback()
raise DatabaseExecption("Something went worng with Datatabase: {}".format(err)) raise DatabaseExecption("Something went worng with Datatabase: {}".format(err))
def updateLastSeen(self, user, time):
try:
cursor = self.db.connection.cursor()
sql = "update user set last_seen='{}' where uid='{}'".format(
time, user.uid)
print(sql)
cursor.execute(sql)
self.db.connection.commit()
except Exception as err:
traceback.print_exc()
self.db.connection.rollback()
raise DatabaseExecption("Something went worng with Datatabase: {}".format(err))
def changeUsername(self, user, newUsername): def changeUsername(self, user, newUsername):
try: try:
cursor= self.db.connection.cursor() cursor= self.db.connection.cursor()

View File

@ -41,6 +41,8 @@ class Base:
debug.debug("user is not locked {{ {} }} or is finanzer execution {{ {} }}".format( debug.debug("user is not locked {{ {} }} or is finanzer execution {{ {} }}".format(
user.locked, finanzer)) user.locked, finanzer))
user.addAmount(amount, year=year, month=month) user.addAmount(amount, year=year, month=month)
user.last_seen = datetime.now()
db.updateLastSeen(user, user.last_seen)
creditLists = user.updateGeruecht() creditLists = user.updateGeruecht()
debug.debug("creditList is {{ {} }}".format(creditLists)) debug.debug("creditList is {{ {} }}".format(creditLists))
for creditList in creditLists: for creditList in creditLists:

View File

@ -28,6 +28,9 @@ class User():
self.firstname = data['firstname'] self.firstname = data['firstname']
self.lastname = data['lastname'] self.lastname = data['lastname']
self.group = data['gruppe'] self.group = data['gruppe']
self.last_seen = None
if 'last_seen' in data:
self.last_seen = data['last_seen']
if 'statusgroup' in data: if 'statusgroup' in data:
self.statusgroup = data['statusgroup'] self.statusgroup = data['statusgroup']
else: else: