task #23 erledigt

es können die User abgefragt werden, die diesen Monat noch keine Schulden haben.
es kann der user abgefragt werden
This commit is contained in:
Tim Gröger 2019-05-02 15:39:53 +02:00
parent 2427d94626
commit ee3eee6e64
1 changed files with 32 additions and 0 deletions

View File

@ -49,3 +49,35 @@ def _baradd():
return jsonify({"userId": user.userID, "amount": amount})
return jsonify({"error", "permission denied"}), 401
@baruser.route("/barGetUsers")
def _getUsers():
token = request.headers.get("Token")
print(token)
accToken = verifyAccessToken(token, BAR)
retVal = {}
if accToken is not None:
users = User.query.all()
for user in users:
month = user.getGeruecht().getMonth()
if month == 0:
retVal[user.userID] = {user.toJSON()}
return jsonify(retVal)
return jsonify({"error": "permission denied"}), 401
@baruser.route("/barGetUser", methods=['POST'])
def _getUser():
token = request.headers.get("Token")
print(token)
accToken = verifyAccessToken(token, BAR)
if accToken is not None:
data = request.get_json()
userID = data['userId']
user = User.query.filter_by(userID=userID)
month = user.getGeruecht().getMonth()
return jsonify({"userId": user.userID, "amount": month[1], "credit": month[0]})
return jsonify({"error": "permission denied"}), 401