mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
core: improve performances on not found images
This commit is contained in:
parent
321e5e3ff5
commit
1f86827e46
@ -23,7 +23,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# This file contains all the views that concern the page model
|
# This file contains all the views that concern the page model
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect, get_object_or_404
|
||||||
from django.views.generic import ListView, DetailView, TemplateView
|
from django.views.generic import ListView, DetailView, TemplateView
|
||||||
from django.views.generic.edit import UpdateView, FormMixin, DeleteView
|
from django.views.generic.edit import UpdateView, FormMixin, DeleteView
|
||||||
from django.views.generic.detail import SingleObjectMixin
|
from django.views.generic.detail import SingleObjectMixin
|
||||||
@ -51,9 +51,7 @@ def send_file(request, file_id, file_class=SithFile, file_attr="file"):
|
|||||||
memory at once. The FileWrapper will turn the file object into an
|
memory at once. The FileWrapper will turn the file object into an
|
||||||
iterator for chunks of 8KB.
|
iterator for chunks of 8KB.
|
||||||
"""
|
"""
|
||||||
f = file_class.objects.filter(id=file_id).first()
|
f = get_object_or_404(file_class, id=file_id)
|
||||||
if f is None or not f.file:
|
|
||||||
return not_found(request)
|
|
||||||
if not (
|
if not (
|
||||||
can_view(f, request.user)
|
can_view(f, request.user)
|
||||||
or (
|
or (
|
||||||
|
Loading…
Reference in New Issue
Block a user