Skip to content
Snippets Groups Projects
Commit c302b5e3 authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

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
parent 3050ce17
No related branches found
No related tags found
No related merge requests found
...@@ -140,7 +140,8 @@ def get_model_choices(model, allow_none=False, attr='name', query=None): ...@@ -140,7 +140,8 @@ def get_model_choices(model, allow_none=False, attr='name', query=None):
if allow_none: if allow_none:
choices = [(None, '')] choices = [(None, '')]
if query is 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()]) choices.extend([(str(instance.id), getattr(instance, attr)) for instance in query.all()])
return choices return choices
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment