Permalink
Browse files

+ Improved file size functionality in project, now core template tag …

…to show mb size

Tane Piper <digitalspaghetti@gmail.com>
  • Loading branch information...
Tane Piper
Tane Piper committed Apr 10, 2008
1 parent 9c9e7e2 commit a2cc6e1ebdf667e41738ab633049a5eb89190a47
@@ -34,4 +34,9 @@ def filetype(value):
if value.endswith('png'): file_type = "png"
if value.endswith('css'): file_type = "css"
return file_type
-register.filter('filetype', filetype)
+register.filter('filetype', filetype)
+
+@register.filter
+def megs(value):
+ size = (value/(1024*1024.0))
+ return size
@@ -154,10 +154,9 @@ def number_of_repos(self):
number_of_repos = property(number_of_repos)
def total_size(self):
- repos = self.repo_set.filter(local_parent_project__exact=self)
filesize = 0
- for repo in repos:
- filesize += repo.folder_size
+ for r in self.repo_set.all():
+ filesize += r.folder_size
return filesize
total_size = property(total_size)
No changes.
@@ -1,8 +0,0 @@
-from django import template
-
-register = template.Library()
-
-@register.filter
-def megs(value):
- size = (value/(1024*1024.0))
- return size
@@ -13,14 +13,16 @@
{% endblock tabs %}
{% block main_content %}
-
+ {% load core_templatetags %}
<div id="project-details">
- <h3>Project: {{project.project_name}} | {{project.project_size}}</h3>
+ <h3>Project: {{project.project_name}}</h3>
<dl id="project-details">
<dt><strong>Local</strong> Project Manager</dt>
<dd><a href="{{project.project_manager.get_absolute_url}}">{{project.project_manager}}</a></dd>
<dt>Project Description</dt>
- <dd>{{project.full_description}}</dd>
+ <dd>{{project.full_description}}</dd>
+ <dt>Project Size</dt>
+ <dd>{{project.total_size|megs|floatformat:2}} Mb</dd>
<dt>Project Active Since</dt>
<dd>{{project.created_date|date:"D d M Y H:i"}}</dd>
<dt>Project Last Updated</dt>
@@ -12,7 +12,7 @@
{% block main_content %}
- {% load repo_tags %}
+ {% load core_templatetags %}
<div id="repo-changeset">
<h3>Changeset</h3>

0 comments on commit a2cc6e1

Please sign in to comment.