remove ':' from field names

This commit is contained in:
Damien Elmes 2019-12-30 18:50:00 +10:00
parent fbfb7861a2
commit ee3f963919
2 changed files with 9 additions and 0 deletions

View File

@ -338,6 +338,8 @@ and notes.mid = ? and cards.ord = ?""",
def renameField(self, m: NoteType, field: Field, newName: Optional[str]) -> None:
self.col.modSchema(check=True)
if newName is not None:
newName = newName.replace(":", "")
pat = r"{{([^{}]*)([:#^/]|[^:#/^}][^:}]*?:|)%s}}"
def wrap(txt):

View File

@ -49,6 +49,7 @@ class CardLayout(QDialog):
self.emptyFields.append(name)
note[name] = "(%s)" % name
note.flush()
self.removeColons()
self.setupTopArea()
self.setupMainArea()
self.setupButtons()
@ -242,6 +243,12 @@ Please create a new card type first."""
)
self.redraw()
def removeColons(self):
# colons in field names conflict with the template language
for fld in self.model["flds"]:
if ":" in fld["name"]:
self.mm.renameField(self.model, fld, fld["name"])
# Buttons
##########################################################################