=== modified file 'lava_scheduler_app/urls.py'
@@ -8,6 +8,7 @@
url(r'^device/(?P<pk>[-_a-zA-Z0-9]+)/maintenance$', 'device_maintenance_mode'),
url(r'^device/(?P<pk>[-_a-zA-Z0-9]+)/online$', 'device_online'),
url(r'^job/(?P<pk>[0-9]+)$', 'job'),
+ url(r'^job/(?P<pk>[0-9]+)/cancel$', 'job_cancel'),
+ url(r'^job/(?P<pk>[0-9]+)/json$', 'job_json'),
url(r'^job/(?P<pk>[0-9]+)/output$', 'job_output'),
- url(r'^job/(?P<pk>[0-9]+)/cancel$', 'job_cancel'),
)
=== modified file 'lava_scheduler_app/views.py'
@@ -1,3 +1,4 @@
+import json
import os
from django.http import (
@@ -6,7 +7,11 @@
HttpResponseNotAllowed,
)
from django.template import RequestContext
-from django.shortcuts import redirect, render_to_response
+from django.shortcuts import (
+ get_object_or_404,
+ redirect,
+ render_to_response,
+ )
from lava_scheduler_app.models import Device, TestJob
@@ -96,6 +101,19 @@
"you cannot cancel this job", content_type="text/plain")
+def job_json(request, pk):
+ job = get_object_or_404(TestJob, pk=pk)
+ json_text = json.dumps({
+ 'status': job.get_status_display(),
+ 'results_link': job.results_link,
+ })
+ content_type = 'application/json'
+ if 'callback' in request.GET:
+ json_text = '%s(%s)'%(request.GET['callback'], json_text)
+ content_type = 'text/javascript'
+ return HttpResponse(json_text, content_type=content_type)
+
+
def device(request, pk):
device = Device.objects.get(pk=pk)
recent_jobs = TestJob.objects.all().filter(