From 0035a2517da3364ecef1bb787d49f4f503b5a265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Wed, 19 Feb 2020 21:47:44 +0100 Subject: [PATCH 1/2] fixed ##178, no strange symbol in emails --- geruecht/controller/emailController.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/geruecht/controller/emailController.py b/geruecht/controller/emailController.py index 23882d8..b11eb40 100644 --- a/geruecht/controller/emailController.py +++ b/geruecht/controller/emailController.py @@ -30,10 +30,10 @@ class EmailController(): msg = MIMEMultipart() msg['From'] = self.email msg['To'] = user.mail - msg['Subject'] = Header('Gerücht, bezahle deine ￿Schulden!', 'utf-8') + msg['Subject'] = Header('Gerücht, bezahle deine Schulden!', 'utf-8') sum = user.getGeruecht(datetime.now().year).getSchulden() if sum < 0: - type = '￿Schulden' + type = 'Schulden' add = 'Bezahle diese umgehend an den Finanzer.' else: type = 'Guthaben' @@ -46,4 +46,4 @@ class EmailController(): LOGGER.debug("Sended email to {}. {}".format(user.uid, {'error': False, 'user': {'userId': user.uid, 'firstname': user.firstname, 'lastname': user.lastname}})) return {'error': False, 'user': {'userId': user.uid, 'firstname': user.firstname, 'lastname': user.lastname}} except Exception: - return {'error': True, 'user': {'userId': user.uid, 'firstname': user.firstname, 'lastname': user.lastname}} \ No newline at end of file + return {'error': True, 'user': {'userId': user.uid, 'firstname': user.firstname, 'lastname': user.lastname}} From 7038928e49a6ec5713b2fce86e81ada9916da883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Wed, 19 Feb 2020 23:11:24 +0100 Subject: [PATCH 2/2] route for baruser to storno, ##164 --- geruecht/baruser/routes.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/geruecht/baruser/routes.py b/geruecht/baruser/routes.py index 92ac2bb..a8c47a4 100644 --- a/geruecht/baruser/routes.py +++ b/geruecht/baruser/routes.py @@ -95,6 +95,37 @@ def _getUsers(**kwargs): retVal = ldap.getAllUser() return jsonify(retVal) +@baruser.route("/bar/storno", methods=['POST']) +@login_required(groups=[BAR]) +def _storno(**kwargs): + """ Function for Baruser to storno amount + + This function added to the user with the posted userID the posted amount. + + Returns: + JSON-File with userID and the amount + or ERROR 401 Permission Denied + """ + data = request.get_json() + userID = data['userId'] + amount = int(data['amount']) + + date = datetime.now() + userController.addCredit(userID, amount, year=date.year, month=date.month) + user = userController.getUser(userID) + geruecht = user.getGeruecht(year=date.year) + month = geruecht.getMonth(month=date.month) + amount = abs(month[0] - month[1]) + all = geruecht.getSchulden() + if all >= 0: + type = 'credit' + else: + type = 'amount' + dic = user.toJSON() + dic['amount'] = abs(all) + dic['type'] = type + + return jsonify(dic) @baruser.route("/barGetUser", methods=['POST']) @login_required(groups=[BAR])