fix(roles): Minor documentation + typings

This commit is contained in:
Ferdinand Thiessen 2021-12-18 03:04:37 +01:00
parent 2df5a61ff3
commit 1db3391826
1 changed files with 11 additions and 2 deletions

View File

@ -1,9 +1,10 @@
from typing import Union
from sqlalchemy.exc import IntegrityError
from werkzeug.exceptions import BadRequest, Conflict, NotFound
from flaschengeist import logger
from flaschengeist.models.user import Role, Permission
from flaschengeist.database import db, case_sensitive
from flaschengeist import logger
from flaschengeist.utils.hook import Hook
@ -11,7 +12,15 @@ def get_all():
return Role.query.all()
def get(role_name) -> Role:
def get(role_name: Union[int,str]) -> Role:
"""Get role by ID or name
Args:
role_name: Name or ID of the role
Returns:
Matching role
Raises:
NotFound
"""
if type(role_name) is int:
role = Role.query.get(role_name)
else: