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:
parent
7cd15e43e0
commit
1561754feb
@ -54,6 +54,7 @@ I will sign everything with 0x769A1BC78A2DDEE2
|
|||||||
|
|
||||||
## CHANGELOG
|
## 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-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 None if no file
|
||||||
- 2017-01-20 [Tyrel Souza] Make path return filename
|
- 2017-01-20 [Tyrel Souza] Make path return filename
|
||||||
|
20
dbfilestorage/migrations/0004_dbfile_mtime.py
Normal file
20
dbfilestorage/migrations/0004_dbfile_mtime.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
@ -13,6 +13,7 @@ class DBFile(models.Model):
|
|||||||
# file data
|
# file data
|
||||||
content_type = models.CharField(max_length=100)
|
content_type = models.CharField(max_length=100)
|
||||||
b64 = models.TextField()
|
b64 = models.TextField()
|
||||||
|
mtime = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u"{filehash} <{content_type}>".format(
|
return u"{filehash} <{content_type}>".format(
|
||||||
|
@ -93,3 +93,8 @@ class DBFileStorage(Storage):
|
|||||||
dbf = _get_object(name)
|
dbf = _get_object(name)
|
||||||
if dbf:
|
if dbf:
|
||||||
return reverse('dbstorage_file', args=(dbf.name,))
|
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
|
||||||
|
@ -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.2'
|
version = u'0.5.0'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# 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
|
# 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.2",
|
version="0.5.0",
|
||||||
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",
|
||||||
|
@ -99,7 +99,6 @@ class DBFileTest(TestCase):
|
|||||||
resp = client.get(url)
|
resp = client.get(url)
|
||||||
self.assertEqual(resp.status_code, 404)
|
self.assertEqual(resp.status_code, 404)
|
||||||
|
|
||||||
|
|
||||||
def test_admin(self):
|
def test_admin(self):
|
||||||
my_admin = User.objects.create_superuser(
|
my_admin = User.objects.create_superuser(
|
||||||
username='tester',
|
username='tester',
|
||||||
@ -110,3 +109,8 @@ class DBFileTest(TestCase):
|
|||||||
url = reverse("admin:dbfilestorage_dbfile_changelist")
|
url = reverse("admin:dbfilestorage_dbfile_changelist")
|
||||||
resp = client.get(url)
|
resp = client.get(url)
|
||||||
self.assertContains(resp, self.md5)
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user