From 1bc6a5931e1e7813a5c0eb2177592e51cbea32d1 Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Tue, 24 Jan 2023 19:06:10 +0100 Subject: [PATCH] Order current user to the top for admins --- app/forms.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/forms.py b/app/forms.py index f847e96..4c21d4f 100644 --- a/app/forms.py +++ b/app/forms.py @@ -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 = [