summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-07-29 19:34:34 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-07-29 19:34:34 +0200
commit360d0a628a8264fb100b9c52c0e4adf0b6421ad3 (patch)
tree5e4c84a01da944baab0f4d1922997f625e2faa49
parentda578506d9317539b35ae5b3e49e79e6ad1c7e83 (diff)
Display number of files and total size on myfiles and images pages.
-rw-r--r--db.py3
-rwxr-xr-xfbin.py2
-rw-r--r--templates/images.tmpl2
-rw-r--r--templates/my.tmpl2
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'<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(
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
-<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>