Mtime and url 0.5.0 (#30)

* Add MTIME and modified_time to storage

* update version and docs

* newline EOF

* newline EOF

* url error
This commit is contained in:
Tyrel Souza 2017-01-23 15:56:51 -05:00 committed by GitHub
parent 7cd15e43e0
commit 1561754feb
7 changed files with 35 additions and 4 deletions

View File

@ -54,6 +54,7 @@ I will sign everything with 0x769A1BC78A2DDEE2
## CHANGELOG
- 2017-01-23 [Tyrel Souza] Add Modified Time to storage support
- 2017-01-23 [Tyrel Souza] Everything should return a "filename" even if it's generated. Make the filename be the hash + ext. (fall back to .txt)
- 2017-01-20 [Tyrel Souza] Make path return None if no file
- 2017-01-20 [Tyrel Souza] Make path return filename

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-01-23 20:34
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dbfilestorage', '0003_auto_remove_serialize'),
]
operations = [
migrations.AddField(
model_name='dbfile',
name='mtime',
field=models.DateTimeField(auto_now=True),
),
]

View File

@ -13,6 +13,7 @@ class DBFile(models.Model):
# file data
content_type = models.CharField(max_length=100)
b64 = models.TextField()
mtime = models.DateTimeField(auto_now=True)
def __unicode__(self):
return u"{filehash} <{content_type}>".format(

View File

@ -93,3 +93,8 @@ class DBFileStorage(Storage):
dbf = _get_object(name)
if dbf:
return reverse('dbstorage_file', args=(dbf.name,))
return reverse('dbstorage_file', args=(name,))
def modified_time(self, name):
dbf = _get_object(name)
return dbf.mtime

View File

@ -54,9 +54,9 @@ author = u'Tyrel Souza'
# built documents.
#
# The short X.Y version.
version = u'0.4.2'
version = u'0.5.0'
# The full version, including alpha/beta/rc tags.
release = u'0.4.2'
release = u'0.5.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@ -24,7 +24,7 @@ class CleanCommand(Command):
setup(
name="django-dbfilestorage",
version="0.4.2",
version="0.5.0",
description="Database backed file storage for testing.",
long_description="Database backed file storage for testing. Stores files as base64 encoded textfields.",
author="Tyrel Souza",

View File

@ -99,7 +99,6 @@ class DBFileTest(TestCase):
resp = client.get(url)
self.assertEqual(resp.status_code, 404)
def test_admin(self):
my_admin = User.objects.create_superuser(
username='tester',
@ -110,3 +109,8 @@ class DBFileTest(TestCase):
url = reverse("admin:dbfilestorage_dbfile_changelist")
resp = client.get(url)
self.assertContains(resp, self.md5)
def test_mtime(self):
""" Ensure we can get the modified time """
mtime = default_storage.modified_time(self.filehash_ext)
self.assertIsNotNone(mtime)