Skip to content

Commit

Permalink
Fix ordering in organization queryset
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshhari committed Jan 5, 2025
1 parent e55e7bc commit 8250162
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions care/emr/api/viewsets/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class OrganizationPublicViewSet(EMRModelReadOnlyViewSet):
permission_classes = []

def get_queryset(self):
return Organization.objects.filter(org_type="govt")
return Organization.objects.filter(org_type="govt").order_by("created_date")


class OrganizationViewSet(EMRModelViewSet):
Expand Down Expand Up @@ -141,7 +141,10 @@ def authorize_create(self, instance):

def get_queryset(self):
queryset = (
super().get_queryset().select_related("parent", "created_by", "updated_by")
super()
.get_queryset()
.select_related("parent", "created_by", "updated_by")
.order_by("created_date")
)
if "parent" in self.request.GET and not self.request.GET.get("parent"):
# Filter for root organizations, For some reason its not working as intended in Django Filters
Expand Down
1 change: 0 additions & 1 deletion care/emr/resources/organization/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class OrganizationTypeChoices(str, Enum):
team = "team"
govt = "govt"
role = "role"
other = "other"


class OrganizationBaseSpec(EMRResource):
Expand Down

0 comments on commit 8250162

Please sign in to comment.