From 733ffa6cd849ed544556d58613189cad78146676 Mon Sep 17 00:00:00 2001 From: Ethan Paul Date: Sun, 23 Feb 2020 16:50:43 -0500 Subject: [PATCH] Add missing methods for casting account model to dict --- keyosk/database/account.py | 6 +++++- keyosk/database/account_acl.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/keyosk/database/account.py b/keyosk/database/account.py index bd7746d..df73155 100644 --- a/keyosk/database/account.py +++ b/keyosk/database/account.py @@ -88,4 +88,8 @@ class Account(KeyoskBaseModel): @staticmethod def dict_keys() -> List[str]: - return ["uuid", "created", "updated", "username", "enabled", "extras"] + return ["uuid", "created", "updated", "username", "enabled", "extras", "acls"] + + @staticmethod + def foreign_backref() -> List[str]: + return ["acls"] diff --git a/keyosk/database/account_acl.py b/keyosk/database/account_acl.py index 6322e2f..c6220fa 100644 --- a/keyosk/database/account_acl.py +++ b/keyosk/database/account_acl.py @@ -41,3 +41,9 @@ class AccountACLEntry(KeyoskBaseModel): permission = peewee.ForeignKeyField(DomainPermission) with_server_secret = peewee.BooleanField(null=False) with_client_secret = peewee.BooleanField(null=False) + + def __iter__(self): + yield "access_list", self.access_list.name + yield "permission", self.permission.name + yield "with_server_secret", self.with_server_secret + yield "with_client_secret", self.with_client_secret