2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-09 15:10:54 +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

@ -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 %}
<ul>
<li>Name: {{ supplier.name }}</li>
<li>Description: {{ supplier.description }}</li>
<li>Website: {{ supplier.website }}</li>
<li>Contact: {{ supplier.contact }}</li>
</li>
<div class="row">
<div class="col-sm-6">
<h3>{{ supplier.name }}</h3>
<p>{{ supplier.description }}</p>
</div>
<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 %}
<table>
<table class="table table-striped">
<tr>
<th>Part</th>
<th>SKU</th>
<th>Part</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><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>MPN goes here</td>
<td>{{ part.URL }}</td>

View File

@ -2,18 +2,21 @@
{% block content %}
<table>
<tr>
<th>Supplier</th>
<th>Description</th>
<th>URL</th>
</tr>
<h3>Suppliers</h3>
<ul class='list-group'>
{% 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>
<li class='list-group-item'>
<b><a href="{% url 'supplier-detail' supplier.id %}">{{ supplier.name }}</a></b>
<br>
{{ supplier.description }}
{% if supplier.website %}
<a href="{{ supplier.website }}">- {{ supplier.website }}</a>
{% endif %}
<span class="badge">
{{ supplier.parts.all|length }}
</span>
</li>
{% endfor %}
</ul>
{% 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 . import views
from . import api
"""
cust_urls = [
# 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())
]
"""
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 = [
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'),
url(r'^(?P<pk>\d+)/', include(supplier_detail_urls)),
url(r'', views.SupplierIndex.as_view(), name='supplier-index'),
# Redirect any other patterns
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.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
def index(request):
""" The supplier index page simply displays all the suppliers
"""
class SupplierIndex(ListView):
model = Supplier
template_name = 'supplier/index.html'
context_object_name = 'suppliers'
paginate_by = 50
suppliers = Supplier.objects.order_by('name')
return render(request, 'supplier/index.html', {'suppliers' : suppliers})
def get_queryset(self):
return Supplier.objects.order_by('name')
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})
class SupplierDetail(DetailView):
context_obect = 'supplier'
template_name = 'supplier/detail.html'
queryset = Supplier.objects.all()
def partDetail(request, pk):