added json to timerange failures

This commit is contained in:
2010-04-14 18:24:21 -07:00
parent 1ac0de80e0
commit 5ba91d6ae4

View File

@@ -89,19 +89,23 @@ def failswindow(request):
period=request.GET['window']
m = re.match("(\d+)([ymwdh])", period)
failures = get_fails_in_timerange(period)
if m.group(2) == 'd':
prd='days'
elif m.group(2) == 'h':
prd = 'hours'
elif m.group(2) == 'w':
prd = 'weeks'
elif m.group(2) == 'm':
prd = 'months'
elif m.group(2) == 'y':
prd = 'years'
if request.GET.has_key('json'):
jtext = list(failures)
return HttpResponse(json.dumps(jtext))
else:
prd = 'days'
if m.group(2) == 'd':
prd='days'
elif m.group(2) == 'h':
prd = 'hours'
elif m.group(2) == 'w':
prd = 'weeks'
elif m.group(2) == 'm':
prd = 'months'
elif m.group(2) == 'y':
prd = 'years'
else:
prd = 'days'
return render_to_response('viewer/failswindow.html', {'failures': failures,'n':m.group(1),'d':prd})
return render_to_response('viewer/failswindow.html', {'failures': failures,'n':m.group(1),'d':prd})