Spaces:
Build error
Build error
File size: 2,099 Bytes
b7a7f32 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
from core.config import settings
from core.db import SessionLocal
from cruds import crud_user_permission
from utils import get_super_admin
def default_permission(user_type: int):
if (user_type == settings.UserType.SUPERADMIN.value):
permissions_list = crud_user_permission.get_multi(db=SessionLocal(), limit=-1)
permissions_list = list(map(lambda x: x.id, permissions_list))
return permissions_list
if (user_type == settings.UserType.ADMIN.value):
permissions_list_name = crud_user_permission.get_multi(db=SessionLocal(), limit=-1)
permissions_list = list(map(lambda x: x.name, permissions_list_name))
nono_list = [
"personal_note_get",
"personal_note_post",
"personal_note_update",
"teacher_note_get",
"teacher_note_post",
"teacher_note_update",
]
for item in nono_list:
permissions_list.pop(nono_list.index(item))
permissions_list = list(map(lambda x: crud_user_permission.get_by_name(db=SessionLocal(), name=x), permissions_list))
permissions_list = list(map(lambda x: x.id, permissions_list))
return permissions_list
if (user_type == settings.UserType.TEACHER.value):
yesyes_list = [
"class_session_get_self",
"course_get",
"personal_note_post",
"personal_note_update",
"class_session_get",
"teacher_note_get_self",
"teacher_note_post",
"teacher_note_update_self",
"user_get_self",
"user_get_self",
]
permissions_list = list(map(lambda x: crud_user_permission.get_by_name(db=SessionLocal(), name=x), yesyes_list))
permissions_list = list(map(lambda x: x.id, permissions_list))
return permissions_list
if (user_type == settings.UserType.STUDENT.value):
permissions_list = crud_user_permission.get_multi(db=SessionLocal(), limit=-1)
permissions_list = list(map(lambda x: x.id, permissions_list))
return permissions_list
|