[balance] revert user ssp for pull-request

This commit is contained in:
Tim Gröger 2021-11-25 10:11:41 +01:00 committed by Ferdinand Thiessen
parent 2634181d5e
commit c3468eea03
4 changed files with 8 additions and 20 deletions

View File

@ -118,12 +118,8 @@ def modify_user(user, password, new_password=None):
messageController.send_message(messageController.Message(user, text, subject)) messageController.send_message(messageController.Message(user, text, subject))
def get_users(userids=None): def get_users():
query = User.query return User.query.all()
if userids:
query.filter(User.userid in userids)
query = query.order_by(User.lastname.asc(), User.firstname.asc())
return query.all()
def get_user_by_role(role: Role): def get_user_by_role(role: Role):

View File

@ -104,11 +104,6 @@ class User(db.Model, ModelSerializeMixin):
def has_permission(self, permission): def has_permission(self, permission):
return permission in self.get_permissions() 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): class _UserAttribute(db.Model, ModelSerializeMixin):
__tablename__ = "user_attribute" __tablename__ = "user_attribute"

View File

@ -110,10 +110,7 @@ def limits(current_session: Session):
Returns: Returns:
JSON encoded array of userid with limit or HTTP-error JSON encoded array of userid with limit or HTTP-error
""" """
userids = None users = userController.get_users()
if "userids" in request.args:
[x for x in request.args.get("userids").split(",") if x]
users = userController.get_users(userids=userids)
if request.method == "GET": if request.method == "GET":
return jsonify([{"userid": user.userid, "limit": user.get_attribute("balance_limit")} for user in users]) 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) sortBy = request.args.get("sortBy", type=str)
balances, count = balance_controller.get_balances(limit=limit, offset=offset, descending=descending, sortBy=sortBy) balances, count = balance_controller.get_balances(limit=limit, offset=offset, descending=descending, sortBy=sortBy)
return jsonify( 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,
}
) )

View File

@ -69,10 +69,7 @@ def list_users(current_session):
JSON encoded array of `flaschengeist.models.user.User` or HTTP error JSON encoded array of `flaschengeist.models.user.User` or HTTP error
""" """
logger.debug("Retrieve list of all users") logger.debug("Retrieve list of all users")
userids = None users = userController.get_users()
if "userids" in request.args:
userids = [x for x in request.args.get("userids").split(",") if x]
users = userController.get_users(userids=userids)
return jsonify(users) return jsonify(users)