New url to see job logs
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Tue, 19 Apr 2011 15:37:05 +0000 (15:37 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Tue, 19 Apr 2011 15:37:05 +0000 (15:37 +0000)
bin/djais/urls.py
bin/djais/views.py

index 4838785965364d302a5fdae4f01de9e3fa5565f4..4adf8a9056833fe904adaa8ae41609040e314594 100644 (file)
@@ -36,6 +36,7 @@ urlpatterns = patterns('',
     (r'^job/$', 'ais.djais.views.jobs_index'),
     (r'^job/(?P<jobid>[A-Z0-9]+)/$', 'ais.djais.views.job_detail'),
     (r'^job/(?P<jobid>[A-Z0-9]+)/download$', 'ais.djais.views.job_get'),
+    (r'^job/(?P<jobid>[A-Z0-9]+)/log$', 'ais.djais.views.job_log'),
     (r'^source/$', 'ais.djais.views.sources_index'),
     (r'^source/stats$', 'ais.djais.views.sources_stats'),
     (r'^news/(?P<page>\d*)$', 'ais.djais.views.news'),
index ab346df3ab8c7716549df43d058efc2c0496fde3..e82a9fc894ef79e8585b6747f242b11ead1d2dc8 100644 (file)
@@ -920,6 +920,21 @@ def job_get(request, jobid):
     extension = os.path.splitext(job.friendly_filename)[-1]
     return HttpResponseRedirect('/job_result/%s%s/%s' % (job.id, extension, job.friendly_filename))
 
+
+@http_authenticate(auth, 'ais')
+def job_log(request, jobid):
+    job = get_object_or_404(Job, id=jobid)
+    if job.user != request.user:
+        return HttpResponseForbidden('403 Forbidden')
+    log = u''
+    try:
+        log = file(RESULT_DIR+unicode(jobid)+'.log').read()
+    except IOError, err:
+        if err.errno != 2: # No such file
+            raise
+    return render_to_response('job.html', {'job': job, 'log': log}, RequestContext(request))
+
+
 @http_authenticate(auth, 'ais')
 def users(request):
     users = User.objects.order_by('name')