-<%def name="navlinks(view, curr, last)">
+<%def name="navlinks(view, curr, last, query=None)">
% if curr != last:
% if curr != 1:
- <a class="pagination" href="${request.route_url(view, page=curr-1)}" name="Previous Page">previous</a>
+ % if query is not None:
+ <a class="pagination" href="${request.route_url(view, page=curr-1, _query=query)}" name="Previous Page">previous</a>
+ % else:
+ <a class="pagination" href="${request.route_url(view, page=curr-1)}" name="Previous Page">previous</a>
+ % endif
% endif
% if last < 8:
% for i in range(1, last+1):
- ${link_page(view, i, curr)}
+ ${link_page(view, i, curr, query)}
% endfor
% else:
% if curr < 5:
% for i in range(1,7):
- ${link_page(view, i, curr)}
+ ${link_page(view, i, curr, query)}
% endfor
<span class="pagination">...</span>
- <a class="pagination" href="${request.route_url(view, page=last)}" name="Last Page">${last}</a>
+ % if query is not None:
+ <a class="pagination" href="${request.route_url(view, page=last, _query=query)}" name="Last Page">${last}</a>
+ % else:
+ <a class="pagination" href="${request.route_url(view, page=last)}" name="Last Page">${last}</a>
+ % endif
+
% elif last-curr < 6:
- <a class="pagination" href="${request.route_url(view, page=1)}" name="First Page">1</a>
+ % if query is not None:
+ <a class="pagination" href="${request.route_url(view, page=1, _query=query)}" name="First Page">1</a>
+ % else:
+ <a class="pagination" href="${request.route_url(view, page=1)}" name="First Page">1</a>
+ % endif
<span class="pagination">...</span>
% for i in range(last-5, last+1):
- ${link_page(view, i, curr)}
+ ${link_page(view, i, curr, query)}
% endfor
% else:
- <a class="pagination" href="${request.route_url(view, page=1)}" name="First Page">1</a>
+ % if query is not None:
+ <a class="pagination" href="${request.route_url(view, page=1, _query=query)}" name="First Page">1</a>
+ % else:
+ <a class="pagination" href="${request.route_url(view, page=1)}" name="First Page">1</a>
+ % endif
+
<span class="pagination">...</span>
% for i in range(curr-2, curr+3):
- ${link_page(view, i, curr)}
+ ${link_page(view, i, curr, query)}
% endfor
<span class="pagination">...</span>
- <a class="pagination" href="${request.route_url(view, page=last)}" name="Last Page">${last}</a>
+ % if query is not None:
+ <a class="pagination" href="${request.route_url(view, page=last, _query=query)}" name="Last Page">${last}</a>
+ % else:
+ <a class="pagination" href="${request.route_url(view, page=last)}" name="Last Page">${last}</a>
+ % endif
+
% endif
% endif
% if curr != last:
- <a class="pagination" href="${request.route_url(view, page=curr+1)}" name="Next Page">next</a>
+ % if query is not None:
+ <a class="pagination" href="${request.route_url(view, page=curr+1, _query=query)}" name="Next Page">next</a>
+ % else:
+ <a class="pagination" href="${request.route_url(view, page=curr+1)}" name="Next Page">next</a>
+ % endif
% endif
% endif
</%def>
-<%def name="link_page(view, page_num, curr_page)">
+<%def name="link_page(view, page_num, curr_page, query)">
% if page_num == curr_page:
<span class="pagination" style="color:#d95b00;">${page_num}</span>
% else:
-<a class="pagination" href="${request.route_url(view, page=page_num)}" name="Go to page ${page_num}">${page_num}</a>
+ % if query is not None:
+ <a class="pagination" href="${request.route_url(view, page=page_num, _query=query)}" name="Go to page ${page_num}">${page_num}</a>
+ % else:
+ <a class="pagination" href="${request.route_url(view, page=page_num)}" name="Go to page ${page_num}">${page_num}</a>
+ % endif
% endif
</%def>
q = session.query(Player)
if nick:
q = q.filter(
- func.upper(Player.stripped_nick).like('%'+nick.upper()+'%'))
+ func.upper(Player.stripped_nick).like('%'+nick.upper()+'%')).\
+ filter(Player.player_id > 2).\
+ order_by(Player.player_id)
# server-only searches
elif server_name and not nick and not map_name and not create_dt:
q = session.query(Server)
if server_name:
q = q.filter(func.upper(Server.name).\
- like('%'+server_name.upper()+'%'))
+ like('%'+server_name.upper()+'%')).\
+ order_by(Server.server_id)
# map-only searches
elif map_name and not nick and not server_name and not create_dt:
q = session.query(Map)
if map_name:
q = q.filter(func.upper(Map.name).\
- like('%'+map_name.upper()+'%'))
+ like('%'+map_name.upper()+'%')).\
+ order_by(Map.map_id)
# game searches (all else)
else:
map_name = None
result_type = None
results = None
+ query = None
- current_page = 1
+ if 'page' in request.matchdict:
+ current_page = request.matchdict['page']
+ else:
+ current_page = 1
if request.params.has_key('fs'):
+ query = {'fs':''}
if request.params.has_key('nick'):
- nick = request.params['nick']
+ if request.params['nick'] != '':
+ nick = request.params['nick']
+ query['nick'] = nick
if request.params.has_key('server_name'):
- server_name = request.params['server_name']
+ if request.params['server_name'] != '':
+ server_name = request.params['server_name']
+ query['server_name'] = server_name
if request.params.has_key('map_name'):
- map_name = request.params['map_name']
+ if request.params['map_name'] != '':
+ map_name = request.params['map_name']
+ query['map_name'] = map_name
(result_type, q) = search_q(nick=nick, server_name=server_name,
map_name=map_name)
log.debug(q)
try:
if q != None:
results = Page(q, current_page, url=page_url)
- log.debug(len(results))
except Exception as e:
raise e
result_type = None
return {'result_type':result_type,
'results':results,
+ 'query':query,
}