是否有一种更干净的方法来获取“ ALL”值,而不是对所有值进行硬编码?例如,如果我在此处添加了新值,则还需要手动添加该项目:
class EntitySharedLinkPermission(models.Model):
OFF = None
COMPANY_VIEW = "Company View"
COMPANY_EDIT = "Company Edit"
PUBLIC_VIEW = "Public View"
PUBLIC_EDIT = "Public Edit"
ALL_PERMISSIONS = [
EntitySharedLinkPermission.OFF,
EntitySharedLinkPermission.COMPANY_VIEW,
EntitySharedLinkPermission.COMPANY_EDIT,
EntitySharedLinkPermission.PUBLIC_VIEW,
EntitySharedLinkPermission.PUBLIC_EDIT
]