mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-09 15:10:54 +00:00
Added supplier web interface
- Display list of suppliers - Supplier detail page - Supplier part detail page - Part detail now includes list of supplier parts
This commit is contained in:
@ -40,7 +40,10 @@ class SupplierPart(models.Model):
|
||||
part = models.ForeignKey(Part, null=True, blank=True, on_delete=models.CASCADE,
|
||||
related_name='supplier_parts')
|
||||
|
||||
supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE)
|
||||
supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE,
|
||||
related_name = 'parts')
|
||||
|
||||
|
||||
SKU = models.CharField(max_length=100)
|
||||
|
||||
manufacturer = models.ForeignKey(Manufacturer, blank=True, null=True, on_delete=models.CASCADE)
|
||||
|
34
InvenTree/supplier/templates/supplier/detail.html
Normal file
34
InvenTree/supplier/templates/supplier/detail.html
Normal file
@ -0,0 +1,34 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<ul>
|
||||
<li>Name: {{ supplier.name }}</li>
|
||||
<li>Description: {{ supplier.description }}</li>
|
||||
<li>Website: {{ supplier.website }}</li>
|
||||
<li>Contact: {{ supplier.contact }}</li>
|
||||
</li>
|
||||
|
||||
{% if supplier.parts.all|length > 0 %}
|
||||
<table>
|
||||
<tr>
|
||||
<th>Part</th>
|
||||
<th>SKU</th>
|
||||
<th>Manufacturer</th>
|
||||
<th>MPN</th>
|
||||
<th>URL</th>
|
||||
</tr>
|
||||
{% for part in supplier.parts.all %}
|
||||
<tr>
|
||||
<td><a href="{% url 'part-detail' part.part.id %}">{{ part.part.name }}</a></td>
|
||||
<td>{{ part.SKU }}</td>
|
||||
<td>Manufacturer name goes here</td>
|
||||
<td>MPN goes here</td>
|
||||
<td>{{ part.URL }}</td>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
There are currently no parts sourced from this supplier.
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
19
InvenTree/supplier/templates/supplier/index.html
Normal file
19
InvenTree/supplier/templates/supplier/index.html
Normal file
@ -0,0 +1,19 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Supplier</th>
|
||||
<th>Description</th>
|
||||
<th>URL</th>
|
||||
</tr>
|
||||
{% for supplier in suppliers %}
|
||||
<tr>
|
||||
<td><a href="{% url 'supplier-detail' supplier.id %}">{{ supplier.name }}</a></td>
|
||||
<td>{{ supplier.description }}</td>
|
||||
<td>{{ supplier.website }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
14
InvenTree/supplier/templates/supplier/partdetail.html
Normal file
14
InvenTree/supplier/templates/supplier/partdetail.html
Normal file
@ -0,0 +1,14 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<ul>
|
||||
<li>Part: <a href="{% url 'part-detail' part.part.id %}">{{ part.part.name }}</a></li>
|
||||
<li>Supplier: <a href="{% url 'supplier-detail' part.supplier.id %}">{{ part.supplier.name }}</a></li>
|
||||
<li>SKU: {{ part.SKU }}</li>
|
||||
<li>Manufacturer name goes here</li>
|
||||
<li>MPN goes here</li>
|
||||
<li>URL: {{ part.URL }}</li>
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
@ -1,4 +1,5 @@
|
||||
from django.conf.urls import url
|
||||
from django.views.generic.base import RedirectView
|
||||
|
||||
from . import views
|
||||
from . import api
|
||||
@ -21,7 +22,7 @@ manu_urls = [
|
||||
url(r'^$', api.ManufacturerList.as_view())
|
||||
]
|
||||
|
||||
supplier_part_urls = [
|
||||
supplier_api_part_urls = [
|
||||
url(r'^(?P<pk>[0-9]+)/?$', api.SupplierPartDetail.as_view(), name='supplierpart-detail'),
|
||||
|
||||
url(r'^\?.*/?$', api.SupplierPartList.as_view()),
|
||||
@ -35,7 +36,7 @@ price_break_urls = [
|
||||
url(r'^$', api.SupplierPriceBreakList.as_view())
|
||||
]
|
||||
|
||||
supplier_urls = [
|
||||
supplier_api_urls = [
|
||||
|
||||
# Display details of a supplier
|
||||
url(r'^(?P<pk>[0-9]+)/$', api.SupplierDetail.as_view(), name='supplier-detail'),
|
||||
@ -44,3 +45,12 @@ supplier_urls = [
|
||||
url(r'^\?.*/?$', api.SupplierList.as_view()),
|
||||
url(r'^$', api.SupplierList.as_view())
|
||||
]
|
||||
|
||||
supplier_urls = [
|
||||
url(r'^(?P<pk>\d+)/', views.detail, name='supplier-detail'),
|
||||
url(r'^part/(?P<pk>\d+)/', views.partDetail, name='supplier-part-detail'),
|
||||
url(r'', views.index, name='supplier-index'),
|
||||
|
||||
# Redirect any other patterns
|
||||
url(r'^.*$', RedirectView.as_view(url='', permanent=False), name='supplier-index'),
|
||||
]
|
@ -0,0 +1,34 @@
|
||||
from django.http import HttpResponse
|
||||
from django.template import loader
|
||||
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
|
||||
from .models import Supplier, SupplierPart
|
||||
|
||||
def index(request):
|
||||
""" The supplier index page simply displays all the suppliers
|
||||
"""
|
||||
|
||||
suppliers = Supplier.objects.order_by('name')
|
||||
|
||||
return render(request, 'supplier/index.html', {'suppliers' : suppliers})
|
||||
|
||||
|
||||
def detail(request, pk):
|
||||
""" The supplier detail page shown detailed information
|
||||
on a particular supplier
|
||||
"""
|
||||
|
||||
supplier = get_object_or_404(Supplier, pk=pk)
|
||||
|
||||
return render(request, 'supplier/detail.html', {'supplier' : supplier})
|
||||
|
||||
|
||||
def partDetail(request, pk):
|
||||
""" The supplier part-detail page shows detailed information
|
||||
on a particular supplier part
|
||||
"""
|
||||
|
||||
part = get_object_or_404(SupplierPart, pk=pk)
|
||||
|
||||
return render(request, 'supplier/partdetail.html', {'part': part})
|
Reference in New Issue
Block a user