mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Improve file moderation
This commit is contained in:
@ -19,13 +19,13 @@ import os
|
||||
from core.models import SithFile
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin, can_view, not_found
|
||||
|
||||
def send_file(request, file_id):
|
||||
def send_file(request, file_id, file_class=SithFile):
|
||||
"""
|
||||
Send a file through Django without loading the whole file into
|
||||
memory at once. The FileWrapper will turn the file object into an
|
||||
iterator for chunks of 8KB.
|
||||
"""
|
||||
f = SithFile.objects.filter(id=file_id).first()
|
||||
f = file_class.objects.filter(id=file_id).first()
|
||||
if f is None or f.is_folder:
|
||||
return not_found(request)
|
||||
from counter.models import Counter
|
||||
|
Reference in New Issue
Block a user