mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add 'attachment_detail' to the TestResult serializer
This commit is contained in:
parent
608057da69
commit
3b53437f46
@ -698,6 +698,11 @@ class StockItemTestResultList(generics.ListCreateAPIView):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
kwargs['attachment_detail'] = str2bool(self.request.query_params.get('attachment_detail', False))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
kwargs['context'] = self.get_serializer_context()
|
kwargs['context'] = self.get_serializer_context()
|
||||||
|
|
||||||
return self.serializer_class(*args, **kwargs)
|
return self.serializer_class(*args, **kwargs)
|
||||||
|
@ -222,15 +222,20 @@ class StockItemTestResultSerializer(InvenTreeModelSerializer):
|
|||||||
""" Serializer for the StockItemTestResult model """
|
""" Serializer for the StockItemTestResult model """
|
||||||
|
|
||||||
user_detail = UserSerializerBrief(source='user', read_only=True)
|
user_detail = UserSerializerBrief(source='user', read_only=True)
|
||||||
|
attachment_detail = StockItemAttachmentSerializer(source='attachment', read_only=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
user_detail = kwargs.pop('user_detail', False)
|
user_detail = kwargs.pop('user_detail', False)
|
||||||
|
attachment_detail = kwargs.pop('attachment_detail', False)
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
if user_detail is not True:
|
if user_detail is not True:
|
||||||
self.fields.pop('user_detail')
|
self.fields.pop('user_detail')
|
||||||
|
|
||||||
|
if attachment_detail is not True:
|
||||||
|
self.fields.pop('attachment_detail')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = StockItemTestResult
|
model = StockItemTestResult
|
||||||
|
|
||||||
@ -241,6 +246,7 @@ class StockItemTestResultSerializer(InvenTreeModelSerializer):
|
|||||||
'result',
|
'result',
|
||||||
'value',
|
'value',
|
||||||
'attachment',
|
'attachment',
|
||||||
|
'attachment_detail',
|
||||||
'notes',
|
'notes',
|
||||||
'user',
|
'user',
|
||||||
'user_detail',
|
'user_detail',
|
||||||
|
Loading…
Reference in New Issue
Block a user