-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathentries.json
54 lines (44 loc) · 1.39 KB
/
entries.json
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import acdr
from acdr.sqlite2 import DISPLAY_COLUMNS
from acdr import cdr
from acdr import elapsed_time
from aspen import Response
SORT_COL = 'iSortCol_%d'
SORT_DIR = 'sSortDir_%d'
SEARCH_STR = 'sSearch_%d'
print("AJAX Request received")
start = int(request.body.one('iDisplayStart'))
length = int(request.body.one('iDisplayLength'))
# Get search string
search = request.body.one('sSearch')
# Parse sorting settings
sortnbr = 0
sorting = []
while (SORT_COL % sortnbr) in request.body:
columnnbr = int(request.body.one(SORT_COL % sortnbr))
sortdirection = request.body.one(SORT_DIR % sortnbr)
sortnbr = sortnbr + 1
sorting.append([ DISPLAY_COLUMNS[columnnbr], sortdirection ])
# Search strings, these values are provided for each column on every request,
# but not all filled with data...
columnnbr = 0
searching = []
search_anything = False
while (SEARCH_STR % columnnbr) in request.body:
str = request.body.one(SEARCH_STR % columnnbr)
if str != '':
search_anything = True
searching.append(str)
columnnbr = columnnbr + 1
if search_anything:
print('Search')
rows = cdr.search_read_page(searching, start, length, sorting)
else:
print('No Search')
rows = cdr.read_page(start, length, sorting)
response.body = {
'sEcho': int(request.body.one('sEcho')),
'iTotalRecords': cdr.total(),
'iTotalDisplayRecords': cdr.total(),
'aaData': rows
}