summaryrefslogtreecommitdiff
path: root/devel
diff options
context:
space:
mode:
authorEvangelos Foutras <foutrelis@gmail.com>2011-04-30 15:15:38 +0300
committerDan McGee <dan@archlinux.org>2011-05-02 10:50:10 -0500
commit8de1bd0639a8b6117bc35dfe0ad1e6a1ac34f715 (patch)
treec882ed5fc323a394b396ad69a3df8f5c680452e1 /devel
parenta5991a31b92e04059589bf897a593535984384e6 (diff)
Add filesizeformat filter to sizes in reports/big
We also add a new 'filesize' tablesorter parser that handles all the suffixes found in django's filesizeformat filter. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel')
-rw-r--r--devel/views.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/devel/views.py b/devel/views.py
index 6907de24..9c523f0a 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -10,6 +10,7 @@ from django.db.models import Q
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.template import loader, Context
+from django.template.defaultfilters import filesizeformat
from django.views.decorators.cache import never_cache
from django.views.generic.simple import direct_to_template
@@ -140,7 +141,13 @@ def report(request, report):
cutoff = 50 * 1024 * 1024
packages = packages.filter(compressed_size__gte=cutoff).order_by('-compressed_size')
names = [ 'Compressed Size', 'Installed Size' ]
- attrs = [ 'compressed_size', 'installed_size' ]
+ attrs = [ 'compressed_size_pretty', 'installed_size_pretty' ]
+ # Format the compressed and installed sizes with MB/GB/etc suffixes
+ for package in packages:
+ package.compressed_size_pretty = filesizeformat(
+ package.compressed_size)
+ package.installed_size_pretty = filesizeformat(
+ package.installed_size)
elif report == 'uncompressed-man':
title = 'Packages with uncompressed manpages'
# magic going on here! Checking for all '.1'...'.9' extensions