Pin black to latest version, and reformat code
[mygpo.git] / mygpo / search / json.py
blob69dfa558ffd833f60e080bc61af0e0a266ed9f6c
1 """ Converts models to a JSON representation """
4 def podcast_to_json(podcast):
5 """ Convert a podcast to JSON for indexing """
6 doc = {
7 'title': podcast.title,
8 'subtitle': podcast.subtitle,
9 'description': podcast.description,
10 'link': podcast.link,
11 'language': podcast.language,
12 'last_update': podcast.last_update,
13 'created': podcast.created,
14 # modified is not indexed
15 'license': podcast.license, # maybe get a license name here?
16 # flattr_url
17 'content_types': list(filter(None, podcast.content_types)),
18 'outdated': podcast.outdated,
19 'author': podcast.author,
20 'logo_url': podcast.logo_url,
21 # group, group_member_name ???
22 'subscribers': podcast.subscribers,
23 # restrictions ?
24 # common_episode_title
25 # new_location
26 'latest_episode_timestamp': podcast.latest_episode_timestamp,
27 'episode_count': podcast.episode_count,
28 # hub
29 'twitter': podcast.twitter,
30 # update_interval
31 'slugs': [s.slug for s in podcast.slugs.all()],
32 'urls': [u.url for u in podcast.urls.all()],
35 return doc