mirror of
https://github.com/ansible/awx.git
synced 2026-02-02 01:58:09 -03:30
Add field on inventory detail to indicate if the user has permission to run ad hoc commands.
This commit is contained in:
@@ -785,6 +785,18 @@ class InventorySerializer(BaseSerializerWithVariables):
|
||||
return ret
|
||||
|
||||
|
||||
class InventoryDetailSerializer(InventorySerializer):
|
||||
|
||||
class Meta:
|
||||
fields = ('*', 'can_run_ad_hoc_commands')
|
||||
|
||||
can_run_ad_hoc_commands = serializers.SerializerMethodField('get_can_run_ad_hoc_commands')
|
||||
|
||||
def get_can_run_ad_hoc_commands(self, obj):
|
||||
view = self.context.get('view', None)
|
||||
return bool(obj and view and view.request and view.request.user and view.request.user.can_access(Inventory, 'run_ad_hoc_commands', obj))
|
||||
|
||||
|
||||
class InventoryScriptSerializer(InventorySerializer):
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -887,7 +887,7 @@ class InventoryList(ListCreateAPIView):
|
||||
class InventoryDetail(RetrieveUpdateDestroyAPIView):
|
||||
|
||||
model = Inventory
|
||||
serializer_class = InventorySerializer
|
||||
serializer_class = InventoryDetailSerializer
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
with ignore_inventory_computed_fields():
|
||||
|
||||
Reference in New Issue
Block a user