Skip to content

Commit 5c5fc3f

Browse files
committed
add ams_filters
- Legacy-Id: 5179
1 parent f496498 commit 5c5fc3f

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from django import template
2+
from ietf.person.models import Person
3+
import datetime
4+
5+
register = template.Library()
6+
7+
@register.filter
8+
def abbr_status(value):
9+
"""
10+
Converts RFC Status to a short abbreviation
11+
"""
12+
d = {'Proposed Standard':'PS',
13+
'Draft Standard':'DS',
14+
'Standard':'S',
15+
'Historic':'H',
16+
'Informational':'I',
17+
'Experimental':'E',
18+
'Best Current Practice':'BCP',
19+
'Internet Standard':'IS'}
20+
21+
return d.get(value,value)
22+
23+
@register.filter(name='display_duration')
24+
def display_duration(value):
25+
"""
26+
Maps a session requested duration from select index to
27+
label."""
28+
map = {'0':'None',
29+
'1800':'30 Minutes',
30+
'3600':'1 Hour',
31+
'5400':'1.5 Hours',
32+
'7200':'2 Hours',
33+
'9000':'2.5 Hours'}
34+
return map[value]
35+
36+
@register.filter
37+
def get_published_date(doc):
38+
'''
39+
Returns the published date for a RFC Document
40+
'''
41+
event = doc.latest_event(type='published_rfc')
42+
if event:
43+
return event.time
44+
event = doc.latest_event(type='new_revision')
45+
if event:
46+
return event.time
47+
else:
48+
return None
49+
50+
@register.filter
51+
def is_ppt(value):
52+
'''
53+
Checks if the value ends in ppt or pptx
54+
'''
55+
if value.endswith('ppt') or value.endswith('pptx'):
56+
return True
57+
else:
58+
return False
59+
60+
@register.filter
61+
def smart_login(user):
62+
'''
63+
Expects a Person object. If person is a Secretariat returns "on behalf of the"
64+
'''
65+
if not isinstance (user, Person):
66+
return value
67+
if user.role_set.filter(name='secr',group__acronym='secretariat'):
68+
return '%s, on behalf of the' % user
69+
else:
70+
return '%s, a chair of the' % user

0 commit comments

Comments
 (0)