2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 12:06:44 +00:00

Improved list and detail views for supplier

Huzzah for bootstrap
This commit is contained in:
Oliver 2018-04-15 13:49:47 +10:00
parent 9e6c7350f9
commit 8232baeed7
17 changed files with 201 additions and 84 deletions

View File

@ -15,7 +15,7 @@ class Company(models.Model):
abstract = True abstract = True
name = models.CharField(max_length=100, unique=True) name = models.CharField(max_length=100, unique=True)
description = models.CharField(max_length=500, blank=True) description = models.CharField(max_length=500)
website = models.URLField(blank=True) website = models.URLField(blank=True)
address = models.CharField(max_length=200, address = models.CharField(max_length=200,
blank=True) blank=True)
@ -43,7 +43,7 @@ class InvenTreeTree(models.Model):
name = models.CharField(max_length=100, unique=True) name = models.CharField(max_length=100, unique=True)
description = models.CharField(max_length=250, blank=True) description = models.CharField(max_length=250)
# When a category is deleted, graft the children onto its parent # When a category is deleted, graft the children onto its parent
parent = models.ForeignKey('self', parent = models.ForeignKey('self',

View File

@ -11,7 +11,7 @@ from part.urls import part_urls
from stock.urls import stock_api_urls, stock_api_loc_urls from stock.urls import stock_api_urls, stock_api_loc_urls
from stock.urls import stock_urls from stock.urls import stock_urls
from supplier.urls import supplier_api_urls, supplier_api_part_urls #from supplier.urls import supplier_api_urls, supplier_api_part_urls
from supplier.urls import supplier_urls from supplier.urls import supplier_urls
from django.conf import settings from django.conf import settings
@ -46,8 +46,8 @@ apipatterns = [
url(r'^bom/', include(bom_api_urls)), url(r'^bom/', include(bom_api_urls)),
# Supplier URLs # Supplier URLs
url(r'^supplier/', include(supplier_api_urls)), #url(r'^supplier/', include(supplier_api_urls)),
url(r'^supplier-part/', include(supplier_api_part_urls)), #url(r'^supplier-part/', include(supplier_api_part_urls)),
#url(r'^price-break/', include(price_break_urls)), #url(r'^price-break/', include(price_break_urls)),
#url(r'^manufacturer/', include(manu_urls)), #url(r'^manufacturer/', include(manu_urls)),
#url(r'^customer/', include(cust_urls)), #url(r'^customer/', include(cust_urls)),
@ -69,15 +69,14 @@ apipatterns = [
urlpatterns = [ urlpatterns = [
# API URL # API URL
url(r'^api/', include(apipatterns)), #url(r'^api/', include(apipatterns)),
#url(r'^api-doc/', include_docs_urls(title='InvenTree API')),
url(r'^part/', include(part_urls)), url(r'^part/', include(part_urls)),
url(r'^stock/', include(stock_urls)), url(r'^stock/', include(stock_urls)),
url(r'^supplier/', include(supplier_urls)), url(r'^supplier/', include(supplier_urls)),
url(r'^track/', include(tracking_urls)), url(r'^track/', include(tracking_urls)),
url(r'^api-doc/', include_docs_urls(title='InvenTree API')),
url(r'^admin/', admin.site.urls), url(r'^admin/', admin.site.urls),
url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')),
] ]

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-04-15 03:02
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('part', '0014_auto_20180415_0107'),
]
operations = [
migrations.AlterField(
model_name='partcategory',
name='description',
field=models.CharField(max_length=250),
),
]

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-04-15 03:16
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('part', '0015_auto_20180415_0302'),
]
operations = [
migrations.AlterField(
model_name='part',
name='description',
field=models.CharField(max_length=250),
),
]

View File

@ -88,7 +88,7 @@ class Part(models.Model):
name = models.CharField(max_length=100, unique=True) name = models.CharField(max_length=100, unique=True)
# Longer description of the part (optional) # Longer description of the part (optional)
description = models.CharField(max_length=250, blank=True) description = models.CharField(max_length=250)
# Internal Part Number (optional) # Internal Part Number (optional)
# Potentially multiple parts map to the same internal IPN (variants?) # Potentially multiple parts map to the same internal IPN (variants?)

View File

@ -6,7 +6,7 @@
<a class="navbar-brand" href="/"><img src="{% static 'img/inventree.png' %}" width="40" height="40"/></a> <a class="navbar-brand" href="/"><img src="{% static 'img/inventree.png' %}" width="40" height="40"/></a>
</div> </div>
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li class="active"><a href="/part/">Parts</a></li> <li><a href="/part/">Parts</a></li>
<li><a href="/stock/">Stock</a></li> <li><a href="/stock/">Stock</a></li>
<li><a href="/supplier/">Suppliers</a></li> <li><a href="/supplier/">Suppliers</a></li>
<li><a href="/track/">Tracking</a></li> <li><a href="/track/">Tracking</a></li>

View File

@ -6,6 +6,11 @@
{% include "part/cat_link.html" with category=category %} {% include "part/cat_link.html" with category=category %}
<p>
<b>{{ category.name }}</b><br>
<i>{{ category.description }}</i>
</p>
{% include "part/category_subcategories.html" with children=category.children.all %} {% include "part/category_subcategories.html" with children=category.children.all %}
{% include "part/category_parts.html" with parts=category.parts.all %} {% include "part/category_parts.html" with parts=category.parts.all %}

View File

@ -1,10 +1,15 @@
{% if parts|length > 0 %} {% if parts|length > 0 %}
Parts: Parts:
<ul class="list-group"> <table class="table table-striped">
<tr>
<th>Part</th>
<th>Description</th>
</tr>
{% for part in parts %} {% for part in parts %}
<li class="list-group-item"> <tr>
<a href="{% url 'part-detail' part.id %}">{{ part.name }}</a> - {{ part.description }} <td><a href="{% url 'part-detail' part.id %}">{{ part.name }}</a></td>
</li> <td>{{ part.description }}</td>
</tr>
{% endfor %} {% endfor %}
</ul> </table>
{% endif %} {% endif %}

View File

@ -3,7 +3,10 @@ Subcategories:
<ul class="list-group"> <ul class="list-group">
{% for child in children %} {% for child in children %}
<li class="list-group-item"> <li class="list-group-item">
<a href="{% url 'category-detail' child.id %}">{{ child.name }}</a> - {{ child.description }} <b><a href="{% url 'category-detail' child.id %}">{{ child.name }}</a></b>
{% if child.description %}
<i> - {{ child.description }}</i>
{% endif %}
<span class='badge'>{{ child.partcount }}</span> <span class='badge'>{{ child.partcount }}</span>
</li> </li>
{% endfor %} {% endfor %}

View File

@ -16,7 +16,7 @@
{% endif %}/> {% endif %}/>
</div> </div>
<div class="media-body"> <div class="media-body">
<h5>{{ part.name }}</h5> <h4>{{ part.name }}</h4>
{% if part.description %} {% if part.description %}
<p><i>{{ part.description }}</i></p> <p><i>{{ part.description }}</i></p>
{% endif %} {% endif %}

View File

@ -1,30 +1,3 @@
table, th, td {
border: 1px solid black;
border-collapse: collapse;
margin-left: 5px;
margin-right: 5px;
margin-top: 10px;
margin-bottom: 10px;
}
th, td {
padding-top: 5px;
padding-bottom: 5px;
padding-left: 10px;
padding-right: 10px;
}
th {
text-align: left;
}
table tr:nth-child(even) {
background-color: #eee;
}
table tr:nth-child(odd) {
background-color: #fff;
}
.navbar-brand { .navbar-brand {
float: left; float: left;
} }

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-04-15 03:02
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('stock', '0005_auto_20180415_0107'),
]
operations = [
migrations.AlterField(
model_name='stocklocation',
name='description',
field=models.CharField(max_length=250),
),
]

View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-04-15 02:55
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('supplier', '0004_auto_20180414_0624'),
]
operations = [
migrations.AlterField(
model_name='customer',
name='description',
field=models.CharField(max_length=500),
),
migrations.AlterField(
model_name='manufacturer',
name='description',
field=models.CharField(max_length=500),
),
migrations.AlterField(
model_name='supplier',
name='description',
field=models.CharField(max_length=500),
),
]

