Simple supplier template

This commit is contained in:
Oliver Walters 2017-03-27 22:05:35 +11:00
parent ffcd56d5ba
commit abe0bbf2e4
5 changed files with 18 additions and 5 deletions

View File

@ -4,10 +4,10 @@ from . import views
urlpatterns = [
# Display part detail
url(r'^(?P<part_id>[0-9]+)/$', views.partdetail, name='detail'),
url(r'^(?P<part_id>[0-9]+)/$', views.partDetail, name='detail'),
# Display a list of top-level categories
url(r'^category/$', views.categorylist, name='categorylist'),
url(r'^category/$', views.categoryList, name='categorylist'),
# Display a single part category
url(r'^category/(?P<category_id>[0-9]+)/$', views.category, name='category'),

View File

@ -6,14 +6,14 @@ from .models import PartCategory, Part
def index(request):
return HttpResponse("Hello world. This is the parts page")
def partdetail(request, part_id):
def partDetail(request, part_id):
part = get_object_or_404(Part, pk=part_id)
return render(request, 'part/detail.html',
{'part': part})
def categorylist(request):
def categoryList(request):
categories = PartCategory.objects.filter(parent = None)
return render(request, 'part/categorylist.html',

View File

@ -0,0 +1 @@
{{ supplier }}

View File

@ -3,5 +3,9 @@ from django.conf.urls import url
from . import views
urlpatterns = [
# Display details of a supplier
url(r'^(?P<supplier_id>[0-9]+)/$', views.supplierDetail, name='detail'),
url(r'^$', views.index, name='index')
]

View File

@ -1,5 +1,13 @@
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse
from .models import Supplier
def index(request):
return HttpResponse("This is the suppliers page")
return HttpResponse("This is the suppliers page")
def supplierDetail(request, supplier_id):
supplier = get_object_or_404(Supplier, pk=supplier_id)
return render(request, 'supplier/detail.html',
{'supplier': supplier})