Alphabetise by partner name only to reduce confusion
@@ -48,9 +48,8 @@ def get_valid_partner_authorizations(partner_pk, stream_pk=None):
return Authorization.objects.none()
-def create_resource_dict(name, authorization, partner, stream):
+def create_resource_dict(authorization, partner, stream):
resource_item = {
- "name": name,
"partner": partner,
"authorization": authorization,
"stream": stream,
@@ -79,27 +78,21 @@ def sort_authorizations_into_resource_list(authorizations):
"""
Given a queryset of Authorization objects, return a
list of dictionaries, sorted alphabetically by partner
- or stream name, with additional data computed for ease
- of display in the my_library template.
+ name, with additional data computed for ease of display
+ in the my_library template.
"""
resource_list = []
if authorizations:
for authorization in authorizations:
for partner in authorization.partners.all():
stream = authorization.stream
- # Name this item according to whether this authorization is
- # to a stream
- if stream:
- name_string = stream.name
- else:
- name_string = partner.company_name
resource_list.append(
- create_resource_dict(name_string, authorization, partner, stream)
+ create_resource_dict(authorization, partner, stream)
)
# Alphabetise by name
- resource_list = sorted(resource_list, key=lambda i: i["name"])
+ resource_list = sorted(resource_list, key=lambda i: i["partner"].company_name)
return resource_list
else:
