diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 6a7ae7bdfd..8c0cf494be 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -13,7 +13,6 @@ from django.contrib.auth import views as auth_views from company.urls import company_urls from company.urls import manufacturer_part_urls from company.urls import supplier_part_urls -from company.urls import price_break_urls from common.urls import common_urls from part.urls import part_urls @@ -126,7 +125,6 @@ urlpatterns = [ url(r'^part/', include(part_urls)), url(r'^manufacturer-part/', include(manufacturer_part_urls)), url(r'^supplier-part/', include(supplier_part_urls)), - url(r'^price-break/', include(price_break_urls)), # "Dynamic" javascript files which are rendered using InvenTree templating. url(r'^dynamic/', include(dynamic_javascript_urls)), diff --git a/InvenTree/company/api.py b/InvenTree/company/api.py index 16887414de..6eac0339fa 100644 --- a/InvenTree/company/api.py +++ b/InvenTree/company/api.py @@ -394,6 +394,15 @@ class SupplierPriceBreakList(generics.ListCreateAPIView): ] +class SupplierPriceBreakDetail(generics.RetrieveUpdateDestroyAPIView): + """ + Detail endpoint for SupplierPriceBreak object + """ + + queryset = SupplierPriceBreak.objects.all() + serializer_class = SupplierPriceBreakSerializer + + manufacturer_part_api_urls = [ url(r'^parameter/', include([ @@ -424,7 +433,12 @@ company_api_urls = [ url(r'^part/', include(supplier_part_api_urls)), - url(r'^price-break/', SupplierPriceBreakList.as_view(), name='api-part-supplier-price-list'), + # Supplier price breaks + url(r'^price-break/', include([ + + url(r'^(?P\d+)/?', SupplierPriceBreakDetail.as_view(), name='api-part-supplier-price-detail'), + url(r'^.*$', SupplierPriceBreakList.as_view(), name='api-part-supplier-price-list'), + ])), url(r'^(?P\d+)/?', CompanyDetail.as_view(), name='api-company-detail'), diff --git a/InvenTree/company/templates/company/supplier_part_pricing.html b/InvenTree/company/templates/company/supplier_part_pricing.html index 5d2d0c5e31..a476b53a13 100644 --- a/InvenTree/company/templates/company/supplier_part_pricing.html +++ b/InvenTree/company/templates/company/supplier_part_pricing.html @@ -46,23 +46,25 @@ $('#price-break-table').inventreeTable({ table.find('.button-price-break-delete').click(function() { var pk = $(this).attr('pk'); - launchModalForm( - `/price-break/${pk}/delete/`, - { - success: reloadPriceBreaks - } - ); + constructForm(`/api/company/price-break/${pk}/`, { + method: 'DELETE', + onSuccess: reloadPriceBreaks, + title: '{% trans "Delete Price Break" %}', + }); }); table.find('.button-price-break-edit').click(function() { var pk = $(this).attr('pk'); - launchModalForm( - `/price-break/${pk}/edit/`, - { - success: reloadPriceBreaks - } - ); + constructForm(`/api/company/price-break/${pk}/`, { + fields: { + quantity: {}, + price: {}, + price_currency: {}, + }, + onSuccess: reloadPriceBreaks, + title: '{% trans "Edit Price Break" %}', + }); }); }, columns: [ @@ -114,7 +116,7 @@ $('#new-price-break').click(function() { }, }, title: '{% trans "Add Price Break" %}', - reload: true + onSuccess: reloadPriceBreaks, } ); }); diff --git a/InvenTree/company/urls.py b/InvenTree/company/urls.py index 840f95b771..47a57d1df0 100644 --- a/InvenTree/company/urls.py +++ b/InvenTree/company/urls.py @@ -39,12 +39,6 @@ company_urls = [ url(r'^.*$', views.CompanyIndex.as_view(), name='company-index'), ] -price_break_urls = [ - - url(r'^(?P\d+)/edit/', views.PriceBreakEdit.as_view(), name='price-break-edit'), - url(r'^(?P\d+)/delete/', views.PriceBreakDelete.as_view(), name='price-break-delete'), -] - manufacturer_part_urls = [ url(r'^new/?', views.ManufacturerPartCreate.as_view(), name='manufacturer-part-create'), diff --git a/InvenTree/company/views.py b/InvenTree/company/views.py index cc046173f9..67c4e45a2e 100644 --- a/InvenTree/company/views.py +++ b/InvenTree/company/views.py @@ -759,27 +759,3 @@ class SupplierPartDelete(AjaxDeleteView): part.delete() return self.renderJsonResponse(self.request, data=data, form=self.get_form()) - - -class PriceBreakEdit(AjaxUpdateView): - """ View for editing a supplier price break """ - - model = SupplierPriceBreak - form_class = EditPriceBreakForm - ajax_form_title = _('Edit Price Break') - ajax_template_name = 'modal_form.html' - - def get_form(self): - - form = super(AjaxUpdateView, self).get_form() - form.fields['part'].widget = HiddenInput() - - return form - - -class PriceBreakDelete(AjaxDeleteView): - """ View for deleting a supplier price break """ - - model = SupplierPriceBreak - ajax_form_title = _("Delete Price Break") - ajax_template_name = 'modal_delete_form.html'