Merge remote-tracking branch 'origin/master' into release
This commit is contained in:
commit
65206875ce
@ -54,6 +54,7 @@ I will sign everything with 0x769A1BC78A2DDEE2
|
|||||||
|
|
||||||
## CHANGELOG
|
## CHANGELOG
|
||||||
|
|
||||||
|
- 2017-01-20 [Tyrel Souza] Make path return filename
|
||||||
- 2017-01-20 [Tyrel Souza] Add another migration, and redo all the initial migrations.
|
- 2017-01-20 [Tyrel Souza] Add another migration, and redo all the initial migrations.
|
||||||
- 2017-01-20 [Tyrel Souza] Make sure migrations is actually there.
|
- 2017-01-20 [Tyrel Souza] Make sure migrations is actually there.
|
||||||
- 2017-01-20 [Tyrel Souza] Split filename and filehash.
|
- 2017-01-20 [Tyrel Souza] Split filename and filehash.
|
||||||
|
@ -4,6 +4,7 @@ import hashlib
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from django.db.transaction import atomic
|
from django.db.transaction import atomic
|
||||||
|
from django.db.models import Q
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
from django.core.files.storage import Storage
|
from django.core.files.storage import Storage
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
@ -13,6 +14,10 @@ from .models import DBFile
|
|||||||
L = logging.getLogger(__name__)
|
L = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_object(param):
|
||||||
|
return DBFile.objects.filter(Q(name=param)|Q(filehash=param)).first()
|
||||||
|
|
||||||
|
|
||||||
class DBFileStorage(Storage):
|
class DBFileStorage(Storage):
|
||||||
"""
|
"""
|
||||||
This is the Test Database file upload storage backend.
|
This is the Test Database file upload storage backend.
|
||||||
@ -67,7 +72,8 @@ class DBFileStorage(Storage):
|
|||||||
return name
|
return name
|
||||||
|
|
||||||
def path(self, name):
|
def path(self, name):
|
||||||
return name
|
dbf = _get_object(name)
|
||||||
|
return dbf.name
|
||||||
|
|
||||||
def delete(self, name):
|
def delete(self, name):
|
||||||
assert name, "The name argument is not allowed to be empty."
|
assert name, "The name argument is not allowed to be empty."
|
||||||
|
@ -54,9 +54,9 @@ author = u'Tyrel Souza'
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = u'0.4.0'
|
version = u'0.4.1'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = u'0.4.0'
|
release = u'0.4.1'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
2
setup.py
2
setup.py
@ -24,7 +24,7 @@ class CleanCommand(Command):
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="django-dbfilestorage",
|
name="django-dbfilestorage",
|
||||||
version="0.4.0",
|
version="0.4.1",
|
||||||
description="Database backed file storage for testing.",
|
description="Database backed file storage for testing.",
|
||||||
long_description="Database backed file storage for testing. Stores files as base64 encoded textfields.",
|
long_description="Database backed file storage for testing. Stores files as base64 encoded textfields.",
|
||||||
author="Tyrel Souza",
|
author="Tyrel Souza",
|
||||||
|
@ -75,10 +75,10 @@ class DBFileTest(TestCase):
|
|||||||
default_storage.delete("Nothing")
|
default_storage.delete("Nothing")
|
||||||
|
|
||||||
def test_path(self):
|
def test_path(self):
|
||||||
""" Test the path is just the md5 name """
|
""" Test the path is just the filename, when passed md5 and name """
|
||||||
path = default_storage.path(self.md5)
|
path = default_storage.path(self.md5)
|
||||||
self.assertEqual(self.md5, path)
|
self.assertNotEqual(self.md5, path)
|
||||||
self.assertNotIn(self.filename, path)
|
self.assertEqual(self.filename, path)
|
||||||
|
|
||||||
def test_size(self):
|
def test_size(self):
|
||||||
""" Ensure we can get the proper size """
|
""" Ensure we can get the proper size """
|
||||||
|
Loading…
Reference in New Issue
Block a user