Check for out-of-place/missing clozes when adding
This commit is contained in:
parent
aeedb4dc11
commit
9acc03773a
@ -6,4 +6,6 @@ adding-history = History
|
||||
adding-note-deleted = (Note deleted)
|
||||
adding-shortcut = Shortcut: { $val }
|
||||
adding-the-first-field-is-empty = The first field is empty.
|
||||
adding-you-have-a-cloze-deletion-note = You have a cloze deletion note type but have not made any cloze deletions. Proceed?
|
||||
adding-missing-cloze = You have a cloze notetype but have not made any cloze deletions.
|
||||
adding-cloze-outside-cloze-notetype = Cloze deletion can only be used on cloze notetypes.
|
||||
adding-cloze-outside-cloze-field = Cloze deletion can only be used in fields which use the 'cloze:' filter (see 'Cards...').
|
||||
|
@ -11,7 +11,7 @@ ignored-classes=
|
||||
QueuedCards,
|
||||
UnburyDeckIn,
|
||||
BuryOrSuspendCardsIn,
|
||||
NoteIsDuplicateOrEmptyOut,
|
||||
NoteFieldsCheckOut,
|
||||
BackendError,
|
||||
SetDeckCollapsedIn,
|
||||
|
||||
|
@ -6,10 +6,9 @@ from typing import Callable, List, Optional
|
||||
import aqt.editor
|
||||
import aqt.forms
|
||||
from anki.collection import OpChanges, SearchNode
|
||||
from anki.consts import MODEL_CLOZE
|
||||
from anki.decks import DeckId
|
||||
from anki.models import NotetypeId
|
||||
from anki.notes import DuplicateOrEmptyResult, Note, NoteId
|
||||
from anki.notes import Note, NoteFieldsCheckResult, NoteId
|
||||
from anki.utils import htmlToTextLine, isMac
|
||||
from aqt import AnkiQt, gui_hooks
|
||||
from aqt.deckchooser import DeckChooser
|
||||
@ -231,9 +230,15 @@ class AddCards(QDialog):
|
||||
).run_in_background()
|
||||
|
||||
def _note_can_be_added(self, note: Note) -> bool:
|
||||
result = note.duplicate_or_empty()
|
||||
if result == DuplicateOrEmptyResult.EMPTY:
|
||||
result = note.fields_check()
|
||||
if result == NoteFieldsCheckResult.EMPTY:
|
||||
problem = tr.adding_the_first_field_is_empty()
|
||||
elif result == NoteFieldsCheckResult.MISSING_CLOZE:
|
||||
problem = tr.adding_missing_cloze()
|
||||
elif result == NoteFieldsCheckResult.NOTETYPE_NOT_CLOZE:
|
||||
problem = tr.adding_cloze_outside_cloze_notetype()
|
||||
elif result == NoteFieldsCheckResult.FIELD_NOT_CLOZE:
|
||||
problem = tr.adding_cloze_outside_cloze_field()
|
||||
else:
|
||||
# duplicate entries are allowed these days
|
||||
problem = None
|
||||
@ -244,12 +249,6 @@ class AddCards(QDialog):
|
||||
showWarning(problem, help=HelpPage.ADDING_CARD_AND_NOTE)
|
||||
return False
|
||||
|
||||
# missing cloze deletion?
|
||||
if note.model()["type"] == MODEL_CLOZE:
|
||||
if not note.cloze_numbers_in_fields():
|
||||
if not askUser(tr.adding_you_have_a_cloze_deletion_note()):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def keyPressEvent(self, evt: QKeyEvent) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user