View File

@ -2,26 +2,55 @@
{% block content %} {% block content %}
<ul> <div class="row">
<li>Name: {{ supplier.name }}</li> <div class="col-sm-6">
<li>Description: {{ supplier.description }}</li> <h3>{{ supplier.name }}</h3>
<li>Website: {{ supplier.website }}</li> <p>{{ supplier.description }}</p>
<li>Contact: {{ supplier.contact }}</li> </div>
</li> <div class="col-sm-6">
<table class="table">
{% if supplier.website %}
<tr>
<td>Website</td><td><a href="{{ supplier.website }}">{{ supplier.website }}</a></td>
</tr>
{% endif %}
{% if supplier.address %}
<tr>
<td>Address</td><td>{{ supplier.address }}</td>
</tr>
{% endif %}
{% if supplier.phone %}
<tr>
<td>Phone</td><td>{{ supplier.phone }}</td>
</tr>
{% endif %}
{% if supplier.email %}
<tr>
<td>Email</td><td>{{ supplier.email }}</td>
</tr>
{% endif %}
{% if supplier.contact %}
<tr>
<td>Contact</td><td>{{ supplier.contact }}</td>
</tr>
{% endif %}
</table>
</div>
</div>
{% if supplier.parts.all|length > 0 %} {% if supplier.parts.all|length > 0 %}
<table> <table class="table table-striped">
<tr> <tr>
<th>Part</th>
<th>SKU</th> <th>SKU</th>
<th>Part</th>
<th>Manufacturer</th> <th>Manufacturer</th>
<th>MPN</th> <th>MPN</th>
<th>URL</th> <th>URL</th>
</tr> </tr>
{% for part in supplier.parts.all %} {% for part in supplier.parts.all %}
<tr> <tr>
<td><a href="{% url 'part-detail' part.part.id %}">{{ part.part.name }}</a></td>
<td><a href="{% url 'supplier-part-detail' part.id %}">{{ part.SKU }}</a></td> <td><a href="{% url 'supplier-part-detail' part.id %}">{{ part.SKU }}</a></td>
<td><a href="{% url 'part-detail' part.part.id %}">{{ part.part.name }}</a></td>
<td>Manufacturer name goes here</td> <td>Manufacturer name goes here</td>
<td>MPN goes here</td> <td>MPN goes here</td>
<td>{{ part.URL }}</td> <td>{{ part.URL }}</td>

