group deletion should be recursive; fix css in import

This commit is contained in:
Damien Elmes 2011-10-22 10:04:32 +09:00
parent b31bd5c091
commit ae839dd3a3
2 changed files with 13 additions and 2 deletions

View file

@ -137,6 +137,9 @@ class GroupManager(object):
assert gid != 1
if not str(gid) in self.groups:
return
# delete children first
for name, id in self.children(gid):
self.rem(id, cardsToo)
# delete cards too?
if cardsToo:
self.deck.remCards(self.cids(gid))
@ -264,12 +267,18 @@ usn=?,mod=? where id in %s""" % ids2str(cids),
# current group
self.deck.conf['curGroup'] = gid
# and active groups (current + all children)
actv = self.children(gid)
actv.sort()
self.deck.conf['activeGroups'] = [gid] + [a[1] for a in actv]
def children(self, gid):
"All children of gid, as (name, id)."
name = self.get(gid)['name']
actv = []
for g in self.all():
if g['name'].startswith(name + "::"):
actv.append((g['name'], g['id']))
actv.sort()
self.deck.conf['activeGroups'] = [gid] + [a[1] for a in actv]
return actv
def parents(self, gid):
"All parents of gid."

View file

@ -111,6 +111,8 @@ class Anki2Importer(Importer):
return dmid
# need to add to local and update index
m = self.dst.models._add(self.src.models.get(mid))
# need to save so the css is updated
self.dst.models.save(m)
h = self.dst.models.scmhash(m)
mid = int(m['id'])
self._dstModels[mid] = h