diff --git a/apps/common/templates/generic_detail.html b/apps/common/templates/generic_detail.html index bf1c4a4e35..c27cf1a6c0 100755 --- a/apps/common/templates/generic_detail.html +++ b/apps/common/templates/generic_detail.html @@ -30,16 +30,50 @@ {% endblock %} {% block content %} -
+
+ + {% if form %} {% with "true" as read_only %} +
{% include "generic_form_subtemplate.html" %} +
+ {% if grid_clear or not grid %} +
+ {% endif %} {% endwith %} -
+ {% 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 %} +
+ {% with form.form as form %} + {% include "generic_form_subtemplate.html" %} + {% endwith %} +
+ {% if form.grid_clear or not form.grid %} +
+ {% 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 %} +
+ {% include subtemplate.name %} + +
+ {% if subtemplate.grid_clear or not subtemplate.grid %} +
+ {% endif %} {% endwith %} {% endwith %} {% endwith %} @@ -55,6 +96,6 @@ {% endwith %} {% endwith %} {% endfor %} - +
{% endblock %} diff --git a/apps/common/templates/generic_form.html b/apps/common/templates/generic_form.html index 6af32a4cc3..0f079bcf5b 100755 --- a/apps/common/templates/generic_form.html +++ b/apps/common/templates/generic_form.html @@ -6,7 +6,13 @@ {% block content %}
{% if form %} +
{% include "generic_form_subtemplate.html" %} + +
+ {% if form.grid_clear or not form.grid %} +
+ {% 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 %} -
- {% endif %} +
{% with form.form as form %} {% include "generic_form_subtemplate.html" %} {% endwith %} - {% if form.grid %} +
- {% if form.grid_clear %} + {% if form.grid_clear or not form.grid %}
{% endif %} - {% endif %} + {% endwith %} {% endwith %} diff --git a/apps/documents/__init__.py b/apps/documents/__init__.py index ca61be4646..bdd067794c 100755 --- a/apps/documents/__init__.py +++ b/apps/documents/__init__.py @@ -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]) diff --git a/apps/documents/conf/settings.py b/apps/documents/conf/settings.py index 92fca3f6c7..a0d95eff97 100755 --- a/apps/documents/conf/settings.py +++ b/apps/documents/conf/settings.py @@ -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') diff --git a/apps/documents/forms.py b/apps/documents/forms.py index 278a9a8917..f7a39e0d82 100755 --- a/apps/documents/forms.py +++ b/apps/documents/forms.py @@ -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: '' % (reverse('document_preview', args=[x.id]), + # reverse('document_thumbnail', args=[x.id])) + output.append('' % (reverse('document_display', args=[value.id]), + reverse('document_preview', args=[value.id]))) + output.append('
%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('%s
%s %s
%s ' % \ + # (file_path, thumbnail(file_name), _('Currently:'), file_path, file_name, _('Change:'))) + # except IOError: # not image + # output.append('%s %s
%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: diff --git a/apps/documents/urls.py b/apps/documents/urls.py index 64a82f9990..3f20b0053a 100755 --- a/apps/documents/urls.py +++ b/apps/documents/urls.py @@ -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\d+)/delete/$', 'document_delete', (), 'document_delete'), url(r'^document/(?P\d+)/edit/$', 'document_edit', (), 'document_edit'), url(r'^document/(?P\d+)/edit/metadata/$', 'document_edit_metadata', (), 'document_edit_metadata'), - url(r'^document/(?P\d+)/preview/$', 'document_preview', (), 'document_preview'), - url(r'^document/(?P\d+)/thumbnail/$', 'document_thumbnail', (), 'document_thumbnail'), + url(r'^document/(?P\d+)/preview/$', 'get_document_image', {'size':PREVIEW_SIZE}, 'document_preview'), + url(r'^document/(?P\d+)/thumbnail/$', 'get_document_image', {'size':THUMBNAIL_SIZE}, 'document_thumbnail'), + url(r'^document/(?P\d+)/display/$', 'get_document_image', {'size':DISPLAY_SIZE}, 'document_display'), url(r'^document/(?P\d+)/download/$', 'document_download', (), 'document_download'), url(r'^document/(?P\d+)/create/siblings/$', 'document_create_sibling', {'multiple':True}, 'document_create_sibling'), diff --git a/apps/documents/views.py b/apps/documents/views.py index c480389280..b7a70684fc 100755 --- a/apps/documents/views.py +++ b/apps/documents/views.py @@ -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): diff --git a/apps/main/templates/base.html b/apps/main/templates/base.html index 6899ab829b..cf81ccc015 100755 --- a/apps/main/templates/base.html +++ b/apps/main/templates/base.html @@ -12,6 +12,8 @@ + + {% block stylesheets %}{% endblock %} {% endblock %} @@ -32,7 +34,8 @@ 'transitionOut' : 'elastic', 'easingIn' : 'easeOutBack', 'easingOut' : 'easeInBack', - 'type' : 'image' + 'type' : 'image', + 'autoScale' : false, }); }); diff --git a/settings.py b/settings.py index 4358cc4a84..61011c43ff 100755 --- a/settings.py +++ b/settings.py @@ -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'