Skip to content

Commit

Permalink
Fixing bug tree order
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelagz committed Dec 5, 2023
1 parent e32ba8f commit 929463d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/auth_and_perms/gtselects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.conf import settings
from django.contrib.auth.models import User, Group
from django.db.models import Q
from django.db.models import Q, Case, When
from django.http import Http404
from djgentelella.groute import register_lookups
from djgentelella.views.select2autocomplete import BaseSelect2View, GPaginator
Expand Down Expand Up @@ -405,8 +405,8 @@ def get_queryset(self):
get_tree_organization_pks_by_user(node, self.user, pks,
parents=parents_pks, extras={'active': True})

queryset = queryset.filter(pk__in=pks)
queryset = list(map(lambda id: queryset.get(pk=id), pks))
tree_order = Case(*[When(pk=pk, then=i) for i, pk in enumerate(pks)])
queryset = queryset.filter(pk__in=pks).order_by(tree_order)
return queryset
return queryset.none()

Expand Down

0 comments on commit 929463d

Please sign in to comment.