mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
run hook on deck/model creation
This commit is contained in:
parent
bde4655fa5
commit
225196f7d1
2 changed files with 4 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
from anki.utils import intTime, ids2str, json
|
from anki.utils import intTime, ids2str, json
|
||||||
|
from anki.hooks import runHook
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
from anki.errors import DeckRenameError
|
from anki.errors import DeckRenameError
|
||||||
|
@ -127,6 +128,7 @@ class DeckManager(object):
|
||||||
self.decks[str(id)] = g
|
self.decks[str(id)] = g
|
||||||
self.save(g)
|
self.save(g)
|
||||||
self.maybeAddToActive()
|
self.maybeAddToActive()
|
||||||
|
runHook("newDeck")
|
||||||
return int(id)
|
return int(id)
|
||||||
|
|
||||||
def rem(self, did, cardsToo=False, childrenToo=True):
|
def rem(self, did, cardsToo=False, childrenToo=True):
|
||||||
|
|
|
@ -7,6 +7,7 @@ from anki.utils import intTime, hexifyID, joinFields, splitFields, ids2str, \
|
||||||
timestampID, fieldChecksum, json
|
timestampID, fieldChecksum, json
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
|
from anki.hooks import runHook
|
||||||
|
|
||||||
# Models
|
# Models
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
@ -86,6 +87,7 @@ class ModelManager(object):
|
||||||
if templates:
|
if templates:
|
||||||
self._syncTemplates(m)
|
self._syncTemplates(m)
|
||||||
self.changed = True
|
self.changed = True
|
||||||
|
runHook("newModel")
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
"Flush the registry if any models were changed."
|
"Flush the registry if any models were changed."
|
||||||
|
|
Loading…
Reference in a new issue