Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
+ Improved file size functionality in project, now core template tag …
Browse files Browse the repository at this point in the history
…to show mb size

Tane Piper <digitalspaghetti@gmail.com>
  • Loading branch information
Tane Piper committed Apr 10, 2008
1 parent 9c9e7e2 commit a2cc6e1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
7 changes: 6 additions & 1 deletion hgfront/core/templatetags/core_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 2 additions & 3 deletions hgfront/project/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Empty file.
8 changes: 0 additions & 8 deletions hgfront/repo/templatetags/repo_tags.py

This file was deleted.

8 changes: 5 additions & 3 deletions hgfront/templates/project/project_detail_ajax.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion hgfront/templates/repos/repo_detail_ajax.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


{% block main_content %}
{% load repo_tags %}
{% load core_templatetags %}

<div id="repo-changeset">
<h3>Changeset</h3>
Expand Down

0 comments on commit a2cc6e1

Please sign in to comment.