2022-06-08 21:41:59 +02:00
|
|
|
from areas.apps.models import AppRole
|
2022-04-14 13:32:35 +02:00
|
|
|
from .models import Role
|
|
|
|
|
|
|
|
|
|
|
|
class RoleService:
|
|
|
|
@staticmethod
|
|
|
|
def get_roles():
|
|
|
|
roles = Role.query.all()
|
|
|
|
return [{"id": r.id, "name": r.name} for r in roles]
|
2022-05-18 20:58:00 +02:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_role_by_id(role_id):
|
|
|
|
return Role.query.filter_by(id=role_id).first()
|
2022-06-08 21:41:59 +02:00
|
|
|
|
2022-06-09 12:21:47 +02:00
|
|
|
@staticmethod
|
2022-06-08 21:41:59 +02:00
|
|
|
def is_user_admin(userId):
|
|
|
|
dashboard_role_id = AppRole.query.filter_by(user_id=userId, app_id=1).first().role_id
|
|
|
|
return dashboard_role_id == 1
|