2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

More API / JSON stuff

- SupplierPart JSON API
- Part supplier list
- Company part list
This commit is contained in:
Oliver
2018-05-03 00:47:03 +10:00
parent 49287c0c61
commit f995f54390
5 changed files with 139 additions and 48 deletions

View File

@ -3,7 +3,19 @@ from rest_framework import serializers
from .models import Company
class CompanySerializer(serializers.HyperlinkedModelSerializer):
class CompanyBriefSerializer(serializers.ModelSerializer):
url = serializers.CharField(source='get_absolute_url', read_only=True)
class Meta:
model = Company
fields = [
'pk',
'url',
'name'
]
class CompanySerializer(serializers.ModelSerializer):
url = serializers.CharField(source='get_absolute_url', read_only=True)

View File

@ -6,29 +6,7 @@
<h3>Company Parts</h3>
<table class='table table-striped' id='part-list' data-sorting='true' data-filtering='true'>
<thead>
<tr>
<th>SKU</th>
<th>Part</th>
<th>MPN</th>
<th>URL</th>
</tr>
</thead>
<tbody>
{% for part in company.parts.all %}
<tr>
<td><a href="{% url 'supplier-part-detail' part.id %}">{{ part.SKU }}</a></td>
<td>
{% if part.part %}
<a href="{% url 'part-suppliers' part.part.id %}">{{ part.part.name }}</a>
{% endif %}
</td>
<td>{{ part.manufacturer_string }}</td>
<td>{{ part.URL }}</td>
</tr>
{% endfor %}
</tbody>
<table clas='table table-striped table-condensed' id='part-table'>
</table>
<div class='container-fluid'>
@ -43,7 +21,7 @@
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
{% endblock %}
{% block js_ready %}
$("#part-create").click(function () {
launchModalForm("#modal-form",
"{% url 'supplier-part-create' %}",
@ -54,4 +32,39 @@
reload: true,
});
});
$("#part-table").bootstrapTable({
sortable: true,
search: true,
queryParams: function(p) {
return {
supplier: {{ company.id }}
}
},
columns: [
{
sortable: true,
field: 'part',
title: 'Part',
formatter: function(value, row, index, field) {
return renderLink(value.name, value.url);
}
},
{
sortable: true,
field: 'SKU',
title: 'SKU',
formatter: function(value, row, index, field) {
return renderLink(value, row.url);
}
},
{
sortable: true,
field: 'manufacturer',
title: 'Manufacturer',
}
],
url: "{% url 'api-part-supplier-list' %}"
});
{% endblock %}