Skip to content

Conversation

@AlanCoding
Copy link
Member

SUMMARY

This is outright duplication with DAB, and this patch brings AWX into the same patterns as everything else.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API

filter_args.append(
Q(Q(**{'%s__pk__in' % res_path: parent_model.accessible_pk_qs(user, '%s_role' % role_type)}) | Q(**{'%s__isnull' % res_path: True}))
Q(
Q(**{'%s__pk__in' % res_path: parent_model.access_ids_qs(user, to_permissions['%s_role' % role_type])})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test failure

  File "/awx_devel/awx/api/serializers.py", line 509, in _obj_capability_dict
    self.context['capability_map'] = prefetch_page_capabilities(model, qs, prefetch_list, view.request.user)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/awx_devel/awx/main/utils/common.py", line 641, in prefetch_page_capabilities
    Q(**{'%s__pk__in' % res_path: parent_model.access_ids_qs(user, to_permissions['%s_role' % role_type])})
                                                                   ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'project_admin_role'

this seems to come from the serializer, from

capabilities_prefetch = ['admin', 'update', {'copy': 'organization.project_admin'}]

This is a coherent "old" role name, but it isn't fully baked in the new system. We just want to check "add_project" permission to the organization. We might want to completely change this contract to the new names to make this make sense.

return cls.objects.filter(pk__in=cls.access_ids_qs(accessor, action))

@classmethod
def accessible_pk_qs(cls, accessor, role_field):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will want to delete this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant