fix save screen

This commit is contained in:
d0c 2023-02-17 13:59:02 +01:00
parent e2c79cf698
commit 512b3dfba9
2 changed files with 17 additions and 15 deletions

View file

@ -16,11 +16,11 @@ def update_repo():
if pull_status.returncode != 0:
logging.error("Error pulling repo")
def set_screen(args):
def set_screens(args):
#if type(args)
screen = Screen.objects.filter(**args)
if not screen.exists():
screen = Screen()
screen = Screens()
for subkey, subvalue in args.items():
if subkey == 'size':
size_mm = subvalue.split(' ')[0]
@ -119,9 +119,9 @@ class Command(BaseCommand):
if type(value) is list:
for s in value:
for k,v in s.items():
screen.append(set_screen(v))
screen.append(set_screens(v))
elif type(value) is dict:
screen.append(set_screen(value))
screen.append(set_screens(value))
else:
setattr(dev, key, value)
except yaml.YAMLError as exc:
@ -131,5 +131,7 @@ class Command(BaseCommand):
dev.bluetooth = bluetooth
for cam in cameras:
dev.cameras.add(cam)
for scr in screen:
dev.screen.add(scr)
dev.save()