Commit 5d820c6e by Kálmán Viktor

dashboard: fix mentioned problems in sort

- node's default ordering is fine
- replacing "-" does not always work so fixed
    for example: ?sort=-na-me
parent 282cea51
...@@ -995,11 +995,9 @@ class VmList(LoginRequiredMixin, ListView): ...@@ -995,11 +995,9 @@ class VmList(LoginRequiredMixin, ListView):
# remove "-" that means descending order # remove "-" that means descending order
# also check if the column name is valid # also check if the column name is valid
if (sort and if (sort and
sort.replace("-", "") (sort[1:] if sort[0] == "-" else sort)
in [i.name for i in Instance._meta.fields] + ["pk"]): in [i.name for i in Instance._meta.fields] + ["pk"]):
queryset = queryset.order_by( queryset = queryset.order_by(sort)
# we order nodes by the normalized_name
sort.replace("node", "node__normalized_name"))
return queryset.select_related('owner', 'node') return queryset.select_related('owner', 'node')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment