mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
add the ability to reverse sort order
This commit is contained in:
parent
6617214708
commit
d089deae5a
3 changed files with 10 additions and 3 deletions
|
@ -31,7 +31,7 @@ defaultQconf = {
|
|||
'timeLim': 600,
|
||||
}
|
||||
|
||||
# scheduling and other options
|
||||
# other options
|
||||
defaultConf = {
|
||||
'currentModelId': None,
|
||||
'currentGroupId': 1,
|
||||
|
@ -52,7 +52,8 @@ defaultConf = {
|
|||
'latexPost': "\\end{document}",
|
||||
'fontFamilies': [
|
||||
[u'MS 明朝',u'ヒラギノ明朝 Pro W3',u'Kochi Mincho', u'東風明朝']
|
||||
]
|
||||
],
|
||||
'sortBackwards': False,
|
||||
}
|
||||
|
||||
# this is initialized by storage.Deck
|
||||
|
|
|
@ -30,7 +30,10 @@ class Finder(object):
|
|||
return []
|
||||
(q, args) = self._whereClause()
|
||||
query = self._orderedSelect(sort, q)
|
||||
return self.deck.db.list(query, **args)
|
||||
res = self.deck.db.list(query, **args)
|
||||
if self.deck.conf['sortBackwards']:
|
||||
res.reverse()
|
||||
return res
|
||||
|
||||
def _whereClause(self):
|
||||
x = []
|
||||
|
|
|
@ -84,6 +84,9 @@ def test_findCards():
|
|||
assert deck.findCards("", sort="factFld")[0] == catCard.id
|
||||
assert deck.findCards("", sort="factFld")[-1] == c.id
|
||||
assert deck.findCards("", sort="cardMod")[-1] == c.id
|
||||
assert not deck.findCards("", sort="cardMod")[0] == c.id
|
||||
deck.conf['sortBackwards'] = True
|
||||
assert deck.findCards("", sort="cardMod")[0] == c.id
|
||||
# model
|
||||
assert len(deck.findCards("model:basic")) == 5
|
||||
assert len(deck.findCards("-model:basic")) == 0
|
||||
|
|
Loading…
Reference in a new issue