2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

Add new attechment functionality to new models

- Giving the ol' refactor tractor a fresh coat of paint
This commit is contained in:
Oliver Walters
2020-05-12 21:40:42 +10:00
parent 2369b40bbf
commit 366d4b2143
10 changed files with 70 additions and 46 deletions

View File

@ -29,6 +29,7 @@ from .serializers import StockItemAttachmentSerializer
from InvenTree.views import TreeSerializer
from InvenTree.helpers import str2bool, isNull
from InvenTree.api import AttachmentMixin
from decimal import Decimal, InvalidOperation
@ -645,7 +646,7 @@ class StockList(generics.ListCreateAPIView):
]
class StockAttachmentList(generics.ListCreateAPIView):
class StockAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
"""
API endpoint for listing (and creating) a StockItemAttachment (file upload)
"""
@ -653,22 +654,10 @@ class StockAttachmentList(generics.ListCreateAPIView):
queryset = StockItemAttachment.objects.all()
serializer_class = StockItemAttachmentSerializer
filter_backends = [
DjangoFilterBackend,
filters.OrderingFilter,
filters.SearchFilter,
]
filter_fields = [
'stock_item',
]
def perform_create(self, serializer):
attachment = serializer.save()
attachment.user = self.request.user
attachment.save()
class StockTrackingList(generics.ListCreateAPIView):
""" API endpoint for list view of StockItemTracking objects.

View File

@ -20,9 +20,9 @@
<table class='table table-striped table-condensed' data-toolbar='#attachment-buttons' id='attachment-table'>
<thead>
<tr>
<th data-field='file' data-searchable='true'>{% trans "File" %}</th>
<th data-field='comment' data-searchable='true'>{% trans "Comment" %}</th>
<th data-field='user' data-searchable='true'>{% trans "Uploaded" %}</th>
<th data-field='file' data-sortable='true' data-searchable='true'>{% trans "File" %}</th>
<th data-field='comment' data-sortable='true' data-searchable='true'>{% trans "Comment" %}</th>
<th data-field='user' data-sortable='true' data-searchable='true'>{% trans "Uploaded" %}</th>
<th></th>
</tr>
</thead>