Allow for passing in custom note type and template
This commit is contained in:
parent
270cef63f4
commit
87febe489e
@ -11,7 +11,7 @@ import anki # pylint: disable=unused-import
|
|||||||
import anki._backend.backend_pb2 as _pb
|
import anki._backend.backend_pb2 as _pb
|
||||||
from anki import hooks
|
from anki import hooks
|
||||||
from anki.consts import MODEL_STD
|
from anki.consts import MODEL_STD
|
||||||
from anki.models import NoteType
|
from anki.models import NoteType, Template
|
||||||
from anki.utils import joinFields
|
from anki.utils import joinFields
|
||||||
|
|
||||||
|
|
||||||
@ -82,18 +82,18 @@ class Note:
|
|||||||
ord: int = 0,
|
ord: int = 0,
|
||||||
*,
|
*,
|
||||||
custom_note_type: NoteType = None,
|
custom_note_type: NoteType = None,
|
||||||
|
custom_template: Template = None,
|
||||||
fill_empty: bool = False,
|
fill_empty: bool = False,
|
||||||
) -> anki.cards.Card:
|
) -> anki.cards.Card:
|
||||||
card = anki.cards.Card(self.col)
|
card = anki.cards.Card(self.col)
|
||||||
card.ord = ord
|
card.ord = ord
|
||||||
card.did = 1
|
card.did = 1
|
||||||
|
|
||||||
model = self.model()
|
model = custom_note_type or self.model()
|
||||||
template = copy.copy(
|
template = copy.copy(
|
||||||
custom_note_type or (
|
custom_template
|
||||||
model["tmpls"][ord]
|
or (
|
||||||
if model["type"] == MODEL_STD
|
model["tmpls"][ord] if model["type"] == MODEL_STD else model["tmpls"][0]
|
||||||
else model["tmpls"][0]
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# may differ in cloze case
|
# may differ in cloze case
|
||||||
|
@ -476,7 +476,8 @@ class CardLayout(QDialog):
|
|||||||
|
|
||||||
c = self.rendered_card = self.note.ephemeral_card(
|
c = self.rendered_card = self.note.ephemeral_card(
|
||||||
self.ord,
|
self.ord,
|
||||||
custom_note_type=self.current_template(),
|
custom_note_type=self.model,
|
||||||
|
custom_template=self.current_template(),
|
||||||
fill_empty=self.fill_empty_action_toggled,
|
fill_empty=self.fill_empty_action_toggled,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user