"Bugfix: Pagination"

This commit is contained in:
Doug Le Tough 2017-10-23 21:29:39 +02:00
parent 5fbfd38218
commit 6cf5daf2a1

View File

@ -67,6 +67,7 @@ def resume_session(func):
order_refresh = 0
c_empty = ''
c_provider = 1
offset_reset = ['c_reference', 'c_designation', 'c_place', 'c_provider']
if not 'c_limit' in session:
session['c_limit'] = limit
if not 'c_offest' in session:
@ -91,14 +92,19 @@ def resume_session(func):
session['c_provider'] = c_provider
# Cookies/session sync
for key in request.cookies:
old = str(session[key])
try:
session[key] = int(str(request.cookies[key]))
except ValueError:
# Value is not an int, will be treated as string
session[key] = str(request.cookies[key])
if key in offset_reset and len(str(session[key])) > 0 and old != str(session[key]):
session['c_offset'] = 0
if key != 'session':
print '+', key, request.cookies[key]
# Switch sort order
if session['c_order_refresh'] == 1:
refresh = {'desc': 'asc', 'asc': 'desc'}
@ -195,13 +201,13 @@ def out_componants():
@resume_session
def update_componants():
# search by reference
like = '%'+str(session['c_reference'])+'%'
like = '%s%s%s' % ('%', str(session['c_reference']), '%')
componants = Stock_componants.query.filter(Stock_componants.reference.like(like))
# search by designation
like = '%'+str(session['c_designation'])+'%'
like = '%s%s%s' % ('%', str(session['c_designation']), '%')
componants = componants.filter(Stock_componants.designation.like(like))
# search by place
like = '%'+str(session['c_place'])+'%'
like = '%s%s%s' % ('%', str(session['c_place']),'%')
componants = componants.filter(Stock_componants.place.like(like))
# search by provider
if session['c_provider'] > 0: