Fix: Printer edit shows the proper hex values in printer edit and import the right hex value from old database
This commit is contained in:
@ -33,7 +33,11 @@ def save(
|
||||
user: UserToken = Security(get_user, scopes=["printers"]),
|
||||
) -> schemas.Printer:
|
||||
try:
|
||||
item = Printer(name=data.name, address=data.address, cut_code=bytearray.fromhex(data.cut_code).decode())
|
||||
item = Printer(
|
||||
name=data.name,
|
||||
address=data.address,
|
||||
cut_code=bytes.fromhex(data.cut_code).decode(),
|
||||
)
|
||||
db.add(item)
|
||||
db.commit()
|
||||
return printer_info(item)
|
||||
@ -123,9 +127,9 @@ def printer_info(item: Printer) -> schemas.Printer:
|
||||
id=item.id,
|
||||
name=item.name,
|
||||
address=item.address,
|
||||
cutCode=item.cut_code,
|
||||
cutCode=bytes(item.cut_code, "ascii").hex(),
|
||||
)
|
||||
|
||||
|
||||
def printer_blank() -> schemas.PrinterBlank:
|
||||
return schemas.PrinterBlank(name="", address="", cutCode="")
|
||||
return schemas.PrinterBlank(name="", address="", cutCode="1d564103")
|
||||
|
||||
Reference in New Issue
Block a user