# Path: chamber/config.py
# DEFAULTS = {
#     'MAX_FILE_UPLOAD_SIZE': 20,
#     'MULTIDOMAINS_OVERTAKER_AUTH_COOKIE_NAME': None,
#     'DEFAULT_IMAGE_ALLOWED_CONTENT_TYPES': {'image/jpeg', 'image/png', 'image/gif'},
#     'PRIVATE_S3_STORAGE_URL_EXPIRATION': 3600,
#     'AWS_S3_ON': getattr(django_settings, 'AWS_S3_ON', False),
#     'AWS_REGION': getattr(django_settings, 'AWS_REGION', None),
# }
# class Settings:
#     def __getattr__(self, attr):
# 
# Path: chamber/forms/validators.py
# class RestrictedFileValidator:
# 
#     def __init__(self, max_upload_size):
#         self.max_upload_size = max_upload_size
# 
#     def __call__(self, data):
#         if data.size > self.max_upload_size:
#             raise ValidationError(
#                 ugettext('Please keep filesize under {max}. Current filesize {current}').format(
#                     max=filesizeformat(self.max_upload_size),
#                     current=filesizeformat(data.size)
#                 )
#             )
#         else:
#             return data
# 
# class AllowedContentTypesByFilenameFileValidator:
# 
#     def __init__(self, content_types):
#         self.content_types = content_types
# 
#     def __call__(self, data):
#         extension_mime_type = mimetypes.guess_type(data.name)[0]
# 
#         if extension_mime_type not in self.content_types:
#             raise ValidationError(ugettext('Extension of file name is not allowed'))
# 
#         return data
# 
# class AllowedContentTypesByContentFileValidator:
# 
#     def __init__(self, content_types):
#         self.content_types = content_types
# 
#     def __call__(self, data):
#         data.open()
#         with magic.Magic(flags=magic.MAGIC_MIME_TYPE) as m:
#             mime_type = m.id_buffer(data.read(2048))
#             data.seek(0)
#             if mime_type not in self.content_types:
#                 raise ValidationError(ugettext('File content was evaluated as not supported file type'))
# 
#         return data


from django import forms
from django.utils.translation import ugettext
from chamber.config import settings
from .validators import (
    RestrictedFileValidator, AllowedContentTypesByFilenameFileValidator, AllowedContentTypesByContentFileValidator
)
        if self.min is not None:
            attrs['min'] = self.min
        if self.max is not None:
            attrs['max'] = self.max
        return attrs


class PriceNumberInput(forms.NumberInput):

    def __init__(self, currency, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.placeholder = currency


class PriceField(DecimalField):

    widget = PriceNumberInput

    def __init__(self, *args, **kwargs):
        currency = kwargs.pop('currency', ugettext('CZK'))
        kwargs.setdefault('max_digits', 10)
        kwargs.setdefault('decimal_places', 2)
        if 'widget' not in kwargs:
            kwargs['widget'] = PriceNumberInput(currency)
        super().__init__(*args, **kwargs)


class RestrictedFileField(forms.FileField):

    def __init__(self, *args, **kwargs):

# Path: chamber/config.py
# DEFAULTS = {
#     'MAX_FILE_UPLOAD_SIZE': 20,
#     'MULTIDOMAINS_OVERTAKER_AUTH_COOKIE_NAME': None,
#     'DEFAULT_IMAGE_ALLOWED_CONTENT_TYPES': {'image/jpeg', 'image/png', 'image/gif'},
#     'PRIVATE_S3_STORAGE_URL_EXPIRATION': 3600,
#     'AWS_S3_ON': getattr(django_settings, 'AWS_S3_ON', False),
#     'AWS_REGION': getattr(django_settings, 'AWS_REGION', None),
# }
# class Settings:
#     def __getattr__(self, attr):
# 
# Path: chamber/forms/validators.py
# class RestrictedFileValidator:
# 
#     def __init__(self, max_upload_size):
#         self.max_upload_size = max_upload_size
# 
#     def __call__(self, data):
#         if data.size > self.max_upload_size:
#             raise ValidationError(
#                 ugettext('Please keep filesize under {max}. Current filesize {current}').format(
#                     max=filesizeformat(self.max_upload_size),
#                     current=filesizeformat(data.size)
#                 )
#             )
#         else:
#             return data
# 
# class AllowedContentTypesByFilenameFileValidator:
# 
#     def __init__(self, content_types):
#         self.content_types = content_types
# 
#     def __call__(self, data):
#         extension_mime_type = mimetypes.guess_type(data.name)[0]
# 
#         if extension_mime_type not in self.content_types:
#             raise ValidationError(ugettext('Extension of file name is not allowed'))
# 
#         return data
# 
# class AllowedContentTypesByContentFileValidator:
# 
#     def __init__(self, content_types):
#         self.content_types = content_types
# 
#     def __call__(self, data):
#         data.open()
#         with magic.Magic(flags=magic.MAGIC_MIME_TYPE) as m:
#             mime_type = m.id_buffer(data.read(2048))
#             data.seek(0)
#             if mime_type not in self.content_types:
#                 raise ValidationError(ugettext('File content was evaluated as not supported file type'))
# 
#         return data


# Path: chamber/forms/fields.py
from django import forms
from django.utils.translation import ugettext
from chamber.config import settings
from .validators import (
    RestrictedFileValidator, AllowedContentTypesByFilenameFileValidator, AllowedContentTypesByContentFileValidator
)

        if self.min is not None:
            attrs['min'] = self.min
        if self.max is not None:
            attrs['max'] = self.max
        return attrs


class PriceNumberInput(forms.NumberInput):

    def __init__(self, currency, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.placeholder = currency


class PriceField(DecimalField):

    widget = PriceNumberInput

    def __init__(self, *args, **kwargs):
        currency = kwargs.pop('currency', ugettext('CZK'))
        kwargs.setdefault('max_digits', 10)
        kwargs.setdefault('decimal_places', 2)
        if 'widget' not in kwargs:
            kwargs['widget'] = PriceNumberInput(currency)
        super().__init__(*args, **kwargs)


class RestrictedFileField(forms.FileField):

    def __init__(self, *args, **kwargs):

        max_upload_size = kwargs.pop('max_upload_size', settings.MAX_FILE_UPLOAD_SIZE) * 1024 * 1024