1
0
mirror of https://github.com/enpaul/keyosk.git synced 2024-11-24 23:47:49 +00:00

Fix hacked permission and access list string names

Update domain access list and domain permission models to be dict-castable
Update domain model to specify dict casting for access list and permission backrefs properly
Remove unnecessary permission_names and access_list_names properties
This commit is contained in:
Ethan Paul 2020-02-24 21:27:20 -05:00
parent 85a53d061a
commit ac893d9707

View File

@ -53,16 +53,6 @@ class Domain(KeyoskBaseModel):
lifespan_access = peewee.IntegerField(null=False)
lifespan_refresh = peewee.IntegerField(null=False)
@property
def access_list_names(self) -> List[str]:
"""Return the list of ACL items from the backref"""
return [item.name for item in self._access_lists]
@property
def permission_names(self) -> List[str]:
"""Return the list of permission names from the backref"""
return [item.name for item in self._permissions]
@staticmethod
def dict_keys() -> List[str]:
return [
@ -80,10 +70,14 @@ class Domain(KeyoskBaseModel):
"enable_refresh",
"lifespan_access",
"lifespan_refresh",
"access_list_names",
"permission_names",
"access_lists",
"permissions",
]
@staticmethod
def foreign_backref() -> List[str]:
return ["access_lists", "permissions"]
class DomainAccessList(KeyoskBaseModel):
"""Access list name model definition
@ -98,6 +92,10 @@ class DomainAccessList(KeyoskBaseModel):
name = peewee.CharField(null=False)
domain = peewee.ForeignKeyField(Domain, backref="access_lists")
@staticmethod
def dict_keys() -> List[str]:
return ["name"]
class DomainPermission(KeyoskBaseModel):
"""Permission name model definition
@ -114,3 +112,7 @@ class DomainPermission(KeyoskBaseModel):
name = peewee.CharField(null=False)
bitindex = peewee.IntegerField(null=False)
domain = peewee.ForeignKeyField(Domain, backref="permissions")
@staticmethod
def dict_keys() -> List[str]:
return ["name", "bitindex"]