summaryrefslogtreecommitdiff
path: root/postgresqleu/util/jsonutil.py
diff options
context:
space:
mode:
authorMagnus Hagander2017-01-23 17:16:59 +0000
committerMagnus Hagander2017-01-23 17:17:41 +0000
commit525d338b763a1b8d2ff7351af37752a61c64877f (patch)
treee21d3319fa158094b638252439ad37041b563a9f /postgresqleu/util/jsonutil.py
parentecdca50fd95ef5bdfbbf8084b0afffe08f565265 (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.py10
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)