@@ -139,8 +139,8 @@ def fetch_creativework(pks):
139139 , 'relation_type', agent_relation.type
140140 , 'order_cited', agent_relation.order_cited
141141 , 'cited_as', agent_relation.cited_as
142- , 'affiliations', COALESCE(affiliations, '{}' )
143- , 'awards', COALESCE(awards, '{}' )
142+ , 'affiliations', COALESCE(affiliations, '[]'::json )
143+ , 'awards', COALESCE(awards, '[]'::json )
144144 ))) AS related_agents
145145 FROM share_agentworkrelation AS agent_relation
146146 JOIN share_agent AS agent ON agent_relation.agent_id = agent.id
@@ -164,6 +164,7 @@ def fetch_creativework(pks):
164164 LEFT JOIN LATERAL (
165165 SELECT json_agg(json_strip_nulls(json_build_object(
166166 'id', award.id
167+ , 'type', 'share.award'
167168 , 'date', award.date
168169 , 'name', award.name
169170 , 'description', award.description
@@ -250,6 +251,14 @@ def fetch_creativework(pks):
250251
251252 for agent in data .pop ('related_agents' ):
252253 populate_types (agent )
254+
255+ for award in agent .get ('awards' , []):
256+ populate_types (award )
257+
258+ for affiliation in agent .get ('affiliations' , []):
259+ populate_types (affiliation )
260+ affiliation ['affiliation' ] = apps .get_model (affiliation .pop ('affiliation_type' ))._meta .verbose_name
261+
253262 relation_model = apps .get_model (agent .pop ('relation_type' ))
254263 parent_model = next (parent for parent in relation_model .mro () if not parent .mro ()[2 ]._meta .proxy )
255264 parent_name = str (parent_model ._meta .verbose_name_plural )
0 commit comments