Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from django.conf import settings
import django.dispatch
from storages.backends.s3boto3 import S3Boto3Storage
from whitenoise.storage import CompressedManifestStaticFilesStorage
# used only for suppressing INFO logging in S3Boto3Storage
import logging
file_saved = django.dispatch.Signal(providing_args=["instance", "path", "overwrite"])
### Static files config
class StaticStorage(CompressedManifestStaticFilesStorage):
pass
### Media files config
class BaseMediaStorage(object):
"""
This mixin provides some helper functions for working with files
in both local disk and remote storage.
"""
def store_file(self, file_object, file_path, overwrite=False, send_signal=True):
"""
Given an open file_object ready for reading,
and the file_path to store it to,
save the file and return the new file name.
from pipeline.storage import PipelineMixin, PipelineStorage
from whitenoise.storage import CompressedManifestStaticFilesStorage, HelpfulExceptionMixin, CompressedStaticFilesMixin
class CompressedManifestPipelineStorage(PipelineMixin, CompressedManifestStaticFilesStorage):
pass
class CompressedPipelineStorage(HelpfulExceptionMixin, CompressedStaticFilesMixin, PipelineStorage):
pass
def post_process(self, *args, **kwargs):
files = super(CompressedManifestStaticFilesStorage, self).post_process(
*args, **kwargs
)
if not kwargs.get("dry_run"):
files = self.post_process_with_compression(files)
return files
from django.contrib.staticfiles import finders
from django.conf import settings
from whitenoise.storage import CompressedManifestStaticFilesStorage
class DebugErroringCompressedManifestStaticFilesStorage(CompressedManifestStaticFilesStorage):
def url(self, name, force=False):
if settings.DEBUG:
if finders.find(name) is None:
raise ValueError("The file '%s' could not be found with %r." % (name, self))
return super(DebugErroringCompressedManifestStaticFilesStorage, self).url(name)
from pipeline.storage import PipelineMixin
from whitenoise.storage import CompressedManifestStaticFilesStorage
class StandupStorage(PipelineMixin, CompressedManifestStaticFilesStorage):
pass