Starts getting reverse fields working for deserialization

also fixes the fields on the image model and runs a long overdue
migration
This commit is contained in:
Mouse Reeve
2020-12-07 18:28:42 -08:00
parent d0c1a68df6
commit 4d4ee8b8c3
8 changed files with 434 additions and 59 deletions

View File

@ -83,9 +83,11 @@ class ActivitypubMixin:
if hasattr(self, 'serialize_reverse_fields'):
# for example, editions of a work
for field_name in self.serialize_reverse_fields:
related_field = getattr(self, field_name)
activity[field_name] = unfurl_related_field(related_field)
for model_field_name, activity_field_name in \
self.serialize_reverse_fields:
related_field = getattr(self, model_field_name)
activity[activity_field_name] = \
unfurl_related_field(related_field)
if not activity.get('id'):
activity['id'] = self.get_remote_id()