diff options
author | Magnus Hagander | 2017-01-23 17:16:59 +0000 |
---|---|---|
committer | Magnus Hagander | 2017-01-23 17:17:41 +0000 |
commit | 525d338b763a1b8d2ff7351af37752a61c64877f (patch) | |
tree | e21d3319fa158094b638252439ad37041b563a9f /postgresqleu/util/jsonutil.py | |
parent | ecdca50fd95ef5bdfbbf8084b0afffe08f565265 (diff) |
Add ability to dump schedule data as json
This is only available to conference admins. The idea is to be able to
test schedules locally using deploystatic, by feeding this schedule data
into the context.override.json file.
Diffstat (limited to 'postgresqleu/util/jsonutil.py')
-rw-r--r-- | postgresqleu/util/jsonutil.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/postgresqleu/util/jsonutil.py b/postgresqleu/util/jsonutil.py new file mode 100644 index 00000000..774a9134 --- /dev/null +++ b/postgresqleu/util/jsonutil.py @@ -0,0 +1,10 @@ +from datetime import datetime, date +import json + +class JsonSerializer(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, datetime) or isinstance(obj, date): + return obj.isoformat() + if hasattr(obj, 'json_included_attributes'): + return dict([(k,getattr(obj, k)) for k in obj.json_included_attributes]) + return json.JSONEncoder.default(self, obj) |