fix cloze->basic model changing

This commit is contained in:
Damien Elmes 2012-07-05 05:39:25 +09:00
parent 7aa9691334
commit 57a9668350
2 changed files with 6 additions and 1 deletions

View file

@ -422,7 +422,7 @@ select id from notes where mid = ?)""" % " ".join(map),
if newModel['type'] != MODEL_CLOZE:
# if we're mapping to a regular note, we need to check if
# the destination ord is valid
if len(newModel['flds']) <= ord:
if len(newModel['tmpls']) <= ord:
new = None
else:
# mapping from a regular note, so the map should be valid

View file

@ -231,6 +231,11 @@ def test_modelChange():
f.load()
assert f['Text'] == "f2"
assert len(f.cards()) == 2
# back the other way, with deletion of second ord
deck.models.remTemplate(basic, basic['tmpls'][1])
assert deck.db.scalar("select count() from cards where nid = ?", f.id) == 2
deck.models.change(cloze, [f.id], basic, map, map)
assert deck.db.scalar("select count() from cards where nid = ?", f.id) == 1
def test_availOrds():
d = getEmptyDeck()