Add author to object jsonifiers.

This commit is contained in:
voussoir 2018-03-18 15:59:36 -07:00
parent 60049c777f
commit 84e0266f30

View file

@ -8,6 +8,7 @@ def album(a, minimal=False):
'id': a.id, 'id': a.id,
'description': a.description, 'description': a.description,
'title': a.title, 'title': a.title,
'author': user_or_none(a.get_author()),
} }
if not minimal: if not minimal:
j['photos'] = [photo(p) for p in a.get_photos()] j['photos'] = [photo(p) for p in a.get_photos()]
@ -23,6 +24,7 @@ def album(a, minimal=False):
def bookmark(b): def bookmark(b):
j = { j = {
'id': b.id, 'id': b.id,
'author': user_or_none(b.get_author()),
'url': b.url, 'url': b.url,
'title': b.title, 'title': b.title,
} }
@ -40,6 +42,7 @@ def photo(p, include_albums=True, include_tags=True):
tags.sort(key=lambda x: x.name) tags.sort(key=lambda x: x.name)
j = { j = {
'id': p.id, 'id': p.id,
'author': user_or_none(p.get_author()),
'extension': p.extension, 'extension': p.extension,
'width': p.width, 'width': p.width,
'height': p.height, 'height': p.height,
@ -66,6 +69,7 @@ def photo(p, include_albums=True, include_tags=True):
def tag(t, include_synonyms=False): def tag(t, include_synonyms=False):
j = { j = {
'id': t.id, 'id': t.id,
'author': user_or_none(t.get_author()),
'name': t.name, 'name': t.name,
'description': t.description, 'description': t.description,
'qualified_name': t.qualified_name(), 'qualified_name': t.qualified_name(),
@ -81,3 +85,8 @@ def user(u):
'created': u.created, 'created': u.created,
} }
return j return j
def user_or_none(u):
if u is None:
return None
return user(u)