mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
replace add missing active cards with selectable version
This commit is contained in:
parent
8147e5002a
commit
5119e46e7b
1 changed files with 7 additions and 7 deletions
12
anki/deck.py
12
anki/deck.py
|
@ -797,11 +797,11 @@ and due < :now""", now=time.time())
|
||||||
self.flushMod()
|
self.flushMod()
|
||||||
return cards
|
return cards
|
||||||
|
|
||||||
def availableCardModels(self, fact):
|
def availableCardModels(self, fact, checkActive=True):
|
||||||
"List of active card models that aren't empty for FACT."
|
"List of active card models that aren't empty for FACT."
|
||||||
models = []
|
models = []
|
||||||
for cardModel in fact.model.cardModels:
|
for cardModel in fact.model.cardModels:
|
||||||
if cardModel.active:
|
if cardModel.active or not checkActive:
|
||||||
ok = True
|
ok = True
|
||||||
for format in [cardModel.qformat, cardModel.aformat]:
|
for format in [cardModel.qformat, cardModel.aformat]:
|
||||||
empty = {}
|
empty = {}
|
||||||
|
@ -821,16 +821,16 @@ and due < :now""", now=time.time())
|
||||||
models.append(cardModel)
|
models.append(cardModel)
|
||||||
return models
|
return models
|
||||||
|
|
||||||
def addMissingCards(self, fact):
|
def addCards(self, fact, cardModelIds):
|
||||||
"Caller must flush first, flushMod after, and rebuild priorities."
|
"Caller must flush first, flushMod after, and rebuild priorities."
|
||||||
for cardModel in fact.model.cardModels:
|
for cardModel in self.availableCardModels(fact, False):
|
||||||
if cardModel.active:
|
if cardModel.id not in cardModelIds:
|
||||||
|
continue
|
||||||
if self.s.scalar("""
|
if self.s.scalar("""
|
||||||
select count(id) from cards
|
select count(id) from cards
|
||||||
where factId = :fid and cardModelId = :cmid""",
|
where factId = :fid and cardModelId = :cmid""",
|
||||||
fid=fact.id, cmid=cardModel.id) == 0:
|
fid=fact.id, cmid=cardModel.id) == 0:
|
||||||
card = anki.cards.Card(fact, cardModel)
|
card = anki.cards.Card(fact, cardModel)
|
||||||
# not added to queue
|
|
||||||
self.setModified()
|
self.setModified()
|
||||||
|
|
||||||
def factIsInvalid(self, fact):
|
def factIsInvalid(self, fact):
|
||||||
|
|
Loading…
Reference in a new issue