Fix serialization

This commit is contained in:
Angel Rey 2020-09-21 13:57:38 -05:00
parent 62c9028212
commit f26c0c6cd8
2 changed files with 21 additions and 9 deletions

View file

@ -50,7 +50,8 @@ class Snapshot(models.Model):
args = args or self.keys
return {
key: getattr(self, key)
for key in args
if key != 'tags' else self.get_tags_str()
for key in args
}
def as_link(self) -> Link:
@ -59,6 +60,13 @@ class Snapshot(models.Model):
def as_link_with_details(self) -> Link:
from ..index import load_link_details
return load_link_details(self.as_link())
def get_tags_str(self) -> str:
tags = ','.join(
tag.name
for tag in self.tags.all()
) if self.tags.all() else ''
return tags
@cached_property
def bookmarked(self):