1
0
Fork 0

(De)serializers for tag fields

This commit is contained in:
Mouse Reeve 2020-11-20 09:28:54 -08:00
parent 73e41d568e
commit 72b4c150f6
4 changed files with 44 additions and 54 deletions

View file

@ -249,3 +249,15 @@ class ActivityMapping:
model_key: str
activity_formatter: Callable = lambda x: x
model_formatter: Callable = lambda x: x
def tag_formatter(items, name_field, activity_type):
''' helper function to format lists of foreign keys into Tags '''
tags = []
for item in items.all():
tags.append(activitypub.Link(
href=item.remote_id,
name=getattr(item, name_field),
type=activity_type
))
return tags