Merge pull request #9912 from fosterseth/fix_t4919_jt_slow_load

Return distinct labels for normal Users

SUMMARY


Create a single label and add it to 2 or more JTs
Visit /api/v2/labels as superuser and you'll see a single label
Create a normal user and give admin role to each JT in step 1
Visit /api/v2/labels as this normal user and you will see duplicate entries for the label. Number of entries will be equal to the number of JTs in step 1


ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME


API

AWX VERSION

awx: 19.0.0

Reviewed-by: Seth Foster <None>
Reviewed-by: Jeff Bradberry <None>
This commit is contained in:
softwarefactory-project-zuul[bot] 2021-04-20 17:22:35 +00:00 committed by GitHub
commit 0ca024c929
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2627,7 +2627,7 @@ class LabelAccess(BaseAccess):
return self.model.objects.filter(
Q(organization__in=Organization.accessible_pk_qs(self.user, 'read_role'))
| Q(unifiedjobtemplate_labels__in=UnifiedJobTemplate.accessible_pk_qs(self.user, 'read_role'))
)
).distinct()
@check_superuser
def can_add(self, data):