Korektury: při přístupu k neex. pdf vrať 404

This commit is contained in:
Matěj Kocián 2016-02-25 00:34:53 +01:00
parent f72e01a0a8
commit 0cc162a806

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from django.shortcuts import render
from django.shortcuts import get_object_or_404, render
from django.views import generic
from django.utils.translation import ugettext as _
from django.conf import settings
@ -114,7 +114,7 @@ class KorekturyView(generic.TemplateView):
def get_context_data(self, **kwargs):
context = super(KorekturyView,self).get_context_data(**kwargs)
pdf = KorekturovanePDF.objects.get(id=self.kwargs['pdf'])
pdf = get_object_or_404(KorekturovanePDF, id=self.kwargs['pdf'])
context['pdf'] = pdf
context['img_name'] = os.path.split(pdf.pdf.path)[1].split('.')[0]
context['img_path'] = settings.KOREKTURY_IMG_DIR