mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-04 20:51:00 +00:00
Annotate models with their API list view
- It will make sense, trust me
This commit is contained in:
@ -424,7 +424,7 @@ company_api_urls = [
|
||||
|
||||
url(r'^part/', include(supplier_part_api_urls)),
|
||||
|
||||
url(r'^price-break/', SupplierPriceBreakList.as_view(), name='api-part-supplier-price'),
|
||||
url(r'^price-break/', SupplierPriceBreakList.as_view(), name='api-part-supplier-price-list'),
|
||||
|
||||
url(r'^(?P<pk>\d+)/?', CompanyDetail.as_view(), name='api-company-detail'),
|
||||
|
||||
|
@ -84,6 +84,10 @@ class Company(models.Model):
|
||||
currency_code: Specifies the default currency for the company
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_api_url():
|
||||
return reverse('api-company-list')
|
||||
|
||||
class Meta:
|
||||
ordering = ['name', ]
|
||||
constraints = [
|
||||
@ -297,6 +301,10 @@ class ManufacturerPart(models.Model):
|
||||
description: Descriptive notes field
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_api_url():
|
||||
return reverse('api-manufacturer-part-list')
|
||||
|
||||
class Meta:
|
||||
unique_together = ('part', 'manufacturer', 'MPN')
|
||||
|
||||
@ -380,6 +388,10 @@ class ManufacturerPartParameter(models.Model):
|
||||
Each parameter is a simple string (text) value.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_api_url():
|
||||
return reverse('api-manufacturer-part-parameter-list')
|
||||
|
||||
class Meta:
|
||||
unique_together = ('manufacturer_part', 'name')
|
||||
|
||||
@ -432,6 +444,10 @@ class SupplierPart(models.Model):
|
||||
packaging: packaging that the part is supplied in, e.g. "Reel"
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_api_url():
|
||||
return reverse('api-supplier-part-list')
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('supplier-part-detail', kwargs={'pk': self.id})
|
||||
|
||||
@ -660,6 +676,10 @@ class SupplierPriceBreak(common.models.PriceBreak):
|
||||
currency: Reference to the currency of this pricebreak (leave empty for base currency)
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_api_url():
|
||||
return reverse('api-part-supplier-price-list')
|
||||
|
||||
part = models.ForeignKey(SupplierPart, on_delete=models.CASCADE, related_name='pricebreaks', verbose_name=_('Part'),)
|
||||
|
||||
class Meta:
|
||||
|
@ -39,7 +39,7 @@ $('#price-break-table').inventreeTable({
|
||||
queryParams: {
|
||||
part: {{ part.id }},
|
||||
},
|
||||
url: "{% url 'api-part-supplier-price' %}",
|
||||
url: "{% url 'api-part-supplier-price-list' %}",
|
||||
onPostBody: function() {
|
||||
var table = $('#price-break-table');
|
||||
|
||||
|
Reference in New Issue
Block a user