Commit 21a80cc3 authored by Diederik van der Boor's avatar Diederik van der Boor
Browse files

Add logger statement to see the content type of rejected uploads

parent 2b1d0347
#-*- coding: utf-8 -*- #-*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import logging
import os import os
import django import django
...@@ -11,6 +13,9 @@ from django.utils.encoding import smart_str ...@@ -11,6 +13,9 @@ from django.utils.encoding import smart_str
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from .storage import private_storage from .storage import private_storage
logger = logging.getLogger(__name__)
class PrivateFileField(models.FileField): class PrivateFileField(models.FileField):
""" """
...@@ -45,6 +50,7 @@ class PrivateFileField(models.FileField): ...@@ -45,6 +50,7 @@ class PrivateFileField(models.FileField):
content_type = file.content_type content_type = file.content_type
if self.content_types and content_type not in self.content_types: if self.content_types and content_type not in self.content_types:
logger.debug('Rejected uploaded file type: %s', content_type)
raise ValidationError(self.error_messages['invalid_file_type']) raise ValidationError(self.error_messages['invalid_file_type'])
if self.max_file_size and file.size > self.max_file_size: if self.max_file_size and file.size > self.max_file_size:
......
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