Added document preview and display size view, merged with 960 grid branch
This commit is contained in:
@@ -30,16 +30,50 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div id="subform">
|
||||
<div class="container_12">
|
||||
|
||||
{% if form %}
|
||||
{% with "true" as read_only %}
|
||||
<div class="grid_{{ grid|default:11 }}">
|
||||
{% include "generic_form_subtemplate.html" %}
|
||||
</div>
|
||||
{% if grid_clear or not grid %}
|
||||
<div class="clear"></div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% for subtemplate in subtemplates %}
|
||||
{% include subtemplate %}
|
||||
{% endfor %}
|
||||
|
||||
{% for form in form_list %}
|
||||
{% with form.submit_method as submit_method %}
|
||||
{% with form.striptags as striptags %}
|
||||
{% with form.title as title %}
|
||||
{% with form.object as object %}
|
||||
{% with form.object_name as object_name %}
|
||||
{% with form.form_action as form_action %}
|
||||
{% with "true" as read_only %}
|
||||
<div class="grid_{{ form.grid|default:11 }}">
|
||||
{% with form.form as form %}
|
||||
{% include "generic_form_subtemplate.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% if form.grid_clear or not form.grid %}
|
||||
<div class="clear"></div>
|
||||
{% endif %}
|
||||
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% for subtemplate in subtemplates_dict %}
|
||||
{% with subtemplate.title as title %}
|
||||
{% with subtemplate.object_list as object_list %}
|
||||
@@ -47,7 +81,14 @@
|
||||
{% with subtemplate.hide_object as hide_object %}
|
||||
{% with subtemplate.main_object as main_object %}
|
||||
{% with subtemplate.hide_link as hide_link %}
|
||||
<div class="grid_{{ subtemplate.grid|default:11 }}">
|
||||
|
||||
{% include subtemplate.name %}
|
||||
|
||||
</div>
|
||||
{% if subtemplate.grid_clear or not subtemplate.grid %}
|
||||
<div class="clear"></div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
@@ -55,6 +96,6 @@
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -6,7 +6,13 @@
|
||||
{% block content %}
|
||||
<div class="container_12">
|
||||
{% if form %}
|
||||
<div class="grid_{{ form.grid|default:11 }}">
|
||||
{% include "generic_form_subtemplate.html" %}
|
||||
|
||||
</div>
|
||||
{% if form.grid_clear or not form.grid %}
|
||||
<div class="clear"></div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% for form in form_list %}
|
||||
@@ -16,18 +22,16 @@
|
||||
{% with form.object as object %}
|
||||
{% with form.object_name as object_name %}
|
||||
{% with form.form_action as form_action %}
|
||||
{% if form.grid %}
|
||||
<div class="grid_{{ form.grid }}">
|
||||
{% endif %}
|
||||
<div class="grid_{{ form.grid|default:11 }}">
|
||||
{% with form.form as form %}
|
||||
{% include "generic_form_subtemplate.html" %}
|
||||
{% endwith %}
|
||||
{% if form.grid %}
|
||||
|
||||
</div>
|
||||
{% if form.grid_clear %}
|
||||
{% if form.grid_clear or not form.grid %}
|
||||
<div class="clear"></div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
|
||||
@@ -26,7 +26,7 @@ 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_edit, document_edit_metadata, document_delete, document_download])
|
||||
register_links(Document, [document_list, document_create, document_create_multiple, document_create_sibling, document_view, document_preview], menu_name='sidebar')
|
||||
register_links(Document, [document_list, document_create, document_create_multiple, document_create_sibling, 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])
|
||||
|
||||
@@ -33,6 +33,7 @@ STORAGE_DIRECTORY_NAME = getattr(settings, 'DOCUMENTS_STORAGE_DIRECTORY_NAME', '
|
||||
# Usage
|
||||
PREVIEW_SIZE = getattr(settings, 'DOCUMENTS_PREVIEW_SIZE', '640x480')
|
||||
THUMBNAIL_SIZE = getattr(settings, 'DOCUMENTS_THUMBNAIL_SIZE', '50x50')
|
||||
DISPLAY_SIZE = getattr(settings, 'DOCUMENTS_DISPLAY_SIZE', '1024x768')
|
||||
# Serving
|
||||
FILESYSTEM_FILESERVING_ENABLE = getattr(settings, 'DOCUMENTS_FILESYSTEM_FILESERVING_ENABLE', True)
|
||||
FILESYSTEM_FILESERVING_PATH = getattr(settings, 'DOCUMENTS_FILESYSTEM_FILESERVING_PATH', u'/tmp/mayan/documents')
|
||||
|
||||
@@ -5,6 +5,7 @@ from django.utils.translation import ugettext
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.utils.http import urlencode
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from staging import StagingFile
|
||||
|
||||
@@ -14,9 +15,34 @@ from common.forms import DetailForm
|
||||
|
||||
from models import Document, DocumentType, DocumentTypeMetadataType
|
||||
|
||||
from documents.conf.settings import AVAILABLE_FUNCTIONS
|
||||
from documents.conf.settings import AVAILABLE_MODELS
|
||||
|
||||
#from documents.conf.settings import AVAILABLE_FUNCTIONS
|
||||
#from documents.conf.settings import AVAILABLE_MODELS
|
||||
#from documents.conf.settings import DISPLAY_SIZE
|
||||
|
||||
|
||||
class ImageWidget(forms.widgets.Widget):
|
||||
def render(self, name, value, attrs=None):
|
||||
output = []
|
||||
#img = lambda x: '<a class="fancybox" href="%s"><img src="%s" /></a>' % (reverse('document_preview', args=[x.id]),
|
||||
# reverse('document_thumbnail', args=[x.id]))
|
||||
output.append('<a class="fancybox" href="%s"><img src="%s" /></a>' % (reverse('document_display', args=[value.id]),
|
||||
reverse('document_preview', args=[value.id])))
|
||||
output.append('<br /><span class="famfam active famfam-magnifier"></span>%s' % ugettext(u'Click on the image for full size view'))
|
||||
#file_name = str(value)
|
||||
#if file_name:
|
||||
# file_path = '%s%s' % (settings.MEDIA_URL, file_name)
|
||||
# try: # is image
|
||||
# Image.open(os.path.join(settings.MEDIA_ROOT, file_name))
|
||||
# output.append('<a target="_blank" href="%s">%s</a><br />%s <a target="_blank" href="%s">%s</a><br />%s ' % \
|
||||
# (file_path, thumbnail(file_name), _('Currently:'), file_path, file_name, _('Change:')))
|
||||
# except IOError: # not image
|
||||
# output.append('%s <a target="_blank" href="%s">%s</a> <br />%s ' % \
|
||||
# (_('Currently:'), file_path, file_name, _('Change:')))
|
||||
#
|
||||
#output.append(super(ImageWidget, self).render(name, value, attrs))
|
||||
return mark_safe(u''.join(output))
|
||||
|
||||
|
||||
#TODO: Turn this into a base form and let others inherit
|
||||
class DocumentForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -37,6 +63,16 @@ class DocumentForm(forms.ModelForm):
|
||||
model = Document
|
||||
exclude = ('description',)
|
||||
|
||||
class DocumentPreviewForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.document = kwargs.pop('document', None)
|
||||
super(DocumentPreviewForm, self).__init__(*args, **kwargs)
|
||||
self.fields['preview'].initial = self.document#reverse('document_preview', args=[self.document.id])
|
||||
|
||||
|
||||
preview = forms.CharField(widget=ImageWidget)
|
||||
#ImageWidget
|
||||
|
||||
|
||||
class DocumentForm_view(DetailForm):
|
||||
class Meta:
|
||||
|
||||
@@ -2,6 +2,9 @@ from django.conf.urls.defaults import *
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.generic.create_update import create_object, update_object
|
||||
|
||||
from documents.conf.settings import PREVIEW_SIZE
|
||||
from documents.conf.settings import THUMBNAIL_SIZE
|
||||
from documents.conf.settings import DISPLAY_SIZE
|
||||
|
||||
urlpatterns = patterns('documents.views',
|
||||
url(r'^document/list/$', 'document_list', (), 'document_list'),
|
||||
@@ -13,8 +16,9 @@ urlpatterns = patterns('documents.views',
|
||||
url(r'^document/(?P<document_id>\d+)/delete/$', 'document_delete', (), 'document_delete'),
|
||||
url(r'^document/(?P<document_id>\d+)/edit/$', 'document_edit', (), 'document_edit'),
|
||||
url(r'^document/(?P<document_id>\d+)/edit/metadata/$', 'document_edit_metadata', (), 'document_edit_metadata'),
|
||||
url(r'^document/(?P<document_id>\d+)/preview/$', 'document_preview', (), 'document_preview'),
|
||||
url(r'^document/(?P<document_id>\d+)/thumbnail/$', 'document_thumbnail', (), 'document_thumbnail'),
|
||||
url(r'^document/(?P<document_id>\d+)/preview/$', 'get_document_image', {'size':PREVIEW_SIZE}, 'document_preview'),
|
||||
url(r'^document/(?P<document_id>\d+)/thumbnail/$', 'get_document_image', {'size':THUMBNAIL_SIZE}, 'document_thumbnail'),
|
||||
url(r'^document/(?P<document_id>\d+)/display/$', 'get_document_image', {'size':DISPLAY_SIZE}, 'document_display'),
|
||||
url(r'^document/(?P<document_id>\d+)/download/$', 'document_download', (), 'document_download'),
|
||||
url(r'^document/(?P<document_id>\d+)/create/siblings/$', 'document_create_sibling', {'multiple':True}, 'document_create_sibling'),
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ from utils import from_descriptor_to_tempfile
|
||||
from models import Document, DocumentMetadata, DocumentType, MetadataType
|
||||
from forms import DocumentTypeSelectForm, DocumentCreateWizard, \
|
||||
MetadataForm, DocumentForm, DocumentForm_edit, DocumentForm_view, \
|
||||
StagingDocumentForm, DocumentTypeMetadataType
|
||||
StagingDocumentForm, DocumentTypeMetadataType, DocumentPreviewForm
|
||||
|
||||
from staging import StagingFile
|
||||
|
||||
@@ -233,6 +233,21 @@ def document_view(request, document_id):
|
||||
{'label':_(u'UUID'), 'field':'uuid'},
|
||||
])
|
||||
|
||||
preview_form = DocumentPreviewForm(document=document)
|
||||
form_list = [
|
||||
{
|
||||
'form':form,
|
||||
'object':document,
|
||||
'grid':6,
|
||||
},
|
||||
{
|
||||
'form':preview_form,
|
||||
'title':_(u'document preview'),
|
||||
'object':document,
|
||||
'grid':6,
|
||||
'grid_clear':True,
|
||||
},
|
||||
]
|
||||
subtemplates_dict = [
|
||||
{
|
||||
'name':'generic_list_subtemplate.html',
|
||||
@@ -251,7 +266,7 @@ def document_view(request, document_id):
|
||||
'hide_link':True})
|
||||
|
||||
return render_to_response('generic_detail.html', {
|
||||
'form':form,
|
||||
'form_list':form_list,
|
||||
'object':document,
|
||||
'subtemplates_dict':subtemplates_dict,
|
||||
}, context_instance=RequestContext(request))
|
||||
@@ -384,12 +399,12 @@ def get_document_image(request, document_id, size=PREVIEW_SIZE):
|
||||
#return HttpResponse(e)
|
||||
|
||||
|
||||
def document_thumbnail(request, document_id):
|
||||
return get_document_image(request, document_id, THUMBNAIL_SIZE)
|
||||
#def document_thumbnail(request, document_id):
|
||||
# return get_document_image(request, document_id, THUMBNAIL_SIZE)
|
||||
|
||||
|
||||
def document_preview(request, document_id):
|
||||
return get_document_image(request, document_id, PREVIEW_SIZE)
|
||||
#def document_preview(request, document_id):
|
||||
# return get_document_image(request, document_id, PREVIEW_SIZE)
|
||||
|
||||
|
||||
def document_download(request, document_id):
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
<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" />
|
||||
<link rel="stylesheet" href="{{ MEDIA_URL }}packages/nathansmith-960-Grid-System-30906f2/code/css/960.css" type="text/css" media="screen" />
|
||||
|
||||
{% block stylesheets %}{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -32,7 +34,8 @@
|
||||
'transitionOut' : 'elastic',
|
||||
'easingIn' : 'easeOutBack',
|
||||
'easingOut' : 'easeInBack',
|
||||
'type' : 'image'
|
||||
'type' : 'image',
|
||||
'autoScale' : false,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -186,6 +186,7 @@ LOGIN_EXEMPT_URLS = (
|
||||
# Usage
|
||||
#DOCUMENTS_PREVIEW_SIZE = '640x480'
|
||||
#DOCUMENTS_THUMBNAIL_SIZE = '50x50'
|
||||
#DOCUMENTS_DISPLAY_SIZE = '1024x768'
|
||||
# Serving
|
||||
#DOCUMENTS_FILESYSTEM_FILESERVING_ENABLE = True
|
||||
#DOCUMENTS_FILESYSTEM_FILESERVING_PATH = u'/tmp/mayan/documents'
|
||||
|
||||
Reference in New Issue
Block a user