sort edition list by rank
This commit is contained in:
parent
fe67f65307
commit
5b7f7aa0e3
|
@ -145,9 +145,11 @@ class ActivitypubMixin:
|
||||||
|
|
||||||
if hasattr(self, 'serialize_reverse_fields'):
|
if hasattr(self, 'serialize_reverse_fields'):
|
||||||
# for example, editions of a work
|
# for example, editions of a work
|
||||||
for model_field_name, activity_field_name in \
|
for model_field_name, activity_field_name, sort_field in \
|
||||||
self.serialize_reverse_fields:
|
self.serialize_reverse_fields:
|
||||||
related_field = getattr(self, model_field_name)
|
related_field = getattr(
|
||||||
|
self, model_field_name
|
||||||
|
).order_by(sort_field)
|
||||||
activity[activity_field_name] = \
|
activity[activity_field_name] = \
|
||||||
unfurl_related_field(related_field)
|
unfurl_related_field(related_field)
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ class Work(OrderedCollectionPageMixin, Book):
|
||||||
)
|
)
|
||||||
|
|
||||||
activity_serializer = activitypub.Work
|
activity_serializer = activitypub.Work
|
||||||
serialize_reverse_fields = [('editions', 'editions')]
|
serialize_reverse_fields = [('editions', 'editions', '-edition_rank')]
|
||||||
deserialize_reverse_fields = [('editions', 'editions')]
|
deserialize_reverse_fields = [('editions', 'editions')]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
||||||
objects = InheritanceManager()
|
objects = InheritanceManager()
|
||||||
|
|
||||||
activity_serializer = activitypub.Note
|
activity_serializer = activitypub.Note
|
||||||
serialize_reverse_fields = [('attachments', 'attachment')]
|
serialize_reverse_fields = [('attachments', 'attachment', 'id')]
|
||||||
deserialize_reverse_fields = [('attachments', 'attachment')]
|
deserialize_reverse_fields = [('attachments', 'attachment')]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -200,7 +200,7 @@ class KeyPair(ActivitypubMixin, BookWyrmModel):
|
||||||
blank=True, null=True, activitypub_field='publicKeyPem')
|
blank=True, null=True, activitypub_field='publicKeyPem')
|
||||||
|
|
||||||
activity_serializer = activitypub.PublicKey
|
activity_serializer = activitypub.PublicKey
|
||||||
serialize_reverse_fields = [('owner', 'owner')]
|
serialize_reverse_fields = [('owner', 'owner', 'id')]
|
||||||
|
|
||||||
def get_remote_id(self):
|
def get_remote_id(self):
|
||||||
# self.owner is set by the OneToOneField on User
|
# self.owner is set by the OneToOneField on User
|
||||||
|
|
Loading…
Reference in New Issue