InvenTree/InvenTree/part/views.py

34 lines
958 B
Python
Raw Normal View History

from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse
from .models import PartCategory, Part
def index(request):
return HttpResponse("Hello world. This is the parts page")
2017-03-27 11:05:35 +00:00
def partDetail(request, part_id):
part = get_object_or_404(Part, pk=part_id)
return render(request, 'part/detail.html',
{'part': part})
2017-03-27 11:05:35 +00:00
def categoryList(request):
categories = PartCategory.objects.filter(parent = None)
return render(request, 'part/categorylist.html',
{'categories': categories
})
def category(request, category_id):
# Find the category
cat = get_object_or_404(PartCategory, pk=category_id)
2017-03-25 23:23:22 +00:00
# Child categories
childs = PartCategory.objects.filter(parent = cat.pk)
return render(request, 'part/category.html',
2017-03-25 23:23:22 +00:00
{'category': cat,
'children': childs
})