use chronological order in session sort (#984)
This commit is contained in:
parent
b87b9bbe93
commit
cbe5503b0f
|
@ -817,6 +817,16 @@ class SearchView(BrowserView):
|
||||||
return 99999
|
return 99999
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
ordered_sessions = tabellio.config.utils.get_ordered_sessions()
|
||||||
|
def cmp_session_name(x, y):
|
||||||
|
if x is y or x == y:
|
||||||
|
return 0
|
||||||
|
if x not in ordered_sessions:
|
||||||
|
return -1
|
||||||
|
if y not in ordered_sessions:
|
||||||
|
return +1
|
||||||
|
return cmp(ordered_sessions.index(x), ordered_sessions.index(y))
|
||||||
|
|
||||||
def cmp_dostype(x, y):
|
def cmp_dostype(x, y):
|
||||||
if not (x.dostype is None or y.dostype is None or
|
if not (x.dostype is None or y.dostype is None or
|
||||||
x.dostype is Missing.Value or y.dostype is Missing.Value):
|
x.dostype is Missing.Value or y.dostype is Missing.Value):
|
||||||
|
@ -826,7 +836,7 @@ class SearchView(BrowserView):
|
||||||
t = -cmp(x.dostype, y.dostype)
|
t = -cmp(x.dostype, y.dostype)
|
||||||
t = cmp(type_x, type_y)
|
t = cmp(type_x, type_y)
|
||||||
if t == 0:
|
if t == 0:
|
||||||
t = -cmp(x.session, y.session)
|
t = -cmp_session_name(x.session, y.session)
|
||||||
if t == 0:
|
if t == 0:
|
||||||
t = -cmp(x.no, y.no)
|
t = -cmp(x.no, y.no)
|
||||||
return t
|
return t
|
||||||
|
@ -840,7 +850,7 @@ class SearchView(BrowserView):
|
||||||
t = -cmp(x.questype, y.questype)
|
t = -cmp(x.questype, y.questype)
|
||||||
t = cmp(type_x, type_y)
|
t = cmp(type_x, type_y)
|
||||||
if t == 0:
|
if t == 0:
|
||||||
t = -cmp(x.session, y.session)
|
t = -cmp_session_name(x.session, y.session)
|
||||||
if t == 0:
|
if t == 0:
|
||||||
t = -cmp(x.dateDoc, y.dateDoc)
|
t = -cmp(x.dateDoc, y.dateDoc)
|
||||||
return t
|
return t
|
||||||
|
@ -848,15 +858,17 @@ class SearchView(BrowserView):
|
||||||
def cmp_number(x, y):
|
def cmp_number(x, y):
|
||||||
t = -cmp(get_no_as_int(x.no), get_no_as_int(y.no))
|
t = -cmp(get_no_as_int(x.no), get_no_as_int(y.no))
|
||||||
if t == 0:
|
if t == 0:
|
||||||
t = -cmp(x.session, y.session)
|
t = -cmp_session_name(x.session, y.session)
|
||||||
if t == 0:
|
if t == 0:
|
||||||
t = cmp(x.nodoc, y.nodoc)
|
t = cmp(x.nodoc, y.nodoc)
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def cmp_session(x, y):
|
def cmp_session(x, y):
|
||||||
t = -cmp(x.session, y.session)
|
t = -cmp_session_name(x.session, y.session)
|
||||||
if t == 0:
|
if t == 0:
|
||||||
t = -cmp(get_no_as_int(x.no), get_no_as_int(y.no))
|
t = -cmp(get_no_as_int(x.no), get_no_as_int(y.no))
|
||||||
|
if t == 0 and hasattr(x, 'nodoc'):
|
||||||
|
t = cmp(x.nodoc, y.nodoc)
|
||||||
return t
|
return t
|
||||||
|
|
||||||
cmp_function = None
|
cmp_function = None
|
||||||
|
@ -875,6 +887,7 @@ class SearchView(BrowserView):
|
||||||
cmp_function = cmp_session
|
cmp_function = cmp_session
|
||||||
|
|
||||||
catalog = getToolByName(self.context, 'portal_catalog')
|
catalog = getToolByName(self.context, 'portal_catalog')
|
||||||
|
print 'kw:', kw
|
||||||
return sorted(catalog(**kw), cmp_function)
|
return sorted(catalog(**kw), cmp_function)
|
||||||
|
|
||||||
def deputy_search_form(self):
|
def deputy_search_form(self):
|
||||||
|
|
Reference in New Issue