Added document printing support
This commit is contained in:
@@ -1,8 +1,14 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from common.literals import PAGE_SIZE_LETTER, PAGE_ORIENTATION_PORTRAIT
|
||||||
|
|
||||||
TEMPORARY_DIRECTORY = getattr(settings, 'COMMON_TEMPORARY_DIRECTORY', u'/tmp')
|
TEMPORARY_DIRECTORY = getattr(settings, 'COMMON_TEMPORARY_DIRECTORY', u'/tmp')
|
||||||
|
|
||||||
setting_description = {
|
setting_description = {
|
||||||
'COMMON_TEMPORARY_DIRECTORY': _(u'Temporary directory used site wide to store thumbnails, previews and temporary files. If none is specified, one will be created using tempfile.mkdtemp()')
|
'COMMON_TEMPORARY_DIRECTORY': _(u'Temporary directory used site wide to store thumbnails, previews and temporary files. If none is specified, one will be created using tempfile.mkdtemp()')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Printing
|
||||||
|
DEFAULT_PAPER_SIZE = getattr(settings, 'COMMON_DEFAULT_PAPER_SIZE', PAGE_SIZE_LETTER)
|
||||||
|
DEFAULT_PAGE_ORIENTATION = getattr(settings, 'COMMON_DEFAULT_PAGE_ORIENTATION', PAGE_ORIENTATION_PORTRAIT)
|
||||||
|
|||||||
40
apps/common/literals.py
Normal file
40
apps/common/literals.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
PAGE_SIZE_A5 = u'a5'
|
||||||
|
PAGE_SIZE_A4 = u'a4'
|
||||||
|
PAGE_SIZE_A3 = u'a3'
|
||||||
|
PAGE_SIZE_B5 = u'b5'
|
||||||
|
PAGE_SIZE_B4 = u'b4'
|
||||||
|
PAGE_SIZE_LETTER = u'letter'
|
||||||
|
PAGE_SIZE_LEGAL = u'legal'
|
||||||
|
PAGE_SIZE_LEDGER = u'ledger'
|
||||||
|
|
||||||
|
PAGE_SIZE_DIMENSIONS = (
|
||||||
|
(PAGE_SIZE_A5, (u'148mm', u'210mm')),
|
||||||
|
(PAGE_SIZE_A4, (u'210mm', u'297mm')),
|
||||||
|
(PAGE_SIZE_A3, (u'297mm', u'420mm')),
|
||||||
|
(PAGE_SIZE_B5, (u'176mm', u'250mm')),
|
||||||
|
(PAGE_SIZE_B4, (u'250mm', u'353mm')),
|
||||||
|
(PAGE_SIZE_LETTER, (u'8.5in', u'11in')),
|
||||||
|
(PAGE_SIZE_LEGAL, (u'8.5in', u'14in')),
|
||||||
|
(PAGE_SIZE_LEDGER, (u'11in', u'17in'))
|
||||||
|
)
|
||||||
|
|
||||||
|
PAGE_SIZE_CHOICES = (
|
||||||
|
(PAGE_SIZE_A5, _(u'A5')),
|
||||||
|
(PAGE_SIZE_A4, _(u'A4')),
|
||||||
|
(PAGE_SIZE_A3, _(u'A3')),
|
||||||
|
(PAGE_SIZE_B5, _(u'B5')),
|
||||||
|
(PAGE_SIZE_B4, _(u'B4')),
|
||||||
|
(PAGE_SIZE_LETTER, _(u'Letter')),
|
||||||
|
(PAGE_SIZE_LEGAL, _(u'Legal')),
|
||||||
|
(PAGE_SIZE_LEDGER, _(u'Ledger'))
|
||||||
|
)
|
||||||
|
|
||||||
|
PAGE_ORIENTATION_PORTRAIT = u'portrait'
|
||||||
|
PAGE_ORIENTATION_LANDSCAPE = u'landscape'
|
||||||
|
|
||||||
|
PAGE_ORIENTATION_CHOICES = (
|
||||||
|
(PAGE_ORIENTATION_PORTRAIT, _(u'Portrait')),
|
||||||
|
(PAGE_ORIENTATION_LANDSCAPE, _(u'Landscape')),
|
||||||
|
)
|
||||||
@@ -302,3 +302,12 @@ def return_type(value):
|
|||||||
return ','.join(list(value))
|
return ','.join(list(value))
|
||||||
else:
|
else:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
# http://stackoverflow.com/questions/4248399/page-range-for-printing-algorithm
|
||||||
|
def parse_range(astr):
|
||||||
|
result=set()
|
||||||
|
for part in astr.split(u','):
|
||||||
|
x=part.split(u'-')
|
||||||
|
result.update(range(int(x[0]),int(x[-1])+1))
|
||||||
|
return sorted(result)
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ register_diagnostic('documents', _(u'Documents'), document_missing_list)
|
|||||||
|
|
||||||
register_tool(document_find_all_duplicates, namespace='documents', title=_(u'documents'))
|
register_tool(document_find_all_duplicates, namespace='documents', title=_(u'documents'))
|
||||||
|
|
||||||
|
|
||||||
def document_exists(document):
|
def document_exists(document):
|
||||||
try:
|
try:
|
||||||
if document.exists():
|
if document.exists():
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ from django.conf import settings
|
|||||||
from tags.widgets import get_tags_inline_widget
|
from tags.widgets import get_tags_inline_widget
|
||||||
from common.wizard import BoundFormWizard
|
from common.wizard import BoundFormWizard
|
||||||
from common.forms import DetailForm
|
from common.forms import DetailForm
|
||||||
|
from common.literals import PAGE_SIZE_CHOICES, PAGE_ORIENTATION_CHOICES
|
||||||
|
from common.conf.settings import DEFAULT_PAPER_SIZE
|
||||||
|
from common.conf.settings import DEFAULT_PAGE_ORIENTATION
|
||||||
|
|
||||||
from documents.staging import StagingFile
|
from documents.staging import StagingFile
|
||||||
from documents.models import Document, DocumentType, DocumentTypeMetadataType, \
|
from documents.models import Document, DocumentType, DocumentTypeMetadataType, \
|
||||||
@@ -423,3 +426,11 @@ class MetaDataGroupForm(forms.Form):
|
|||||||
'links': links
|
'links': links
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class PrintForm(forms.Form):
|
||||||
|
page_size = forms.ChoiceField(choices=PAGE_SIZE_CHOICES, initial=DEFAULT_PAPER_SIZE, label=_(u'Page size'), required=False)
|
||||||
|
custom_page_width = forms.CharField(label=_(u'Custom page width'), required=False)
|
||||||
|
custom_page_height = forms.CharField(label=_(u'Custom page height'), required=False)
|
||||||
|
page_orientation = forms.ChoiceField(choices=PAGE_ORIENTATION_CHOICES, initial=DEFAULT_PAGE_ORIENTATION, label=_(u'Page orientation'), required=True)
|
||||||
|
page_range = forms.CharField(label=_(u'Page range'), required=False)
|
||||||
|
|||||||
@@ -2,23 +2,3 @@ PICTURE_ERROR_SMALL = u'picture_error.png'
|
|||||||
PICTURE_ERROR_MEDIUM = u'1297211435_error.png'
|
PICTURE_ERROR_MEDIUM = u'1297211435_error.png'
|
||||||
PICTURE_UNKNOWN_SMALL = u'1299549572_unknown2.png'
|
PICTURE_UNKNOWN_SMALL = u'1299549572_unknown2.png'
|
||||||
PICTURE_UNKNOWN_MEDIUM = u'1299549805_unknown.png'
|
PICTURE_UNKNOWN_MEDIUM = u'1299549805_unknown.png'
|
||||||
|
|
||||||
PAGE_SIZE_A5 = u'a5'
|
|
||||||
PAGE_SIZE_A4 = u'a4'
|
|
||||||
PAGE_SIZE_A3 = u'a3'
|
|
||||||
PAGE_SIZE_B5 = u'b5'
|
|
||||||
PAGE_SIZE_B4 = u'b4'
|
|
||||||
PAGE_SIZE_LETTER = u'letter'
|
|
||||||
PAGE_SIZE_LEGAL = u'legal'
|
|
||||||
PAGE_SIZE_LEDGER = u'ledger'
|
|
||||||
|
|
||||||
PAGE_SIZE_DIMENSIONS = (
|
|
||||||
(PAGE_SIZE_A5, (u'148mm', u'210mm')),
|
|
||||||
(PAGE_SIZE_A4, (u'210mm', u'297mm')),
|
|
||||||
(PAGE_SIZE_A3, (u'297mm', u'420mm')),
|
|
||||||
(PAGE_SIZE_B5, (u'176mm', u'250mm')),
|
|
||||||
(PAGE_SIZE_B4, (u'250mm', u'353mm')),
|
|
||||||
(PAGE_SIZE_LETTER, (u'8.5in', u'11in')),
|
|
||||||
(PAGE_SIZE_LEGAL, (u'8.5in', u'14in')),
|
|
||||||
(PAGE_SIZE_LEDGER, (u'11in', u'17in'))
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
.break { page-break-after: always; }
|
.break { page-break-after: always; }
|
||||||
img { border: 1px solid black; }
|
img { border: 1px solid black; }
|
||||||
@page {
|
@page {
|
||||||
size: {{ page_size.0 }} {{ page_size.1 }};
|
size: {{ page_width }} {{ page_height }};
|
||||||
margin-top: 1cm;
|
margin-top: 1cm;
|
||||||
margin-bottom: 1cm;
|
margin-bottom: 1cm;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{% for page in object.documentpage_set.all %}
|
{% for page in pages %}
|
||||||
{% get_document_size object %}
|
{% get_document_size object %}
|
||||||
<div class="{% if forloop.counter > 1 %}break{% endif %}">
|
<div class="{% if forloop.counter > 1 %}break{% endif %}">
|
||||||
<img src="{% url document_display_print object.id %}?page={{ page.page_number }}" {% if document_aspect > page_aspect %}width="97%"{% else %}height="97%"{% endif %} />
|
<img src="{% url document_display_print object.id %}?page={{ page.page_number }}" {% if document_aspect > page_aspect %}width="97%"{% else %}height="97%"{% endif %} />
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from django.template import TemplateSyntaxError, Library, \
|
from django.template import Library, Node, Variable
|
||||||
VariableDoesNotExist, Node, Variable
|
|
||||||
from converter.api import get_document_dimensions, QUALITY_PRINT
|
from converter.api import get_document_dimensions, QUALITY_PRINT
|
||||||
|
|
||||||
from documents.views import calculate_converter_arguments
|
from documents.views import calculate_converter_arguments
|
||||||
from documents.conf.settings import PRINT_SIZE
|
from documents.conf.settings import PRINT_SIZE
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ class GetImageSizeNode(Node):
|
|||||||
context[u'document_aspect'] = float(width) / float(height)
|
context[u'document_aspect'] = float(width) / float(height)
|
||||||
return u''
|
return u''
|
||||||
|
|
||||||
|
|
||||||
@register.tag
|
@register.tag
|
||||||
def get_document_size(parser, token):
|
def get_document_size(parser, token):
|
||||||
tag_name, arg = token.contents.split(None, 1)
|
tag_name, arg = token.contents.split(None, 1)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ urlpatterns = patterns('documents.views',
|
|||||||
url(r'^document/(?P<document_id>\d+)/edit/metadata/$', 'document_edit_metadata', (), 'document_edit_metadata'),
|
url(r'^document/(?P<document_id>\d+)/edit/metadata/$', 'document_edit_metadata', (), 'document_edit_metadata'),
|
||||||
url(r'^document/multiple/edit/metadata/$', 'document_multiple_edit_metadata', (), 'document_multiple_edit_metadata'),
|
url(r'^document/multiple/edit/metadata/$', 'document_multiple_edit_metadata', (), 'document_multiple_edit_metadata'),
|
||||||
url(r'^document/(?P<document_id>\d+)/print/$', 'document_print', (), 'document_print'),
|
url(r'^document/(?P<document_id>\d+)/print/$', 'document_print', (), 'document_print'),
|
||||||
|
url(r'^document/(?P<document_id>\d+)/hard_copy/$', 'document_hard_copy', (), 'document_hard_copy'),
|
||||||
|
|
||||||
url(r'^document/(?P<document_id>\d+)/display/preview/$', 'get_document_image', {'size': PREVIEW_SIZE}, 'document_preview'),
|
url(r'^document/(?P<document_id>\d+)/display/preview/$', 'get_document_image', {'size': PREVIEW_SIZE}, 'document_preview'),
|
||||||
url(r'^document/(?P<document_id>\d+)/display/preview/multipage/$', 'get_document_image', {'size': MULTIPAGE_PREVIEW_SIZE}, 'document_preview_multipage'),
|
url(r'^document/(?P<document_id>\d+)/display/preview/multipage/$', 'get_document_image', {'size': MULTIPAGE_PREVIEW_SIZE}, 'document_preview_multipage'),
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile
|
|||||||
from django.contrib.comments.models import Comment
|
from django.contrib.comments.models import Comment
|
||||||
|
|
||||||
import sendfile
|
import sendfile
|
||||||
from common.utils import pretty_size
|
from common.utils import pretty_size, parse_range, urlquote
|
||||||
from converter.api import convert_document, QUALITY_DEFAULT
|
from converter.api import convert_document, QUALITY_DEFAULT
|
||||||
from converter.exceptions import UnkownConvertError, UnknownFormat
|
from converter.exceptions import UnkownConvertError, UnknownFormat
|
||||||
from filetransfers.api import serve_file
|
from filetransfers.api import serve_file
|
||||||
@@ -28,8 +28,10 @@ from navigation.utils import resolve_to_name
|
|||||||
from tags.utils import get_tags_subtemplate
|
from tags.utils import get_tags_subtemplate
|
||||||
from document_comments.utils import get_comments_subtemplate
|
from document_comments.utils import get_comments_subtemplate
|
||||||
from converter.api import DEFAULT_ZOOM_LEVEL, DEFAULT_ROTATION, \
|
from converter.api import DEFAULT_ZOOM_LEVEL, DEFAULT_ROTATION, \
|
||||||
DEFAULT_FILE_FORMAT
|
DEFAULT_FILE_FORMAT, QUALITY_PRINT
|
||||||
from converter.api import QUALITY_PRINT
|
from common.literals import PAGE_SIZE_DIMENSIONS, \
|
||||||
|
PAGE_ORIENTATION_PORTRAIT, PAGE_ORIENTATION_LANDSCAPE
|
||||||
|
from common.conf.settings import DEFAULT_PAPER_SIZE
|
||||||
|
|
||||||
from documents.conf.settings import DELETE_STAGING_FILE_AFTER_UPLOAD
|
from documents.conf.settings import DELETE_STAGING_FILE_AFTER_UPLOAD
|
||||||
from documents.conf.settings import USE_STAGING_DIRECTORY
|
from documents.conf.settings import USE_STAGING_DIRECTORY
|
||||||
@@ -57,7 +59,7 @@ from documents.forms import DocumentTypeSelectForm, DocumentCreateWizard, \
|
|||||||
StagingDocumentForm, DocumentTypeMetadataType, DocumentPreviewForm, \
|
StagingDocumentForm, DocumentTypeMetadataType, DocumentPreviewForm, \
|
||||||
MetadataFormSet, DocumentPageForm, DocumentPageTransformationForm, \
|
MetadataFormSet, DocumentPageForm, DocumentPageTransformationForm, \
|
||||||
DocumentContentForm, DocumentPageForm_edit, MetaDataGroupForm, \
|
DocumentContentForm, DocumentPageForm_edit, MetaDataGroupForm, \
|
||||||
DocumentPageForm_text
|
DocumentPageForm_text, PrintForm
|
||||||
|
|
||||||
from documents.metadata import save_metadata_list, \
|
from documents.metadata import save_metadata_list, \
|
||||||
decode_metadata_from_url, metadata_repr_as_list
|
decode_metadata_from_url, metadata_repr_as_list
|
||||||
@@ -66,8 +68,7 @@ from documents.models import Document, DocumentType, DocumentPage, \
|
|||||||
from documents.staging import StagingFile
|
from documents.staging import StagingFile
|
||||||
from documents import metadata_group_link
|
from documents import metadata_group_link
|
||||||
from documents.literals import PICTURE_ERROR_SMALL, PICTURE_ERROR_MEDIUM, \
|
from documents.literals import PICTURE_ERROR_SMALL, PICTURE_ERROR_MEDIUM, \
|
||||||
PICTURE_UNKNOWN_SMALL, PICTURE_UNKNOWN_MEDIUM, PAGE_SIZE_DIMENSIONS, \
|
PICTURE_UNKNOWN_SMALL, PICTURE_UNKNOWN_MEDIUM
|
||||||
PAGE_SIZE_LETTER, PAGE_SIZE_LEGAL
|
|
||||||
|
|
||||||
|
|
||||||
def document_list(request, object_list=None, title=None):
|
def document_list(request, object_list=None, title=None):
|
||||||
@@ -1154,36 +1155,96 @@ def metadatagroup_view(request, document_id, metadata_group_id):
|
|||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
def document_print(request, document_id, page_size=PAGE_SIZE_LEGAL):
|
def document_print(request, document_id):
|
||||||
check_permissions(request.user, 'documents', [PERMISSION_DOCUMENT_VIEW])
|
check_permissions(request.user, 'documents', [PERMISSION_DOCUMENT_VIEW])
|
||||||
|
|
||||||
document = get_object_or_404(Document.objects.select_related(), pk=document_id)
|
document = get_object_or_404(Document, pk=document_id)
|
||||||
|
|
||||||
RecentDocument.objects.add_document_for_user(request.user, document)
|
RecentDocument.objects.add_document_for_user(request.user, document)
|
||||||
|
|
||||||
#page = int(request.GET.get('page', 1))
|
post_redirect = None
|
||||||
#zoom = int(request.GET.get('zoom', 100))
|
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', post_redirect or document.get_absolute_url())))
|
||||||
#if zoom < ZOOM_MIN_LEVEL:
|
|
||||||
# zoom = ZOOM_MIN_LEVEL
|
new_window_url = None
|
||||||
#if zoom > ZOOM_MAX_LEVEL:
|
html_redirect = None
|
||||||
# zoom = ZOOM_MAX_LEVEL
|
|
||||||
#rotation = int(request.GET.get('rotation', 0)) % 360
|
if request.method == 'POST':
|
||||||
|
form = PrintForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
hard_copy_arguments = {}
|
||||||
|
# Get page range
|
||||||
|
if form.cleaned_data['page_range']:
|
||||||
|
hard_copy_arguments['page_range'] = form.cleaned_data['page_range']
|
||||||
|
|
||||||
|
# Compute page width and height
|
||||||
|
if form.cleaned_data['custom_page_width'] and form.cleaned_data['custom_page_height']:
|
||||||
|
page_width = form.cleaned_data['custom_page_width']
|
||||||
|
page_height = form.cleaned_data['custom_page_height']
|
||||||
|
elif form.cleaned_data['page_size']:
|
||||||
|
page_width, page_height = dict(PAGE_SIZE_DIMENSIONS)[form.cleaned_data['page_size']]
|
||||||
|
|
||||||
|
# Page orientation
|
||||||
|
if form.cleaned_data['page_orientation'] == PAGE_ORIENTATION_LANDSCAPE:
|
||||||
|
page_width, page_height = page_height, page_width
|
||||||
|
|
||||||
|
hard_copy_arguments['page_width'] = page_width
|
||||||
|
hard_copy_arguments['page_height'] = page_height
|
||||||
|
|
||||||
|
new_url = [reverse('document_hard_copy', args=[document_id])]
|
||||||
|
if hard_copy_arguments:
|
||||||
|
new_url.append(urlquote(hard_copy_arguments))
|
||||||
|
|
||||||
|
new_window_url = u'?'.join(new_url)
|
||||||
|
#html_redirect = next
|
||||||
|
#messages.success(request, _(u'Preparing document hardcopy.'))
|
||||||
|
else:
|
||||||
|
form = PrintForm()
|
||||||
|
|
||||||
|
return render_to_response('generic_form.html', {
|
||||||
|
'form': form,
|
||||||
|
'object': document,
|
||||||
|
'title': _(u'print: %s') % document,
|
||||||
|
'next': next,
|
||||||
|
'html_redirect': html_redirect if html_redirect else html_redirect,
|
||||||
|
'new_window_url': new_window_url if new_window_url else new_window_url
|
||||||
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
|
def document_hard_copy(request, document_id):
|
||||||
|
check_permissions(request.user, 'documents', [PERMISSION_DOCUMENT_VIEW])
|
||||||
|
|
||||||
|
document = get_object_or_404(Document, pk=document_id)
|
||||||
|
|
||||||
|
RecentDocument.objects.add_document_for_user(request.user, document)
|
||||||
|
|
||||||
arguments, warnings = calculate_converter_arguments(document, size=PRINT_SIZE, file_format=DEFAULT_FILE_FORMAT, quality=QUALITY_PRINT)
|
arguments, warnings = calculate_converter_arguments(document, size=PRINT_SIZE, file_format=DEFAULT_FILE_FORMAT, quality=QUALITY_PRINT)
|
||||||
#, page=page, zoom=zoom, rotation=rotation)
|
|
||||||
|
|
||||||
#Pre-generate
|
# Pre-generate
|
||||||
output_file = convert_document(document, **arguments)
|
convert_document(document, **arguments)
|
||||||
|
|
||||||
page_dimensions = dict(PAGE_SIZE_DIMENSIONS)[page_size]
|
# Extract dimension values ignoring any unit
|
||||||
width = float(page_dimensions[0].split('i')[0].split('c')[0].split('m')[0])
|
page_width = request.GET.get('page_width', dict(PAGE_SIZE_DIMENSIONS)[DEFAULT_PAPER_SIZE][0])
|
||||||
height = float(page_dimensions[1].split('i')[0].split('c')[0].split('m')[0])
|
page_height = request.GET.get('page_height', dict(PAGE_SIZE_DIMENSIONS)[DEFAULT_PAPER_SIZE][1])
|
||||||
|
|
||||||
|
width = float(page_width.split('i')[0].split('c')[0].split('m')[0])
|
||||||
|
height = float(page_height.split('i')[0].split('c')[0].split('m')[0])
|
||||||
|
|
||||||
|
page_range = request.GET.get('page_range', u'')
|
||||||
|
if page_range:
|
||||||
|
page_range = parse_range(page_range)
|
||||||
|
|
||||||
|
pages = document.documentpage_set.filter(page_number__in=page_range)
|
||||||
|
else:
|
||||||
|
pages = document.documentpage_set.all()
|
||||||
|
|
||||||
return render_to_response('document_print.html', {
|
return render_to_response('document_print.html', {
|
||||||
'object': document,
|
'object': document,
|
||||||
'page_size': page_dimensions,
|
|
||||||
'page_aspect': width / height,
|
'page_aspect': width / height,
|
||||||
'page_orientation': u'landscape' if width / height > 1 else u'portrait',
|
'page_orientation': PAGE_ORIENTATION_LANDSCAPE if width / height > 1 else PAGE_ORIENTATION_PORTRAIT,
|
||||||
'page_orientation_landscape': True if width / height > 1 else False,
|
'page_orientation_landscape': True if width / height > 1 else False,
|
||||||
'page_orientation_portrait': False if width / height > 1 else True,
|
'page_orientation_portrait': False if width / height > 1 else True,
|
||||||
|
'page_range': page_range,
|
||||||
|
'page_width': page_width,
|
||||||
|
'page_height': page_height,
|
||||||
|
'pages': pages,
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
|
|||||||
@@ -5,8 +5,22 @@
|
|||||||
{% load settings %}
|
{% load settings %}
|
||||||
{% load search_tags %}
|
{% load search_tags %}
|
||||||
{% load main_settings_tags %}
|
{% load main_settings_tags %}
|
||||||
|
{% block web_theme_head %}
|
||||||
|
{% if new_window_url %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.open('{{ new_window_url|safe }}','name','toolbar=1,scrollbars=1,location=1,status=1,menubar=1,resizable=1');
|
||||||
|
</script>
|
||||||
|
<noscript>
|
||||||
|
<META HTTP-EQUIV="refresh" CONTENT="{{ new_window_url_timeout|default:'2' }};{{ new_window_url|safe }}">
|
||||||
|
</noscript>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% block html_title %}{% project_name %}{% block title %}{% endblock %}{% endblock %}
|
{% if html_redirect %}
|
||||||
|
<META HTTP-EQUIV="refresh" CONTENT="{{ html_redirect_timeout|default:'2' }};{{ html_redirect|safe }}">
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block html_title %}{% project_name %}{{ request.new_window_url }}{% block title %}{% endblock %}{% endblock %}
|
||||||
|
|
||||||
{% get_main_setting "SIDE_BAR_SEARCH" as debug %}
|
{% get_main_setting "SIDE_BAR_SEARCH" as debug %}
|
||||||
{% block web_theme_project_name %}{% project_name %}{% if debug %} {% trans "(DEBUG Mode)" %} {% endif %}{% endblock %}
|
{% block web_theme_project_name %}{% project_name %}{% if debug %} {% trans "(DEBUG Mode)" %} {% endif %}{% endblock %}
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ def check_settings(request):
|
|||||||
{'name': 'COMMON_TEMPORARY_DIRECTORY',
|
{'name': 'COMMON_TEMPORARY_DIRECTORY',
|
||||||
'value': common_settings.TEMPORARY_DIRECTORY, 'exists': True,
|
'value': common_settings.TEMPORARY_DIRECTORY, 'exists': True,
|
||||||
'description': common_settings.setting_description},
|
'description': common_settings.setting_description},
|
||||||
|
{'name': 'COMMON_DEFAULT_PAPER_SIZE',
|
||||||
|
'value': common_settings.PAGE_SIZE_LETTER},
|
||||||
|
{'name': 'COMMON_DEFAULT_PAGE_ORIENTATION',
|
||||||
|
'value': common_settings.PAGE_ORIENTATION_PORTRAIT},
|
||||||
|
|
||||||
# Converter
|
# Converter
|
||||||
{'name': 'CONVERTER_UNPAPER_PATH',
|
{'name': 'CONVERTER_UNPAPER_PATH',
|
||||||
|
|||||||
44
settings.py
44
settings.py
@@ -162,6 +162,19 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||||||
#WEB_THEME = 'default'
|
#WEB_THEME = 'default'
|
||||||
#-------------- Main -----------------
|
#-------------- Main -----------------
|
||||||
#MAIN_SIDE_BAR_SEARCH = False
|
#MAIN_SIDE_BAR_SEARCH = False
|
||||||
|
#------------ Common --------------
|
||||||
|
# Printing
|
||||||
|
# from common.literals import PAGE_SIZE_LETTER, PAGE_ORIENTATION_PORTRAIT
|
||||||
|
#COMMON_DEFAULT_PAPER_SIZE = PAGE_SIZE_LETTER
|
||||||
|
#COMMON_DEFAULT_PAGE_ORIENTATION = PAGE_ORIENTATION_PORTRAIT
|
||||||
|
#------------ Storage --------------
|
||||||
|
#DOCUMENTS_STORAGE_BACKEND = FileBasedStorage
|
||||||
|
# GridFS settings
|
||||||
|
#STORAGE_GRIDFS_HOST = 'localhost' # or list ['host a', 'host b']
|
||||||
|
#STORAGE_GRIDFS_PORT = 27017
|
||||||
|
#STORAGE_GRIDFS_DATABASE_NAME = u'document_storage'
|
||||||
|
# Filebased
|
||||||
|
#STORAGE_FILESTORAGE_LOCATION = u'document_storage'
|
||||||
#---------- Documents ------------------
|
#---------- Documents ------------------
|
||||||
# Definition
|
# Definition
|
||||||
#DOCUMENTS_METADATA_AVAILABLE_FUNCTIONS = {}
|
#DOCUMENTS_METADATA_AVAILABLE_FUNCTIONS = {}
|
||||||
@@ -182,15 +195,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||||||
#DOCUMENTS_UUID_FUNCTION = lambda:unicode(uuid.uuid4())
|
#DOCUMENTS_UUID_FUNCTION = lambda:unicode(uuid.uuid4())
|
||||||
#DOCUMENTS_DEFAULT_TRANSFORMATIONS = []
|
#DOCUMENTS_DEFAULT_TRANSFORMATIONS = []
|
||||||
|
|
||||||
# Storage
|
|
||||||
#DOCUMENTS_STORAGE_BACKEND = FileBasedStorage
|
|
||||||
# Storage - GridFS settings
|
|
||||||
#STORAGE_GRIDFS_HOST = 'localhost' # or list ['host a', 'host b']
|
|
||||||
#STORAGE_GRIDFS_PORT = 27017
|
|
||||||
#STORAGE_GRIDFS_DATABASE_NAME = u'document_storage'
|
|
||||||
# Filebased
|
|
||||||
#STORAGE_FILESTORAGE_LOCATION = u'document_storage'
|
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
#DOCUMENTS_PREVIEW_SIZE = '640x480'
|
#DOCUMENTS_PREVIEW_SIZE = '640x480'
|
||||||
#DOCUMENTS_THUMBNAIL_SIZE = '50x50'
|
#DOCUMENTS_THUMBNAIL_SIZE = '50x50'
|
||||||
@@ -206,17 +210,12 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||||||
|
|
||||||
# Groups
|
# Groups
|
||||||
#DOCUMENTS_GROUP_SHOW_EMPTY = True
|
#DOCUMENTS_GROUP_SHOW_EMPTY = True
|
||||||
|
#------------ Filesystem serving --------------
|
||||||
# Serving
|
|
||||||
#FILESYSTEM_FILESERVING_ENABLE = True
|
#FILESYSTEM_FILESERVING_ENABLE = True
|
||||||
#FILESYSTEM_FILESERVING_PATH = u'/tmp/mayan/documents'
|
#FILESYSTEM_FILESERVING_PATH = u'/tmp/mayan/documents'
|
||||||
#FILESYSTEM_SLUGIFY_PATHS = False
|
#FILESYSTEM_SLUGIFY_PATHS = False
|
||||||
#FILESYSTEM_MAX_RENAME_COUNT = 200
|
#FILESYSTEM_MAX_RENAME_COUNT = 200
|
||||||
|
#------------ Converter --------------
|
||||||
# Misc
|
|
||||||
#COMMON_TEMPORARY_DIRECTORY = u'/tmp'
|
|
||||||
|
|
||||||
# Converter
|
|
||||||
#CONVERTER_DEFAULT_OPTIONS = u''
|
#CONVERTER_DEFAULT_OPTIONS = u''
|
||||||
#CONVERTER_LOW_QUALITY_OPTIONS = u''
|
#CONVERTER_LOW_QUALITY_OPTIONS = u''
|
||||||
#CONVERTER_HIGH_QUALITY_OPTIONS = u'-density 400'
|
#CONVERTER_HIGH_QUALITY_OPTIONS = u'-density 400'
|
||||||
@@ -227,8 +226,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||||||
#CONVERTER_GRAPHICS_BACKEND = u'converter.backends.imagemagick'
|
#CONVERTER_GRAPHICS_BACKEND = u'converter.backends.imagemagick'
|
||||||
#CONVERTER_GM_PATH = u'/usr/bin/gm'
|
#CONVERTER_GM_PATH = u'/usr/bin/gm'
|
||||||
#CONVERTER_GM_SETTINGS = u''
|
#CONVERTER_GM_SETTINGS = u''
|
||||||
|
#------------ OCR --------------
|
||||||
# OCR
|
|
||||||
#OCR_TESSERACT_PATH = u'/usr/bin/tesseract'
|
#OCR_TESSERACT_PATH = u'/usr/bin/tesseract'
|
||||||
#OCR_NODE_CONCURRENT_EXECUTION = 1
|
#OCR_NODE_CONCURRENT_EXECUTION = 1
|
||||||
#OCR_TESSERACT_LANGUAGE = u'eng'
|
#OCR_TESSERACT_LANGUAGE = u'eng'
|
||||||
@@ -236,17 +234,13 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||||||
#OCR_AUTOMATIC_OCR = False
|
#OCR_AUTOMATIC_OCR = False
|
||||||
#OCR_PDFTOTEXT_PATH = u'/usr/bin/pdftotext'
|
#OCR_PDFTOTEXT_PATH = u'/usr/bin/pdftotext'
|
||||||
#OCR_QUEUE_PROCESSING_INTERVAL = 10 # In seconds
|
#OCR_QUEUE_PROCESSING_INTERVAL = 10 # In seconds
|
||||||
|
#------------ Permissions --------------
|
||||||
# Permissions
|
|
||||||
#ROLES_DEFAULT_ROLES = []
|
#ROLES_DEFAULT_ROLES = []
|
||||||
|
#------------ Searching --------------
|
||||||
# Searching
|
|
||||||
#SEARCH_LIMIT = 100
|
#SEARCH_LIMIT = 100
|
||||||
|
#------------ django-sendfile --------------
|
||||||
# django-sendfile
|
|
||||||
# Change to xsendfile for apache if x-sendfile is enabled
|
# Change to xsendfile for apache if x-sendfile is enabled
|
||||||
SENDFILE_BACKEND = 'sendfile.backends.simple'
|
SENDFILE_BACKEND = 'sendfile.backends.simple'
|
||||||
|
|
||||||
#----------- django-celery --------------
|
#----------- django-celery --------------
|
||||||
import djcelery
|
import djcelery
|
||||||
djcelery.setup_loader()
|
djcelery.setup_loader()
|
||||||
|
|||||||
Reference in New Issue
Block a user