View File

@ -2,18 +2,21 @@
{% block content %} {% block content %}
<table> <h3>Suppliers</h3>
<tr> <ul class='list-group'>
<th>Supplier</th>
<th>Description</th>
<th>URL</th>
</tr>
{% for supplier in suppliers %} {% for supplier in suppliers %}
<tr> <li class='list-group-item'>
<td><a href="{% url 'supplier-detail' supplier.id %}">{{ supplier.name }}</a></td> <b><a href="{% url 'supplier-detail' supplier.id %}">{{ supplier.name }}</a></b>
<td>{{ supplier.description }}</td> <br>
<td>{{ supplier.website }}</td> {{ supplier.description }}
</tr> {% if supplier.website %}
<a href="{{ supplier.website }}">- {{ supplier.website }}</a>
{% endif %}
<span class="badge">
{{ supplier.parts.all|length }}
</span>
</li>
{% endfor %} {% endfor %}
</ul>
{% endblock %} {% endblock %}

View File

@ -1,9 +1,10 @@
from django.conf.urls import url from django.conf.urls import url, include
from django.views.generic.base import RedirectView from django.views.generic.base import RedirectView
from . import views from . import views
from . import api from . import api
"""
cust_urls = [ cust_urls = [
# Customer detail # Customer detail
url(r'^(?P<pk>[0-9]+)/?$', api.CustomerDetail.as_view(), name='customer-detail'), url(r'^(?P<pk>[0-9]+)/?$', api.CustomerDetail.as_view(), name='customer-detail'),
@ -45,11 +46,21 @@ supplier_api_urls = [
url(r'^\?.*/?$', api.SupplierList.as_view()), url(r'^\?.*/?$', api.SupplierList.as_view()),
url(r'^$', api.SupplierList.as_view()) url(r'^$', api.SupplierList.as_view())
] ]
"""
supplier_detail_urls = [
#url(r'edit/?', views.SupplierEdit.as_view(), name='supplier-edit'),
#url(r'delete/?', views.SupplierDelete.as_view(), name='supplier-delete'),
url(r'^.*$', views.SupplierDetail.as_view(), name='supplier-detail'),
]
supplier_urls = [ 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'^part/(?P<pk>\d+)/', views.partDetail, name='supplier-part-detail'),
url(r'', views.index, name='supplier-index'),
url(r'^(?P<pk>\d+)/', include(supplier_detail_urls)),
url(r'', views.SupplierIndex.as_view(), name='supplier-index'),
# Redirect any other patterns # Redirect any other patterns
url(r'^.*$', RedirectView.as_view(url='', permanent=False), name='supplier-index'), url(r'^.*$', RedirectView.as_view(url='', permanent=False), name='supplier-index'),

View File

@ -1,27 +1,26 @@
from django.http import HttpResponse
from django.template import loader
from django.shortcuts import get_object_or_404, render from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.views.generic import DetailView, ListView
from django.views.generic.edit import UpdateView, DeleteView, CreateView
from .models import Supplier, SupplierPart from .models import Supplier, SupplierPart
def index(request): class SupplierIndex(ListView):
""" The supplier index page simply displays all the suppliers model = Supplier
""" template_name = 'supplier/index.html'
context_object_name = 'suppliers'
paginate_by = 50
suppliers = Supplier.objects.order_by('name') def get_queryset(self):
return Supplier.objects.order_by('name')
return render(request, 'supplier/index.html', {'suppliers' : suppliers})
def detail(request, pk): class SupplierDetail(DetailView):
""" The supplier detail page shown detailed information context_obect = 'supplier'
on a particular supplier template_name = 'supplier/detail.html'
""" queryset = Supplier.objects.all()
supplier = get_object_or_404(Supplier, pk=pk)
return render(request, 'supplier/detail.html', {'supplier' : supplier})
def partDetail(request, pk): def partDetail(request, pk):