@ -296,7 +296,7 @@ class AdminUserSerializer(serializers.ModelSerializer):
User . UserType . SUPER_ADMIN : " Super Admin Group " ,
User . UserType . SUPER_ADMIN : " Super Admin Group " ,
User . UserType . CONSULTANT : " Consultant Group " ,
User . UserType . CONSULTANT : " Consultant Group " ,
}
}
PANEL_GROUPS = { " Professor Group " , " Admin Group " , " Super admin Group " , " Super Admin Group " }
PANEL_GROUPS = { " Professor Group " , " Admin Group " , " Super admin Group " , " Super Admin Group " , " Consultant Group " }
def _ensure_group ( self , instance , group_name ) :
def _ensure_group ( self , instance , group_name ) :
group , _ = Group . objects . get_or_create ( name = group_name )
group , _ = Group . objects . get_or_create ( name = group_name )
@ -317,21 +317,21 @@ class AdminUserSerializer(serializers.ModelSerializer):
instance . is_staff = True
instance . is_staff = True
instance . is_superuser = True
instance . is_superuser = True
self . _ensure_group ( instance , " Super Admin Group " )
self . _ensure_group ( instance , " Super Admin Group " )
self . _remove_groups ( instance , { " Professor Group " , " Admin Group " , " Super admin Group " } )
self . _remove_groups ( instance , { " Professor Group " , " Admin Group " , " Super admin Group " , " Consultant Group " } )
return
return
if requested_user_type == User . UserType . PROFESSOR :
if requested_user_type == User . UserType . PROFESSOR :
instance . is_staff = False
instance . is_staff = False
instance . is_superuser = False
instance . is_superuser = False
self . _ensure_group ( instance , " Professor Group " )
self . _ensure_group ( instance , " Professor Group " )
self . _remove_groups ( instance , { " Admin Group " , " Super admin Group " , " Super Admin Group " } )
self . _remove_groups ( instance , { " Admin Group " , " Super admin Group " , " Super Admin Group " , " Consultant Group " } )
return
return
if requested_user_type == User . UserType . ADMIN :
if requested_user_type == User . UserType . ADMIN :
instance . is_staff = False
instance . is_staff = False
instance . is_superuser = False
instance . is_superuser = False
self . _ensure_group ( instance , " Admin Group " )
self . _ensure_group ( instance , " Admin Group " )
self . _remove_groups ( instance , { " Professor Group " , " Super admin Group " , " Super Admin Group " } )
self . _remove_groups ( instance , { " Professor Group " , " Super admin Group " , " Super Admin Group " , " Consultant Group " } )
return
return
if requested_user_type == User . UserType . STUDENT :
if requested_user_type == User . UserType . STUDENT :
@ -345,7 +345,7 @@ class AdminUserSerializer(serializers.ModelSerializer):
instance . is_staff = False
instance . is_staff = False
instance . is_superuser = False
instance . is_superuser = False
self . _ensure_group ( instance , " Consultant Group " )
self . _ensure_group ( instance , " Consultant Group " )
self . _remove_groups ( instance , self . PANEL_GROUPS )
self . _remove_groups ( instance , { " Professor Group " , " Admin Group " , " Super admin Group " , " Super Admin Group " , " Student Group " } )
return
return
if requested_user_type == User . UserType . CLIENT :
if requested_user_type == User . UserType . CLIENT :