From 360d0a628a8264fb100b9c52c0e4adf0b6421ad3 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Fri, 29 Jul 2011 19:34:34 +0200 Subject: Display number of files and total size on myfiles and images pages. --- db.py | 3 +++ fbin.py | 2 ++ templates/images.tmpl | 2 +- templates/my.tmpl | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/db.py b/db.py index 8652540..3436ef3 100644 --- a/db.py +++ b/db.py @@ -51,6 +51,9 @@ class File(Base): def get_path(self): return os.path.join(settings.file_directory, self.hash + os.path.splitext(self.filename)[1]) + def get_size(self): + return os.path.getsize(self.get_path()) + def html(self): return u'{filename} ' \ '1 2 ({size}) on {date}'.format( diff --git a/fbin.py b/fbin.py index 15ba13e..14ba18d 100755 --- a/fbin.py +++ b/fbin.py @@ -356,6 +356,7 @@ class Application(object): 'root': settings.virtual_root, 'user': user, 'files': files, + 'total_size': db.File.pretty_size(sum([f.get_size() for f in files])), })) def images(self, environ, start_response, path): @@ -370,6 +371,7 @@ class Application(object): 'root': settings.virtual_root, 'user': user, 'files': files, + 'total_size': db.File.pretty_size(sum([f.get_size() for f in files])), })) def thumb(self, environ, start_response, path): diff --git a/templates/images.tmpl b/templates/images.tmpl index 34c8e78..4cd3752 100644 --- a/templates/images.tmpl +++ b/templates/images.tmpl @@ -2,7 +2,7 @@ #def header: images #extends templates.base #def content -

Your uploaded images:

+

You have $len($files) uploaded images totaling $total_size.