fix(types): resolucion integral de tipado estatico, Pyright 0 errores y bump a v3.8.1
This commit is contained in:
@@ -131,9 +131,9 @@ class Role(db.Model):
|
||||
if access_level not in ACCESS_LEVELS:
|
||||
access_level = 'none'
|
||||
|
||||
for p in self.permissions:
|
||||
if p.module == module:
|
||||
p.access_level = access_level
|
||||
for p in getattr(self, 'permissions', []):
|
||||
if getattr(p, 'module', None) == module:
|
||||
setattr(p, 'access_level', access_level)
|
||||
return p
|
||||
|
||||
new_perm = Permission(role=self, module=module, access_level=access_level)
|
||||
@@ -141,14 +141,16 @@ class Role(db.Model):
|
||||
return new_perm
|
||||
|
||||
def to_dict(self):
|
||||
perms = getattr(self, 'permissions', [])
|
||||
users_list = getattr(self, 'users', [])
|
||||
return {
|
||||
'id': self.id,
|
||||
'name': self.name,
|
||||
'description': self.description,
|
||||
'is_system': self.is_system,
|
||||
'created_at': self.created_at.isoformat() if self.created_at else None,
|
||||
'user_count': len(self.users) if self.users else 0,
|
||||
'permissions': {p.module: p.access_level for p in self.permissions}
|
||||
'user_count': len(list(users_list)) if users_list else 0,
|
||||
'permissions': {getattr(p, 'module', ''): getattr(p, 'access_level', '') for p in perms}
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
Reference in New Issue
Block a user