mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Add thumbnails to albums
This commit is contained in:
@ -572,10 +572,14 @@ class SithFile(models.Model):
|
||||
code='duplicate',
|
||||
)
|
||||
if self.is_folder:
|
||||
try:
|
||||
self.file.delete()
|
||||
except: pass
|
||||
self.file = None
|
||||
if self.file:
|
||||
try:
|
||||
import imghdr
|
||||
if imghdr.what(None, self.file.read()) not in ['gif', 'png', 'jpeg']:
|
||||
self.file.delete()
|
||||
self.file = None
|
||||
except:
|
||||
self.file = None
|
||||
self.mime_type = "inode/directory"
|
||||
if self.is_file and (self.file is None or self.file == ""):
|
||||
raise ValidationError(_("You must provide a file"))
|
||||
|
@ -26,7 +26,7 @@ def send_file(request, file_id, file_class=SithFile, file_attr="file"):
|
||||
iterator for chunks of 8KB.
|
||||
"""
|
||||
f = file_class.objects.filter(id=file_id).first()
|
||||
if f is None or f.is_folder:
|
||||
if f is None or not f.file:
|
||||
return not_found(request)
|
||||
from counter.models import Counter
|
||||
if not (can_view(f, request.user) or
|
||||
|
Reference in New Issue
Block a user