summaryrefslogtreecommitdiff
path: root/coip/extensions/templatetags/userdisplay.py
blob: a4756235df37e1efcf9ccf6182a9296a08bd05cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from django import template
 
register = template.Library()
 
MOMENT = 120    # duration in seconds within which the time difference 
                # will be rendered as 'a moment ago'
 
def userdisplay(user):
    if user == None:
        return "anonymous"
    profile = user.get_profile()
    if profile and profile.display_name:
        return profile.display_name
    cn = user.get_full_name()
    if cn:
        return cn
    else:
        return user.username

userdisplay.is_safe = True
register.filter(userdisplay)

def memberdisplay(membership):
    return userdisplay(membership.user)
    
memberdisplay.is_safe = True
register.filter(memberdisplay)