Commit 19716de7 authored by BAIRE Anthony's avatar BAIRE Anthony
Browse files

fix error 500 on job not found

fix #347, allgo.inria.fr#8
parent a3c9772f
from django.conf import settings from django.conf import settings
from django.contrib.auth.mixins import UserPassesTestMixin, LoginRequiredMixin from django.contrib.auth.mixins import UserPassesTestMixin, LoginRequiredMixin
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.http import HttpResponse, JsonResponse from django.http import HttpResponse, JsonResponse, Http404
from django.shortcuts import redirect from django.shortcuts import redirect
from .models import Job from .models import Job
...@@ -101,6 +101,8 @@ class JobAuthMixin(AllgoValidAccountMixin, UserPassesTestMixin): ...@@ -101,6 +101,8 @@ class JobAuthMixin(AllgoValidAccountMixin, UserPassesTestMixin):
job = Job.objects.get(id=self.kwargs['pk']) job = Job.objects.get(id=self.kwargs['pk'])
except Job.DoesNotExist: except Job.DoesNotExist:
return False return False
if job.state in (Job.NEW, Job.DELETED, Job.ARCHIVED):
raise Http404
return user.is_superuser or user == getattr(job, "user", ()) return user.is_superuser or user == getattr(job, "user", ())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment