Commit 4c798787 authored by Olga Brani's avatar Olga Brani
Browse files

Merge branch 'latest-quota' of https://code.grnet.gr/git/synnefo into latest-quota

parents 500752ed f186a964
......@@ -42,6 +42,7 @@ from django_tables2 import A
import django_tables2 as tables
from astakos.im.models import *
from astakos.im.templatetags.filters import truncatename
DEFAULT_DATE_FORMAT = "d/m/Y"
......@@ -56,6 +57,18 @@ MEMBER_STATUS_DISPLAY = {
-1: _('Unregistered'),
}
class TruncatedLinkColumn(tables.LinkColumn):
def __init__(self, *args, **kwargs):
self.truncate_chars = kwargs.pop('truncate_chars', 10)
super(TruncatedLinkColumn, self).__init__(*args, **kwargs)
def render_link(self, uri, text, attrs=None):
text = truncatename(text, self.truncate_chars)
return super(TruncatedLinkColumn, self).render_link(uri, text, attrs)
# Helper columns
class RichLinkColumn(tables.TemplateColumn):
......@@ -213,7 +226,9 @@ class UserTable(tables.Table):
class UserProjectApplicationsTable(UserTable):
caption = _('My projects')
name = tables.LinkColumn('astakos.im.views.project_detail', args=(A('pk'),))
name = TruncatedLinkColumn('astakos.im.views.project_detail',
truncate_chars=25,
args=(A('pk'),))
issue_date = tables.DateColumn(format=DEFAULT_DATE_FORMAT)
start_date = tables.DateColumn(format=DEFAULT_DATE_FORMAT)
end_date = tables.DateColumn(format=DEFAULT_DATE_FORMAT)
......
......@@ -134,7 +134,7 @@ def paginate(l, args):
paginator.len
except AttributeError:
paginator._count = len(list(l))
try:
page_number = int(page)
except ValueError:
......@@ -197,22 +197,21 @@ def sizeof_fmt(num):
return '1 byte'
else:
return '0'
@register.filter
def isinf(v):
if math.isinf(v):
return 'Unlimited'
else:
return v
@register.filter
def truncatename(v):
max = 18
def truncatename(v, max=18, append="..."):
length = len(v)
if length>max:
return v[:max]+'...'
return v[:max] + append
else:
return v[:20]
return v
@register.filter
def resource_groups(project_definition):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment