From c302b5e34edfc908404bfea8d9f981c4b8da0571 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand <benjamin.bertrand@esss.se> Date: Mon, 9 Apr 2018 12:13:09 +0200 Subject: [PATCH] Sort network names in the register new host form The sorting of the models was done in the utils.get_model_choices funtion but a specific query was passed to not display admin_only networks. The sorting is now done even when passing a specific query to get_model_choices. JIRA INFRA-284 --- app/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/utils.py b/app/utils.py index a5c2e06..a8f7896 100644 --- a/app/utils.py +++ b/app/utils.py @@ -140,7 +140,8 @@ def get_model_choices(model, allow_none=False, attr='name', query=None): if allow_none: choices = [(None, '')] if query is None: - query = model.query.order_by(getattr(model, attr)) + query = model.query + query = query.order_by(getattr(model, attr)) choices.extend([(str(instance.id), getattr(instance, attr)) for instance in query.all()]) return choices -- GitLab