mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
add a bgclass helper func
This commit is contained in:
parent
2c545cfb1d
commit
9d52196949
3 changed files with 17 additions and 1 deletions
|
@ -132,6 +132,10 @@ streak=?, lapses=?, grade=?, cycles=?, edue=? where id = ?""",
|
||||||
def template(self):
|
def template(self):
|
||||||
return self._reviewData()[1].templates[self.ord]
|
return self._reviewData()[1].templates[self.ord]
|
||||||
|
|
||||||
|
def bgClass(self):
|
||||||
|
return "cm%s-%s" % (hexifyID(self.model().id),
|
||||||
|
hexifyID(self.template()['ord']))
|
||||||
|
|
||||||
def startTimer(self):
|
def startTimer(self):
|
||||||
self.timerStarted = time.time()
|
self.timerStarted = time.time()
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ insert or replace into models values (?, ?, ?, ?, ?, ?, ?)""",
|
||||||
return ""
|
return ""
|
||||||
# fields
|
# fields
|
||||||
css = "".join([self._fieldCSS(
|
css = "".join([self._fieldCSS(
|
||||||
".fm%s.%s" % (hexifyID(self.id), hexifyID(f['ord'])),
|
".fm%s-%s" % (hexifyID(self.id), hexifyID(f['ord'])),
|
||||||
(f['font'], f['qsize'], f['qcol'], f['rtl'], f['pre']))
|
(f['font'], f['qsize'], f['qcol'], f['rtl'], f['pre']))
|
||||||
for f in self.fields])
|
for f in self.fields])
|
||||||
# templates
|
# templates
|
||||||
|
|
|
@ -85,3 +85,15 @@ def test_delete():
|
||||||
assert deck.factCount() == 0
|
assert deck.factCount() == 0
|
||||||
assert deck.db.scalar("select count() from facts") == 0
|
assert deck.db.scalar("select count() from facts") == 0
|
||||||
assert deck.db.scalar("select count() from cards") == 0
|
assert deck.db.scalar("select count() from cards") == 0
|
||||||
|
|
||||||
|
def test_misc():
|
||||||
|
d = getEmptyDeck()
|
||||||
|
f = d.newFact()
|
||||||
|
f['Front'] = u'1'
|
||||||
|
f['Back'] = u'2'
|
||||||
|
d.addFact(f)
|
||||||
|
c = f.cards()[0]
|
||||||
|
assert c.bgClass() == "cm1-0"
|
||||||
|
assert c.fact().id == 1
|
||||||
|
assert c.model().id == 1
|
||||||
|
assert c.template()['ord'] == 0
|
||||||
|
|
Loading…
Reference in a new issue