mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 09:16:38 -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,
|
'timeLim': 600,
|
||||||
}
|
}
|
||||||
|
|
||||||
# scheduling and other options
|
# other options
|
||||||
defaultConf = {
|
defaultConf = {
|
||||||
'currentModelId': None,
|
'currentModelId': None,
|
||||||
'currentGroupId': 1,
|
'currentGroupId': 1,
|
||||||
|
@ -52,7 +52,8 @@ defaultConf = {
|
||||||
'latexPost': "\\end{document}",
|
'latexPost': "\\end{document}",
|
||||||
'fontFamilies': [
|
'fontFamilies': [
|
||||||
[u'MS 明朝',u'ヒラギノ明朝 Pro W3',u'Kochi Mincho', u'東風明朝']
|
[u'MS 明朝',u'ヒラギノ明朝 Pro W3',u'Kochi Mincho', u'東風明朝']
|
||||||
]
|
],
|
||||||
|
'sortBackwards': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# this is initialized by storage.Deck
|
# this is initialized by storage.Deck
|
||||||
|
|
|
@ -30,7 +30,10 @@ class Finder(object):
|
||||||
return []
|
return []
|
||||||
(q, args) = self._whereClause()
|
(q, args) = self._whereClause()
|
||||||
query = self._orderedSelect(sort, q)
|
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):
|
def _whereClause(self):
|
||||||
x = []
|
x = []
|
||||||
|
|
|
@ -84,6 +84,9 @@ def test_findCards():
|
||||||
assert deck.findCards("", sort="factFld")[0] == catCard.id
|
assert deck.findCards("", sort="factFld")[0] == catCard.id
|
||||||
assert deck.findCards("", sort="factFld")[-1] == c.id
|
assert deck.findCards("", sort="factFld")[-1] == c.id
|
||||||
assert deck.findCards("", sort="cardMod")[-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
|
# model
|
||||||
assert len(deck.findCards("model:basic")) == 5
|
assert len(deck.findCards("model:basic")) == 5
|
||||||
assert len(deck.findCards("-model:basic")) == 0
|
assert len(deck.findCards("-model:basic")) == 0
|
||||||
|
|
Loading…
Reference in a new issue