mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
1ff6e37de4
New Storage.get_{accessed,created,modified}_time() methods convert the naive time from now-deprecated {accessed,created_modified}_time() methods into aware objects in UTC if USE_TZ=True.
29 lines
677 B
Python
29 lines
677 B
Python
from datetime import datetime
|
|
|
|
from django.contrib.staticfiles.storage import CachedStaticFilesStorage
|
|
from django.core.files import storage
|
|
from django.utils import timezone
|
|
|
|
|
|
class DummyStorage(storage.Storage):
|
|
"""
|
|
A storage class that implements get_modified_time().
|
|
"""
|
|
def _save(self, name, content):
|
|
return 'dummy'
|
|
|
|
def delete(self, name):
|
|
pass
|
|
|
|
def exists(self, name):
|
|
pass
|
|
|
|
def get_modified_time(self, name):
|
|
return datetime.datetime(1970, 1, 1, tzinfo=timezone.utc)
|
|
|
|
|
|
class SimpleCachedStaticFilesStorage(CachedStaticFilesStorage):
|
|
|
|
def file_hash(self, name, content=None):
|
|
return 'deploy12345'
|