fix group tree when no cards use a group

This commit is contained in:
Damien Elmes 2011-04-06 17:39:04 +09:00
parent 95b3f60353
commit 673913a2a8
3 changed files with 4 additions and 3 deletions

View file

@ -13,7 +13,8 @@ from anki.media import MediaRegistry
from anki.consts import *
import anki.latex # sets up hook
import anki.cards, anki.facts, anki.models, anki.template, anki.cram
import anki.cards, anki.facts, anki.models, anki.template, anki.cram, \
anki.groups
# Settings related to queue building. These may be loaded without the rest of
# the config to check due counts faster on mobile clients.

View file

@ -124,7 +124,7 @@ sum(case when queue = 2 and due <= ? then 1 else 0 end),
sum(case when queue = 0 then 1 else 0 end)
from cards group by gid""", self.today):
gids[gid] = [all, rev, new]
return [[name, gid]+gids[gid] for (gid, name) in
return [[name, gid]+gids.get(gid, [0, 0, 0]) for (gid, name) in
self.deck.db.execute(
"select id, name from groups order by name")]

View file

@ -202,7 +202,7 @@ def joinTags(tags):
return u" %s " % u" ".join(tags)
def canonifyTags(tags):
"Strip leading/trailing/superfluous commas and duplicates."
"Strip leading/trailing/superfluous spaces and duplicates."
tags = [t.lstrip(":") for t in set(tags)]
return joinTags(sorted(tags))