add parent_role to role representation
This commit is contained in:
@@ -105,6 +105,8 @@ class RoleSerializer(serializers.ModelSerializer):
|
|||||||
"""
|
"""
|
||||||
representation = super().to_representation(instance)
|
representation = super().to_representation(instance)
|
||||||
representation['type'] = auth_serializer.OrganizationTypeSerializer(instance.type).data
|
representation['type'] = auth_serializer.OrganizationTypeSerializer(instance.type).data
|
||||||
|
if instance.parent_role:
|
||||||
|
representation['parent_role'] = {'name': instance.parent_role.role_name, 'id': instance.parent_role.id}
|
||||||
if instance.permissions: # noqa
|
if instance.permissions: # noqa
|
||||||
permissions = instance.permissions.filter(is_active=True)
|
permissions = instance.permissions.filter(is_active=True)
|
||||||
representation['permissions'] = PermissionSerializer(permissions, many=True).data
|
representation['permissions'] = PermissionSerializer(permissions, many=True).data
|
||||||
|
|||||||
@@ -278,3 +278,5 @@ django.core.exceptions.FieldError: Unsupported lookup 'name' for ForeignKey or j
|
|||||||
[2025-10-28 09:03:36,050] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
[2025-10-28 09:03:36,050] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||||
[2025-10-28 09:07:59,433] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authorization\api\v1\serializers.py changed, reloading.
|
[2025-10-28 09:07:59,433] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authorization\api\v1\serializers.py changed, reloading.
|
||||||
[2025-10-28 09:08:01,206] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
[2025-10-28 09:08:01,206] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||||
|
[2025-10-28 09:15:25,146] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authorization\api\v1\serializers.py changed, reloading.
|
||||||
|
[2025-10-28 09:15:27,109] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||||
|
|||||||
Reference in New Issue
Block a user