From 268d2645fd9079996f90bf4c8edf90f640013263 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 13 Nov 2010 16:33:39 +0900 Subject: [PATCH] delete cards that have the wrong card model --- anki/deck.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/anki/deck.py b/anki/deck.py index 8ceffb094..f2e48c341 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -3124,6 +3124,19 @@ select id from cards where cardModelId not in problems.append(ngettext("Deleted %d card with no card template", "Deleted %d cards with no card template", len(ids)) % len(ids)) + # cards with a card model from the wrong model + ids = self.s.column0(""" +select id from cards where cardModelId not in (select cm.id from +cardModels cm, facts f where cm.modelId = f.modelId and +f.id = cards.factId)""") + if ids: + deletedCards.extend(self.s.all( + "select question, answer from cards where id in %s" % + ids2str(ids))) + self.deleteCards(ids) + problems.append(ngettext("Deleted %d card with wrong card template", + "Deleted %d cards with wrong card template", len(ids)) % + len(ids)) # facts missing a card? ids = self.deleteDanglingFacts() if ids: