Merge pull request #212 from ZeusWPI/fix/admin-order-current-top

Order current user to the top for admins when choosing courier
This commit is contained in:
Charlotte Van Petegem 2023-01-24 19:11:21 +01:00 committed by GitHub
commit 02afba70a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,8 +30,11 @@ class OrderForm(Form):
def populate(self) -> None:
"Fill in the options for courier for an Order"
if current_user.is_admin():
self.courier_id.choices = [(0, None)] + [
(u.id, u.username) for u in User.query.order_by("username")
self.courier_id.choices = [
(0, None),
(current_user.id, current_user.username),
] + [
(u.id, u.username) for u in User.query.order_by("username") if u.id != current_user.id
]
else:
self.courier_id.choices = [