Coverage for app/filters.py : 97%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from datetime import datetime
2from app import app
3from app.docutils import topics
5@app.template_filter('name_by_type')
6def item_name(item_type, plural=True):
7 #
8 # get name of the item_type
9 #
11 # categories
12 if item_type == 'main':
13 name = 'Main Item'
15 # main items
16 elif item_type == 'testrun':
17 name = 'Testrun'
18 elif item_type == 'testcase_sequence':
19 name = 'Test Case Sequence'
20 elif item_type == 'testcase':
21 name = 'Test Case'
22 elif item_type == 'teststep_sequence':
23 name = 'Test Step Sequence'
24 elif item_type == 'teststep':
25 name = 'Test Step'
26 else:
27 # wrong item_type
28 return ''
30 # check for plurals
31 if plural:
32 name += 's'
34 return name
36@app.template_filter('time')
37def format_time(time):
38 return time.strftime('%Y-%m-%d %H:%M')
40@app.template_filter('doc_title')
41def documentation_title(topic):
42 if topic in topics:
43 return topics[topic]
45 return "Index"
47@app.context_processor
48def doc_topics():
49 return dict(topics=topics)