mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 12:36:45 +00:00
Add detail endpoint for StockItemAttachment
This commit is contained in:
parent
87235b7e6f
commit
54c9bd25a5
@ -2,6 +2,7 @@
|
||||
JSON API for the Stock app
|
||||
"""
|
||||
|
||||
from django.db.models.query import QuerySet
|
||||
from django_filters.rest_framework import FilterSet, DjangoFilterBackend
|
||||
from django_filters import NumberFilter
|
||||
|
||||
@ -931,6 +932,15 @@ class StockAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
|
||||
]
|
||||
|
||||
|
||||
class StockAttachmentDetail(generics.RetrieveUpdateDestroyAPIView, AttachmentMixin):
|
||||
"""
|
||||
Detail endpoint for StockItemAttachment
|
||||
"""
|
||||
|
||||
queryset = StockItemAttachment.objects.all()
|
||||
serializer_class = StockItemAttachmentSerializer
|
||||
|
||||
|
||||
class StockItemTestResultList(generics.ListCreateAPIView):
|
||||
"""
|
||||
API endpoint for listing (and creating) a StockItemTestResult object.
|
||||
@ -1133,6 +1143,7 @@ stock_api_urls = [
|
||||
url(r'location/', include(location_endpoints)),
|
||||
|
||||
# These JSON endpoints have been replaced (for now) with server-side form rendering - 02/06/2019
|
||||
# TODO: Remove server-side forms for stock adjustment!!!
|
||||
url(r'count/?', StockCount.as_view(), name='api-stock-count'),
|
||||
url(r'add/?', StockAdd.as_view(), name='api-stock-add'),
|
||||
url(r'remove/?', StockRemove.as_view(), name='api-stock-remove'),
|
||||
@ -1140,6 +1151,7 @@ stock_api_urls = [
|
||||
|
||||
# Base URL for StockItemAttachment API endpoints
|
||||
url(r'^attachment/', include([
|
||||
url(r'^(?P<pk>\d+)/', StockAttachmentDetail.as_view(), name='api-stock-attachment-detail'),
|
||||
url(r'^$', StockAttachmentList.as_view(), name='api-stock-attachment-list'),
|
||||
])),
|
||||
|
||||
|
@ -61,11 +61,17 @@ $("#new-attachment").click(function() {
|
||||
$("#attachment-table").on('click', '.attachment-edit-button', function() {
|
||||
var button = $(this);
|
||||
|
||||
var url = `/stock/item/attachment/${button.attr('pk')}/edit/`;
|
||||
var pk = button.attr('pk');
|
||||
|
||||
launchModalForm(url,
|
||||
{
|
||||
reload: true,
|
||||
var url = `/api/stock/attachment/${pk}/`;
|
||||
|
||||
constructForm(url, {
|
||||
fields: {
|
||||
attachment: {},
|
||||
comment: {},
|
||||
},
|
||||
title: '{% trans "Edit Attachment" %}',
|
||||
reload: true
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -64,7 +64,6 @@ stock_urls = [
|
||||
|
||||
# URLs for StockItem attachments
|
||||
url(r'^item/attachment/', include([
|
||||
url(r'^(?P<pk>\d+)/edit/', views.StockItemAttachmentEdit.as_view(), name='stock-item-attachment-edit'),
|
||||
url(r'^(?P<pk>\d+)/delete/', views.StockItemAttachmentDelete.as_view(), name='stock-item-attachment-delete'),
|
||||
])),
|
||||
|
||||
|
@ -255,23 +255,6 @@ class StockLocationQRCode(QRCodeView):
|
||||
return None
|
||||
|
||||
|
||||
class StockItemAttachmentEdit(AjaxUpdateView):
|
||||
"""
|
||||
View for editing a StockItemAttachment object.
|
||||
"""
|
||||
|
||||
model = StockItemAttachment
|
||||
form_class = StockForms.EditStockItemAttachmentForm
|
||||
ajax_form_title = _("Edit Stock Item Attachment")
|
||||
|
||||
def get_form(self):
|
||||
|
||||
form = super().get_form()
|
||||
form.fields['stock_item'].widget = HiddenInput()
|
||||
|
||||
return form
|
||||
|
||||
|
||||
class StockItemAttachmentDelete(AjaxDeleteView):
|
||||
"""
|
||||
View for deleting a StockItemAttachment object.
|
||||
|
Loading…
x
Reference in New Issue
Block a user