def _note_can_be_added(self, note: Note) -> bool: result = note.duplicate_or_empty() if result == DuplicateOrEmptyResult.EMPTY: problem = tr.adding_the_first_field_is_empty() else: # duplicate entries are allowed these days problem = None # filter problem through add-ons problem = gui_hooks.add_cards_will_add_note(problem, note) if problem is not None: 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 _note_can_be_added(self, note: Note) -> bool: result = note.fields_check() # no problem, duplicate, and confirmed cloze cases problem = None if result == NoteFieldsCheckResult.EMPTY: problem = tr.adding_the_first_field_is_empty() elif result == NoteFieldsCheckResult.MISSING_CLOZE: if not askUser(tr.adding_you_have_a_cloze_deletion_note()): return False 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() # filter problem through add-ons problem = gui_hooks.add_cards_will_add_note(problem, note) if problem is not None: showWarning(problem, help=HelpPage.ADDING_CARD_AND_NOTE) return False return True