Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] fix Location/ Bed Management issue ( District Lab Admin Account) #1959

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions care/facility/models/mixins/permissions/facility.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ def has_cover_image_delete_permission(request):
)

def has_object_read_permission(self, request):
return super().has_object_read_permission(request) or self.users.contains(
request.user
return (
super().has_object_read_permission(request)
or self.users.contains(request.user)
or (
hasattr(self, "district")
and request.user.user_type >= User.TYPE_VALUE_MAP["DistrictLabAdmin"]
and request.user.district == self.district
)
)

def has_object_write_permission(self, request):
Expand Down Expand Up @@ -124,6 +130,7 @@ def has_object_read_permission(self, request):
return (
super().has_object_read_permission(request)
or request.user.is_superuser
or request.user.user_type >= User.TYPE_VALUE_MAP["DistrictLabAdmin"]
or request.user in self.facility.users.all()
)

Expand Down