From 0acd66bee63e24df0e03fb5d3892ae24e9549020 Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 21 Jun 2011 02:18:23 +0530 Subject: [PATCH] round is better than square --- edgware/editor/templatetags/alter_size.py | 4 ++-- edgware/editor/views.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/edgware/editor/templatetags/alter_size.py b/edgware/editor/templatetags/alter_size.py index 02824f3..b5418d3 100644 --- a/edgware/editor/templatetags/alter_size.py +++ b/edgware/editor/templatetags/alter_size.py @@ -11,7 +11,7 @@ def make_really_big(value, m): v = str(value).strip() if v[-2:] == 'px': no = int(value.replace("px", "")) * m - return str(int(no)) + "px" + return str(int(round(no))) + "px" else: return value @@ -24,7 +24,7 @@ def parse_html(value, m): matches = re.findall(p, value) for match in matches: val = int(match.replace("px", "")) - new_val = val * m + new_val = int(round(val * m)) r = str(new_val) + "px" value = value.replace(match, r) return value diff --git a/edgware/editor/views.py b/edgware/editor/views.py index 3644342..3f894b8 100644 --- a/edgware/editor/views.py +++ b/edgware/editor/views.py @@ -627,7 +627,7 @@ def product_pdf(request): width_mm = request.GET['width'] else: width_mm = product.typ.print_width - height_mm = int(width_mm // product.typ.aspect_ratio) + height_mm = int(round(width_mm // product.typ.aspect_ratio)) pages = product.get_page_list() m = product.get_print_multiplier(dpi) url_list = [] @@ -643,7 +643,7 @@ def article_pdf(request): article = get_object_or_404_json(Article, pk=a_id) dpi = request.GET.get('dpi', 300) width_mm = request.GET.get('width', article.typ.print_width) - height_mm = int(width_mm // article.typ.aspect_ratio) + height_mm = int(round(width_mm // article.typ.aspect_ratio)) pages = Page.objects.filter(article=article).order_by('page_no') m = article.get_print_multiplier(dpi) url = SITE_BASE + "/edit/view_article/%d/?m=%f" % (article.id, m)