|
|
|
@ -2043,7 +2043,7 @@ def get_cached_edition_metadata(): |
|
|
|
).prefetch_related( |
|
|
|
Prefetch('researchers', queryset=BookResearcher.objects.select_related('author')), |
|
|
|
Prefetch('editors', queryset=BookEditor.objects.select_related('author')), |
|
|
|
Prefetch('contributors', queryset=BookEditionContributor.objects.select_related('author', 'role').prefetch_related('volumes')), |
|
|
|
Prefetch('contributors', queryset=BookEditionContributor.objects.select_related('author', 'role').prefetch_related('volumes').order_by('role__order', 'id')), |
|
|
|
) |
|
|
|
) |
|
|
|
by_id = {} |
|
|
|
@ -2233,7 +2233,8 @@ def _build_edition_info_dict(obj, edition, request): |
|
|
|
|
|
|
|
raw_researchers = edition._cached_researchers if hasattr(edition, '_cached_researchers') else (edition.researchers.all() if hasattr(edition, "researchers") else []) |
|
|
|
raw_editors = edition._cached_editors if hasattr(edition, '_cached_editors') else (edition.editors.all() if hasattr(edition, "editors") else []) |
|
|
|
raw_contributors = edition._cached_contributors if hasattr(edition, '_cached_contributors') else (edition.contributors.all() if hasattr(edition, "contributors") else []) |
|
|
|
raw_contributors = list(edition._cached_contributors if hasattr(edition, '_cached_contributors') else (edition.contributors.all() if hasattr(edition, "contributors") else [])) |
|
|
|
raw_contributors.sort(key=lambda c: (getattr(c.role, 'order', 999999) if getattr(c, 'role_id', None) and getattr(c, 'role', None) else 999999, c.id or 0)) |
|
|
|
researchers = [_serialize_contributor(r) for r in raw_researchers] |
|
|
|
editors = [_serialize_contributor(e) for e in raw_editors] |
|
|
|
contributors = [_serialize_contributor(c) for c in raw_contributors] |
|
|
|
|