mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix #2273 (Little bug in Calibra Server)
This commit is contained in:
parent
d8ed8c0c07
commit
ead9de4002
@ -163,7 +163,7 @@ class MetadataHeader(BookHeader):
|
|||||||
|
|
||||||
if self.num_sections >= 2:
|
if self.num_sections >= 2:
|
||||||
header = self.header()
|
header = self.header()
|
||||||
BookHeader.__init__(self, header, self.ident, None)
|
BookHeader.__init__(self, header, self.ident)
|
||||||
else:
|
else:
|
||||||
self.exth = None
|
self.exth = None
|
||||||
|
|
||||||
|
@ -243,10 +243,23 @@ class LibraryServer(object):
|
|||||||
raise cherrypy.HTTPError(400, '%s is not a valid sort field'%field)
|
raise cherrypy.HTTPError(400, '%s is not a valid sort field'%field)
|
||||||
cmpf = cmp if field in ('rating', 'size', 'timestamp') else \
|
cmpf = cmp if field in ('rating', 'size', 'timestamp') else \
|
||||||
lambda x, y: cmp(x.lower() if x else '', y.lower() if y else '')
|
lambda x, y: cmp(x.lower() if x else '', y.lower() if y else '')
|
||||||
|
if field == 'series':
|
||||||
|
items.sort(cmp=self.seriescmp, reverse=not order)
|
||||||
|
else:
|
||||||
field = FIELD_MAP[field]
|
field = FIELD_MAP[field]
|
||||||
getter = operator.itemgetter(field)
|
getter = operator.itemgetter(field)
|
||||||
items.sort(cmp=lambda x, y: cmpf(getter(x), getter(y)), reverse=not order)
|
items.sort(cmp=lambda x, y: cmpf(getter(x), getter(y)), reverse=not order)
|
||||||
|
|
||||||
|
def seriescmp(self, x, y):
|
||||||
|
si = FIELD_MAP['series']
|
||||||
|
try:
|
||||||
|
ans = cmp(x[si].lower(), y[si].lower())
|
||||||
|
except AttributeError: # Some entries may be None
|
||||||
|
ans = cmp(x[si], y[si])
|
||||||
|
if ans != 0: return ans
|
||||||
|
return cmp(x[FIELD_MAP['series_index']], y[FIELD_MAP['series_index']])
|
||||||
|
|
||||||
|
|
||||||
def last_modified(self, updated):
|
def last_modified(self, updated):
|
||||||
lm = updated.strftime('day, %d month %Y %H:%M:%S GMT')
|
lm = updated.strftime('day, %d month %Y %H:%M:%S GMT')
|
||||||
day ={0:'Sun', 1:'Mon', 2:'Tue', 3:'Wed', 4:'Thu', 5:'Fri', 6:'Sat'}
|
day ={0:'Sun', 1:'Mon', 2:'Tue', 3:'Wed', 4:'Thu', 5:'Fri', 6:'Sat'}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user