Skip to content

Commit

Permalink
fixed linting
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshhari committed Dec 25, 2024
1 parent 601af4d commit 0d65f50
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions care/emr/resources/role/spec.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pydantic import UUID4, BaseModel
from pydantic import UUID4

from care.emr.resources.base import EMRResource
from care.security.models import RoleModel, PermissionModel
from care.security.models import PermissionModel, RoleModel


class PermissionSpec(EMRResource):
Expand Down
22 changes: 16 additions & 6 deletions care/users/api/serializers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from care.emr.resources.role.spec import PermissionSpec
from care.facility.api.serializers.facility import FacilityBareMinimumSerializer
from care.facility.models import Facility, FacilityUser
from care.security.models import RoleModel, RolePermission
from care.security.models import RolePermission
from care.users.api.serializers.lsg import (
DistrictSerializer,
LocalBodySerializer,
Expand Down Expand Up @@ -310,12 +310,22 @@ class UserSerializer(SignUpSerializer):
permissions = serializers.SerializerMethodField()

def get_organizations(self, user):
organizations = Organization.objects.filter(id__in=OrganizationUser.objects.filter(user=user).values_list("organization_id", flat=True))
organizations = Organization.objects.filter(
id__in=OrganizationUser.objects.filter(user=user).values_list(
"organization_id", flat=True
)
)
return [OrganizationReadSpec.serialize(obj).to_json() for obj in organizations]

def get_permissions(self , user):
permissions = RolePermission.objects.filter(role_id__in=OrganizationUser.objects.filter(user=user).values_list("role_id", flat=True)).select_related("permission")
return [PermissionSpec.serialize(obj.permission).to_json() for obj in permissions]
def get_permissions(self, user):
permissions = RolePermission.objects.filter(
role_id__in=OrganizationUser.objects.filter(user=user).values_list(
"role_id", flat=True
)
).select_related("permission")
return [
PermissionSpec.serialize(obj.permission).to_json() for obj in permissions
]

def get_user_flags(self, user) -> tuple[str]:
return user.get_all_flags()
Expand Down Expand Up @@ -357,7 +367,7 @@ class Meta:
"user_flags",
"last_login",
"organizations",
"permissions"
"permissions",
)
read_only_fields = (
"is_superuser",
Expand Down

0 comments on commit 0d65f50

Please sign in to comment.