From c3468eea03466d66b42e3bb41d27dba39ad02b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Thu, 25 Nov 2021 10:11:41 +0100 Subject: [PATCH] [balance] revert user ssp for pull-request --- flaschengeist/controller/userController.py | 8 ++------ flaschengeist/models/user.py | 5 ----- flaschengeist/plugins/balance/routes.py | 10 +++++----- flaschengeist/plugins/users/__init__.py | 5 +---- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/flaschengeist/controller/userController.py b/flaschengeist/controller/userController.py index 7c7c237..0722d66 100644 --- a/flaschengeist/controller/userController.py +++ b/flaschengeist/controller/userController.py @@ -118,12 +118,8 @@ def modify_user(user, password, new_password=None): messageController.send_message(messageController.Message(user, text, subject)) -def get_users(userids=None): - query = User.query - if userids: - query.filter(User.userid in userids) - query = query.order_by(User.lastname.asc(), User.firstname.asc()) - return query.all() +def get_users(): + return User.query.all() def get_user_by_role(role: Role): diff --git a/flaschengeist/models/user.py b/flaschengeist/models/user.py index 095ba12..2f3ac67 100644 --- a/flaschengeist/models/user.py +++ b/flaschengeist/models/user.py @@ -104,11 +104,6 @@ class User(db.Model, ModelSerializeMixin): def has_permission(self, permission): return permission in self.get_permissions() - def __repr__(self): - return ( - f"User({self.userid}, {self.firstname}, {self.lastname}, {self.mail}, {self.display_name}, {self.birthday})" - ) - class _UserAttribute(db.Model, ModelSerializeMixin): __tablename__ = "user_attribute" diff --git a/flaschengeist/plugins/balance/routes.py b/flaschengeist/plugins/balance/routes.py index 11c7e33..b135c52 100644 --- a/flaschengeist/plugins/balance/routes.py +++ b/flaschengeist/plugins/balance/routes.py @@ -110,10 +110,7 @@ def limits(current_session: Session): Returns: JSON encoded array of userid with limit or HTTP-error """ - userids = None - if "userids" in request.args: - [x for x in request.args.get("userids").split(",") if x] - users = userController.get_users(userids=userids) + users = userController.get_users() if request.method == "GET": return jsonify([{"userid": user.userid, "limit": user.get_attribute("balance_limit")} for user in users]) @@ -319,5 +316,8 @@ def get_balances(current_session: Session): sortBy = request.args.get("sortBy", type=str) balances, count = balance_controller.get_balances(limit=limit, offset=offset, descending=descending, sortBy=sortBy) return jsonify( - {"balances": [{"userid": u, "credit": v[0], "debit": v[1]} for u, v in balances.items()], "count": count} + { + "balances": [{"userid": u, "credit": v[0], "debit": v[1]} for u, v in balances.items()], + "count": count, + } ) diff --git a/flaschengeist/plugins/users/__init__.py b/flaschengeist/plugins/users/__init__.py index a8c87c8..d0f929e 100644 --- a/flaschengeist/plugins/users/__init__.py +++ b/flaschengeist/plugins/users/__init__.py @@ -69,10 +69,7 @@ def list_users(current_session): JSON encoded array of `flaschengeist.models.user.User` or HTTP error """ logger.debug("Retrieve list of all users") - userids = None - if "userids" in request.args: - userids = [x for x in request.args.get("userids").split(",") if x] - users = userController.get_users(userids=userids) + users = userController.get_users() return jsonify(users)