Added document printing support
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
from django.conf import settings
|
||||
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')
|
||||
|
||||
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()')
|
||||
}
|
||||
|
||||
# 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)
|
||||
|
||||
@@ -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))
|
||||
else:
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user