Added document size display and now the preview link is available in any view
This commit is contained in:
@@ -16,8 +16,8 @@ document_download = {'text':_('download'), 'view':'document_download', 'args':'o
|
||||
|
||||
staging_file_preview = {'text':_('preview'), 'class':'fancybox', 'view':'staging_file_preview', 'args':'object.id', 'famfam':'drive_magnify'}
|
||||
|
||||
register_links(Document, [document_view, document_edit, document_delete, document_preview, document_download])
|
||||
register_links(Document, [document_list, document_create, document_create_multiple], menu_name='sidebar')
|
||||
register_links(Document, [document_edit, document_delete, document_preview, document_download])
|
||||
register_links(Document, [document_list, document_create, document_create_multiple, document_view], menu_name='sidebar')
|
||||
register_links(['document_list', 'document_create', 'document_create_multiple', 'upload_document_with_type', 'upload_multiple_documents_with_type'], [document_list, document_create, document_create_multiple], menu_name='sidebar')
|
||||
|
||||
register_links(StagingFile, [staging_file_preview])
|
||||
|
||||
@@ -3,6 +3,16 @@ import tempfile
|
||||
|
||||
from documents.conf.settings import TEMPORARY_DIRECTORY
|
||||
|
||||
#http://snippets.dzone.com/posts/show/5434
|
||||
#http://snippets.dzone.com/user/jakob
|
||||
def pretty_size(size):
|
||||
suffixes = [("B",2**10), ("K",2**20), ("M",2**30), ("G",2**40), ("T",2**50)]
|
||||
for suf, lim in suffixes:
|
||||
if size > lim:
|
||||
continue
|
||||
else:
|
||||
return round(size/float(lim/2**10),2).__str__()+suf
|
||||
|
||||
|
||||
#http://stackoverflow.com/questions/123198/how-do-i-copy-a-file-in-python
|
||||
def copyfile(source, dest, buffer_size=1024*1024):
|
||||
|
||||
@@ -14,7 +14,7 @@ from django.core.files.base import File
|
||||
from filetransfers.api import serve_file
|
||||
|
||||
from convert import convert, in_cache
|
||||
from utils import from_descriptor_to_tempfile
|
||||
from utils import from_descriptor_to_tempfile, pretty_size
|
||||
|
||||
from models import Document, DocumentMetadata, DocumentType, MetadataType
|
||||
from forms import DocumentTypeSelectForm, DocumentCreateWizard, \
|
||||
@@ -39,11 +39,7 @@ def document_list(request):
|
||||
'extra_columns':[
|
||||
{'name':_(u'mimetype'), 'attribute':'file_mimetype'},
|
||||
{'name':_(u'added'), 'attribute':lambda x: x.date_added.date()},
|
||||
],
|
||||
'subtemplates_dict':[
|
||||
{
|
||||
'name':'fancybox.html',
|
||||
},
|
||||
{'name':_(u'file size'), 'attribute':lambda x: pretty_size(x.file.storage.size(x.file.path)) if x.exists() else '-'},
|
||||
],
|
||||
},
|
||||
)
|
||||
@@ -167,9 +163,6 @@ def upload_document_with_type(request, document_type_id, multiple=True):
|
||||
finally:
|
||||
context.update({
|
||||
'subtemplates_dict':[
|
||||
{
|
||||
'name':'fancybox.html',
|
||||
},
|
||||
{
|
||||
'name':'generic_list_subtemplate.html',
|
||||
'title':_(u'files in staging'),
|
||||
@@ -195,17 +188,15 @@ def document_view(request, document_id):
|
||||
{'label':_(u'Filename'), 'field':'file_filename'},
|
||||
{'label':_(u'File extension'), 'field':'file_extension'},
|
||||
{'label':_(u'File mimetype'), 'field':'file_mimetype'},
|
||||
{'label':_(u'File size'), 'field':lambda x: pretty_size(x.file.storage.size(x.file.path)) if x.exists() else '-'},
|
||||
{'label':_(u'Exists in storage'), 'field':'exists'},
|
||||
{'label':_(u'Date added'), 'field':lambda x: x.date_added.date()},
|
||||
{'label':_(u'Time added'), 'field':lambda x: unicode(x.date_added.time()).split('.')[0]},
|
||||
{'label':_(u'Checksum'), 'field':'checksum'},
|
||||
{'label':_(u'UUID'), 'field':'uuid'},
|
||||
{'label':_(u'Exists in storage'), 'field':'exists'}
|
||||
])
|
||||
|
||||
subtemplates_dict = [
|
||||
{
|
||||
'name':'fancybox.html',
|
||||
},
|
||||
{
|
||||
'name':'generic_list_subtemplate.html',
|
||||
'title':_(u'metadata'),
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
{% block web_theme_stylesheets %}
|
||||
<link rel="stylesheet" href="{{ MEDIA_URL }}css/override.css" type="text/css" media="screen" />
|
||||
<link rel="stylesheet" href="{{ MEDIA_URL }}css/famfamfam-silk-sprite.css" type="text/css" media="screen" />
|
||||
<link rel="stylesheet" href="{{ MEDIA_URL }}packages/jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
|
||||
{% block stylesheets %}{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -20,6 +21,21 @@
|
||||
$("input:text:visible:not(#livesearch):not([readonly]):enabled:first").focus();
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}packages/jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}packages/jquery.fancybox-1.3.4/fancybox/jquery.easing-1.3.pack.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
$("a.fancybox").fancybox({
|
||||
'titleShow' : false,
|
||||
'transitionIn' : 'elastic',
|
||||
'transitionOut' : 'elastic',
|
||||
'easingIn' : 'easeOutBack',
|
||||
'easingOut' : 'easeInBack',
|
||||
'type' : 'image'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% block javascript %}{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* Implement single sign on or LDAP for intranets - DEFERRED, provided by Django AuthBackends
|
||||
* Database storage backend (sql, nosql: [mongodb]) - DEFERRED, provided by https://bitbucket.org/david/django-storages/wiki/Home
|
||||
* Staging file previews - DONE
|
||||
* Display file size in list and details - DONE
|
||||
* Document list filtering by metadata
|
||||
* Filterform date filtering widget
|
||||
* Validate GET data before saving file
|
||||
|
||||
Reference in New Issue
Block a user