forked from mirrors/bookwyrm
sort edition list by rank
This commit is contained in:
parent
fe67f65307
commit
5b7f7aa0e3
4 changed files with 7 additions and 5 deletions
|
@ -145,9 +145,11 @@ class ActivitypubMixin:
|
|||
|
||||
if hasattr(self, 'serialize_reverse_fields'):
|
||||
# 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:
|
||||
related_field = getattr(self, model_field_name)
|
||||
related_field = getattr(
|
||||
self, model_field_name
|
||||
).order_by(sort_field)
|
||||
activity[activity_field_name] = \
|
||||
unfurl_related_field(related_field)
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ class Work(OrderedCollectionPageMixin, Book):
|
|||
)
|
||||
|
||||
activity_serializer = activitypub.Work
|
||||
serialize_reverse_fields = [('editions', 'editions')]
|
||||
serialize_reverse_fields = [('editions', 'editions', '-edition_rank')]
|
||||
deserialize_reverse_fields = [('editions', 'editions')]
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
objects = InheritanceManager()
|
||||
|
||||
activity_serializer = activitypub.Note
|
||||
serialize_reverse_fields = [('attachments', 'attachment')]
|
||||
serialize_reverse_fields = [('attachments', 'attachment', 'id')]
|
||||
deserialize_reverse_fields = [('attachments', 'attachment')]
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -200,7 +200,7 @@ class KeyPair(ActivitypubMixin, BookWyrmModel):
|
|||
blank=True, null=True, activitypub_field='publicKeyPem')
|
||||
|
||||
activity_serializer = activitypub.PublicKey
|
||||
serialize_reverse_fields = [('owner', 'owner')]
|
||||
serialize_reverse_fields = [('owner', 'owner', 'id')]
|
||||
|
||||
def get_remote_id(self):
|
||||
# self.owner is set by the OneToOneField on User
|
||||
|
|
Loading…
Reference in a new issue