del -> rem for consistency

This commit is contained in:
Damien Elmes 2011-11-17 22:55:03 +09:00
parent 16ecfe4097
commit a51307701d
2 changed files with 5 additions and 4 deletions

View file

@ -271,7 +271,7 @@ select id from cards where fid in (select id from facts where mid = ?)""",
return fields
self._transformFields(m, add)
def delField(self, m, field):
def remField(self, m, field):
idx = m['flds'].index(field)
m['flds'].remove(field)
self._updateFieldOrds(m)
@ -338,12 +338,13 @@ select id from cards where fid in (select id from facts where mid = ?)""",
return t
def addTemplate(self, m, template):
"Note: should deck.genCards() afterwards."
self.deck.modSchema()
m['tmpls'].append(template)
self._updateTemplOrds(m)
self.save(m)
def delTemplate(self, m, template):
def remTemplate(self, m, template):
self.deck.modSchema()
ord = m['tmpls'].index(template)
cids = self.deck.db.list("""

View file

@ -47,7 +47,7 @@ def test_fields():
d.models.renameField(m, f, "bar")
assert d.getFact(d.models.fids(m)[0])['bar'] == ''
# delete back
d.models.delField(m, m['flds'][1])
d.models.remField(m, m['flds'][1])
assert d.getFact(d.models.fids(m)[0]).fields == ["1", ""]
# move 0 -> 1
d.models.moveField(m, m['flds'][0], 1)
@ -96,7 +96,7 @@ def test_templates():
assert c.ord == 1
assert c2.ord == 0
# removing a template should delete its cards
d.models.delTemplate(m, m['tmpls'][0])
d.models.remTemplate(m, m['tmpls'][0])
assert d.cardCount() == 1
# and should have updated the other cards' ordinals
c = f.cards()[0]