mirror of
https://github.com/ansible/awx.git
synced 2026-06-23 15:47:49 -02:30
Remove some attached methods from User model (#15325)
Remove archaic monkey patches (#15338) Remove some attached methods from User model Test user-org sublist URLs we did not test before
This commit is contained in:
@@ -10,7 +10,7 @@ from rest_framework import permissions
|
||||
|
||||
# AWX
|
||||
from awx.main.access import check_user_access
|
||||
from awx.main.models import Inventory, UnifiedJob
|
||||
from awx.main.models import Inventory, UnifiedJob, Organization
|
||||
from awx.main.utils import get_object_or_400
|
||||
|
||||
logger = logging.getLogger('awx.api.permissions')
|
||||
@@ -228,7 +228,7 @@ class InventoryInventorySourcesUpdatePermission(ModelAccessPermission):
|
||||
class UserPermission(ModelAccessPermission):
|
||||
def check_post_permissions(self, request, view, obj=None):
|
||||
if not request.data:
|
||||
return request.user.admin_of_organizations.exists()
|
||||
return Organization.access_qs(request.user, 'change').exists()
|
||||
elif request.user.is_superuser:
|
||||
return True
|
||||
raise PermissionDenied()
|
||||
|
||||
@@ -1152,7 +1152,6 @@ class UserOrganizationsList(OrganizationCountsMixin, SubListAPIView):
|
||||
model = models.Organization
|
||||
serializer_class = serializers.OrganizationSerializer
|
||||
parent_model = models.User
|
||||
relationship = 'organizations'
|
||||
|
||||
def get_queryset(self):
|
||||
parent = self.get_parent_object()
|
||||
@@ -1166,7 +1165,6 @@ class UserAdminOfOrganizationsList(OrganizationCountsMixin, SubListAPIView):
|
||||
model = models.Organization
|
||||
serializer_class = serializers.OrganizationSerializer
|
||||
parent_model = models.User
|
||||
relationship = 'admin_of_organizations'
|
||||
|
||||
def get_queryset(self):
|
||||
parent = self.get_parent_object()
|
||||
|
||||
Reference in New Issue
Block a user