mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Replace PartAttachmentEdit view
This commit is contained in:
parent
238dccc071
commit
b946aedb5c
@ -232,6 +232,15 @@ class PartAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class PartAttachmentDetail(generics.RetrieveUpdateDestroyAPIView, AttachmentMixin):
|
||||||
|
"""
|
||||||
|
Detail endpoint for PartAttachment model
|
||||||
|
"""
|
||||||
|
|
||||||
|
queryset = PartAttachment.objects.all()
|
||||||
|
serializer_class = part_serializers.PartAttachmentSerializer
|
||||||
|
|
||||||
|
|
||||||
class PartTestTemplateList(generics.ListCreateAPIView):
|
class PartTestTemplateList(generics.ListCreateAPIView):
|
||||||
"""
|
"""
|
||||||
API endpoint for listing (and creating) a PartTestTemplate.
|
API endpoint for listing (and creating) a PartTestTemplate.
|
||||||
@ -1032,6 +1041,7 @@ part_api_urls = [
|
|||||||
|
|
||||||
# Base URL for PartAttachment API endpoints
|
# Base URL for PartAttachment API endpoints
|
||||||
url(r'^attachment/', include([
|
url(r'^attachment/', include([
|
||||||
|
url(r'^(?P<pk>\d+)/', PartAttachmentDetail.as_view(), name='api-part-attachment-detail'),
|
||||||
url(r'^$', PartAttachmentList.as_view(), name='api-part-attachment-list'),
|
url(r'^$', PartAttachmentList.as_view(), name='api-part-attachment-list'),
|
||||||
])),
|
])),
|
||||||
|
|
||||||
|
@ -56,10 +56,16 @@
|
|||||||
$("#attachment-table").on('click', '.attachment-edit-button', function() {
|
$("#attachment-table").on('click', '.attachment-edit-button', function() {
|
||||||
var button = $(this);
|
var button = $(this);
|
||||||
|
|
||||||
var url = `/part/attachment/${button.attr('pk')}/edit/`;
|
var pk = button.attr('pk');
|
||||||
|
|
||||||
launchModalForm(url,
|
var url = `/api/part/attachment/${pk}/`;
|
||||||
{
|
|
||||||
|
constructForm(url, {
|
||||||
|
fields: {
|
||||||
|
attachment: {},
|
||||||
|
comment: {},
|
||||||
|
},
|
||||||
|
title: '{% trans "Edit Attachment" %}',
|
||||||
reload: true,
|
reload: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -18,7 +18,6 @@ part_related_urls = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
part_attachment_urls = [
|
part_attachment_urls = [
|
||||||
url(r'^(?P<pk>\d+)/edit/?', views.PartAttachmentEdit.as_view(), name='part-attachment-edit'),
|
|
||||||
url(r'^(?P<pk>\d+)/delete/?', views.PartAttachmentDelete.as_view(), name='part-attachment-delete'),
|
url(r'^(?P<pk>\d+)/delete/?', views.PartAttachmentDelete.as_view(), name='part-attachment-delete'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -154,27 +154,6 @@ class PartRelatedDelete(AjaxDeleteView):
|
|||||||
role_required = 'part.change'
|
role_required = 'part.change'
|
||||||
|
|
||||||
|
|
||||||
class PartAttachmentEdit(AjaxUpdateView):
|
|
||||||
""" View for editing a PartAttachment object """
|
|
||||||
|
|
||||||
model = PartAttachment
|
|
||||||
form_class = part_forms.EditPartAttachmentForm
|
|
||||||
ajax_template_name = 'modal_form.html'
|
|
||||||
ajax_form_title = _('Edit attachment')
|
|
||||||
|
|
||||||
def get_data(self):
|
|
||||||
return {
|
|
||||||
'success': _('Part attachment updated')
|
|
||||||
}
|
|
||||||
|
|
||||||
def get_form(self):
|
|
||||||
form = super(AjaxUpdateView, self).get_form()
|
|
||||||
|
|
||||||
form.fields['part'].widget = HiddenInput()
|
|
||||||
|
|
||||||
return form
|
|
||||||
|
|
||||||
|
|
||||||
class PartAttachmentDelete(AjaxDeleteView):
|
class PartAttachmentDelete(AjaxDeleteView):
|
||||||
""" View for deleting a PartAttachment """
|
""" View for deleting a PartAttachment """
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ enableDragAndDrop(
|
|||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
stock_item: {{ item.id }},
|
stock_item: {{ item.id }},
|
||||||
user: {{ user.pk }},
|
|
||||||
},
|
},
|
||||||
label: 'attachment',
|
label: 'attachment',
|
||||||
success: function(data, status, xhr) {
|
success: function(data, status, xhr) {
|
||||||
@ -47,10 +46,6 @@ $("#new-attachment").click(function() {
|
|||||||
value: {{ item.pk }},
|
value: {{ item.pk }},
|
||||||
hidden: true,
|
hidden: true,
|
||||||
},
|
},
|
||||||
user: {
|
|
||||||
value: {{ user.pk }},
|
|
||||||
hidden: true,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
reload: true,
|
reload: true,
|
||||||
title: '{% trans "Add Attachment" %}',
|
title: '{% trans "Add Attachment" %}',
|
||||||
|
Loading…
Reference in New Issue
Block a user