Manual merge of the new document preview code from the unstable branch
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django import forms
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.utils.html import conditional_escape
|
||||
from django.utils.safestring import mark_safe
|
||||
@@ -16,7 +15,7 @@ from .models import (Document, DocumentType,
|
||||
DocumentVersion)
|
||||
from .literals import (RELEASE_LEVEL_FINAL, RELEASE_LEVEL_CHOICES,
|
||||
DEFAULT_ZIP_FILENAME)
|
||||
from .widgets import document_html_widget
|
||||
from .widgets import DocumentPageImageWidget, DocumentPagesCarouselWidget
|
||||
|
||||
|
||||
# Document page forms
|
||||
@@ -29,26 +28,11 @@ class DocumentPageTransformationForm(forms.ModelForm):
|
||||
self.fields['document_page'].widget = forms.HiddenInput()
|
||||
|
||||
|
||||
class DocumentPageImageWidget(forms.widgets.Widget):
|
||||
def render(self, name, value, attrs=None):
|
||||
final_attrs = self.build_attrs(attrs)
|
||||
zoom = final_attrs.get('zoom', 100)
|
||||
rotation = final_attrs.get('rotation', 0)
|
||||
if value:
|
||||
output = []
|
||||
output.append('<div class="full-height scrollable" style="overflow: auto;">')
|
||||
|
||||
output.append(document_html_widget(value.document, view='document_display', page=value.page_number, zoom=zoom, rotation=rotation))
|
||||
output.append('</div>')
|
||||
return mark_safe(u''.join(output))
|
||||
else:
|
||||
return u''
|
||||
|
||||
|
||||
class DocumentPageForm(DetailForm):
|
||||
class Meta:
|
||||
model = DocumentPage
|
||||
exclude = ('document', 'document_type', 'page_label', 'content')
|
||||
#exclude = ('document', 'document_type', 'page_label', 'content')
|
||||
fields = ()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
zoom = kwargs.pop('zoom', 100)
|
||||
@@ -96,37 +80,6 @@ class DocumentPageForm_edit(forms.ModelForm):
|
||||
|
||||
|
||||
# Document forms
|
||||
class DocumentPagesCarouselWidget(forms.widgets.Widget):
|
||||
"""
|
||||
Display many small representations of a document pages
|
||||
"""
|
||||
def render(self, name, value, attrs=None):
|
||||
output = []
|
||||
output.append(u'<div style="white-space:nowrap; overflow: auto;">')
|
||||
|
||||
for page in value.pages.all():
|
||||
|
||||
output.append(u'<div style="display: inline-block; margin: 5px 10px 10px 10px;">')
|
||||
output.append(u'<div class="tc">%(page_string)s %(page)s</div>' % {'page_string': ugettext(u'Page'), 'page': page.page_number})
|
||||
output.append(
|
||||
document_html_widget(
|
||||
page.document,
|
||||
view='document_preview_multipage',
|
||||
click_view='document_display',
|
||||
page=page.page_number,
|
||||
gallery_name='document_pages',
|
||||
fancybox_class='fancybox-noscaling',
|
||||
)
|
||||
)
|
||||
output.append(u'<div class="tc">')
|
||||
output.append(u'<a class="fancybox-iframe" href="%s"><span class="famfam active famfam-page_white_go"></span>%s</a>' % (reverse('document_page_view', args=[page.pk]), ugettext(u'Details')))
|
||||
output.append(u'</div>')
|
||||
output.append(u'</div>')
|
||||
|
||||
output.append(u'</div>')
|
||||
output.append(u'<br /><span class="famfam active famfam-magnifier"></span>%s' % ugettext(u'Click on the image for full size preview'))
|
||||
|
||||
return mark_safe(u''.join(output))
|
||||
|
||||
|
||||
class DocumentPreviewForm(forms.Form):
|
||||
@@ -146,7 +99,8 @@ class DocumentForm(forms.ModelForm):
|
||||
"""
|
||||
class Meta:
|
||||
model = Document
|
||||
exclude = ('description', 'tags', 'document_type')
|
||||
#exclude = ('description', 'tags', 'document_type')
|
||||
exclude = ('tags', 'document_type')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
document_type = kwargs.pop('document_type', None)
|
||||
|
||||
Reference in New Issue
Block a user