diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-07-29 19:34:34 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-07-29 19:34:34 +0200 |
commit | 360d0a628a8264fb100b9c52c0e4adf0b6421ad3 (patch) | |
tree | 5e4c84a01da944baab0f4d1922997f625e2faa49 | |
parent | da578506d9317539b35ae5b3e49e79e6ad1c7e83 (diff) |
Display number of files and total size on myfiles and images pages.
-rw-r--r-- | db.py | 3 | ||||
-rwxr-xr-x | fbin.py | 2 | ||||
-rw-r--r-- | templates/images.tmpl | 2 | ||||
-rw-r--r-- | templates/my.tmpl | 2 |
4 files changed, 7 insertions, 2 deletions
@@ -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'<a href="{root}f/{hash}/{filename}">{filename}</a> ' \ '<sup><a href="{root}f/{hash}">1</a> <a href="{root}f/{hash}{ext}">2</a></sup> ({size}) on {date}'.format( @@ -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 -<p>Your uploaded images:</p> +<p>You have $len($files) uploaded images totaling $total_size.</p> <ul class="image-list"> #for file in $files <li>$file.image_html</li> diff --git a/templates/my.tmpl b/templates/my.tmpl index b1fb2cc..7e6e242 100644 --- a/templates/my.tmpl +++ b/templates/my.tmpl @@ -2,7 +2,7 @@ #def header: myfiles #extends templates.base #def content -<p>Your uploads:</p> +<p>You have $len($files) uploaded files totaling $total_size.</p> <ul> #for file in $files <li>$file.html</li> |