Issue #56, remove print preview unused code

This commit is contained in:
Roberto Rosario
2014-10-13 17:08:23 -04:00
parent e26c6c1905
commit bcc71bebd2
4 changed files with 7 additions and 58 deletions

View File

@@ -1,36 +1,5 @@
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'

View File

@@ -5,7 +5,7 @@ from django.contrib.auth.models import User
from smart_settings.api import register_setting
from common.literals import PAGE_SIZE_LETTER, PAGE_ORIENTATION_PORTRAIT
from common.literals import PAGE_ORIENTATION_PORTRAIT
TEMPORARY_DIRECTORY = register_setting(
namespace=u'common',
@@ -17,14 +17,6 @@ TEMPORARY_DIRECTORY = register_setting(
exists=True
)
DEFAULT_PAPER_SIZE = register_setting(
namespace=u'common',
module=u'common.settings',
name=u'DEFAULT_PAPER_SIZE',
global_name=u'COMMON_DEFAULT_PAPER_SIZE',
default=PAGE_SIZE_LETTER,
)
DEFAULT_PAGE_ORIENTATION = register_setting(
namespace=u'common',
module=u'common.settings',

View File

@@ -290,7 +290,10 @@ class Document(models.Model):
@property
def first_version(self):
return self.versions.order_by('timestamp').first()
if self.pk not in self.__class__._first_versions:
self.__class__._first_versions[self.pk] = self.versions.order_by('timestamp').first()
return self.__class__._first_versions[self.pk]
def rename(self, new_name):
version = self.latest_version
@@ -503,6 +506,7 @@ class DocumentVersion(models.Model):
self.__class__._page_counts[self.pk] = None
# Invalidate parent document's latest version cache
Document._latest_versions[self.document.pk] = None
Document._first_versions[self.document.pk] = None
return super(DocumentVersion, self).delete(*args, **kwargs)

View File

@@ -18,9 +18,7 @@ import sendfile
from acls.models import AccessEntry
from common.compressed_files import CompressedFile
from common.literals import (PAGE_ORIENTATION_LANDSCAPE, PAGE_ORIENTATION_PORTRAIT,
PAGE_SIZE_DIMENSIONS)
from common.settings import DEFAULT_PAPER_SIZE
from common.literals import PAGE_ORIENTATION_LANDSCAPE, PAGE_ORIENTATION_PORTRAIT
from common.utils import (encapsulate, pretty_size, parse_range, return_diff,
urlquote)
from common.views import SingleObjectListView
@@ -841,14 +839,6 @@ def document_hard_copy(request, document_id):
RecentDocument.objects.add_document_for_user(request.user, document)
# Extract dimension values ignoring any unit
page_width = request.GET.get('page_width', dict(PAGE_SIZE_DIMENSIONS)[DEFAULT_PAPER_SIZE][0])
page_height = request.GET.get('page_height', dict(PAGE_SIZE_DIMENSIONS)[DEFAULT_PAPER_SIZE][1])
# TODO: Replace with regex to extact numeric portion
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)
@@ -859,13 +849,7 @@ def document_hard_copy(request, document_id):
return render_to_response('document_print.html', {
'object': document,
'page_aspect': width / height,
'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_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))