Skip to content

Commit f8835ef

Browse files
committed
sort collaborators, supprters and partners
1 parent 11ae4ef commit f8835ef

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

api/types/type_collaborative.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def metadata(self) -> Optional[List["TypeCollaborativeMetadata"]]:
187187
def contributors(self) -> Optional[List["TypeUser"]]:
188188
"""Get contributors associated with this collaborative."""
189189
try:
190-
queryset = self.contributors.all() # type: ignore
190+
queryset = self.contributors.all().order_by("full_name") # type: ignore
191191
if not queryset.exists():
192192
return []
193193
return TypeUser.from_django_list(queryset)
@@ -215,10 +215,14 @@ def organization_relationships(
215215
def supporting_organizations(self) -> Optional[List["TypeOrganization"]]:
216216
"""Get supporting organizations for this collaborative."""
217217
try:
218-
relationships = CollaborativeOrganizationRelationship.objects.filter(
219-
collaborative=self, # type: ignore
220-
relationship_type=OrganizationRelationshipType.SUPPORTER,
221-
).select_related("organization")
218+
relationships = (
219+
CollaborativeOrganizationRelationship.objects.filter(
220+
collaborative=self, # type: ignore
221+
relationship_type=OrganizationRelationshipType.SUPPORTER,
222+
)
223+
.select_related("organization")
224+
.order_by("organization__name")
225+
)
222226

223227
if not relationships.exists():
224228
return []
@@ -232,10 +236,14 @@ def supporting_organizations(self) -> Optional[List["TypeOrganization"]]:
232236
def partner_organizations(self) -> Optional[List["TypeOrganization"]]:
233237
"""Get partner organizations for this collaborative."""
234238
try:
235-
relationships = CollaborativeOrganizationRelationship.objects.filter(
236-
collaborative=self, # type: ignore
237-
relationship_type=OrganizationRelationshipType.PARTNER,
238-
).select_related("organization")
239+
relationships = (
240+
CollaborativeOrganizationRelationship.objects.filter(
241+
collaborative=self, # type: ignore
242+
relationship_type=OrganizationRelationshipType.PARTNER,
243+
)
244+
.select_related("organization")
245+
.order_by("organization__name")
246+
)
239247

240248
if not relationships.exists():
241249
return []

0 commit comments

Comments
 (0)