# /opt/planetstack/core/dashboard/views/helloworld.py
import os
import sys
import json
from django.http import HttpResponse, HttpResponseServerError, HttpResponseForbidden
from django.views.generic import TemplateView, View
from core.models import *
from django.forms.models import model_to_dict

class ShellDataView(View):
    url = r'^shelldata/'

    def get(self, request, **kwargs):
        allSlices = []
        for slice in Slice.objects.all():
            allSlices.append(model_to_dict(slice))

        result = {"slices": allSlices}

        return HttpResponse(json.dumps(result), mimetype='application/json')

@@ -47,16 +47,32 @@
 orld.py%0A
+import datetime%0A
 import o
@@ -84,16 +84,28 @@
 ort sys%0A
+import time%0A
 import j
@@ -318,16 +318,269 @@
 o_dict%0A%0A
+def ensure_serializable(d):%0A    d2=%7B%7D%0A    for (k,v) in d.items():%0A        # datetime is not json serializable%0A        if isinstance(v, datetime.datetime):%0A            d2%5Bk%5D = time.mktime(v.timetuple())%0A        else:%0A            d2%5Bk%5D = v%0A    return d2%0A%0A
 class Sh
@@ -756,16 +756,36 @@
 .append(
+ensure_serializable(
 model_to
@@ -797,16 +797,17 @@
 (slice))
+)
 %0A%0A      

fix datetime not serializable in shell view