You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.4 KiB
Python
62 lines
1.4 KiB
Python
from django.shortcuts import render, get_object_or_404
|
|
from django.utils import timezone
|
|
from datetime import timedelta
|
|
from .models import *
|
|
from django.http import JsonResponse, HttpResponse
|
|
from django.template.loader import get_template
|
|
|
|
|
|
# LISTING
|
|
def items(request, *args, **kwargs):
|
|
products = Item.objects.filter(type='Product').order_by('-id')
|
|
services = Item.objects.filter(type='Service').order_by('-id')
|
|
context = {
|
|
'products': products,
|
|
'services': services,
|
|
|
|
}
|
|
return render(request, 'listing_pages/items.html', context)
|
|
|
|
|
|
def orders(request, *args, **kwargs):
|
|
orders = Order.objects.all().order_by('-id')
|
|
context = {
|
|
'orders': orders,
|
|
}
|
|
return render(request, 'listing_pages/orders.html', context)
|
|
|
|
|
|
def invoices(request, *args, **kwargs):
|
|
invoices = Invoice.objects.all().order_by('-id')
|
|
|
|
context = {
|
|
'invoices': invoices,
|
|
}
|
|
|
|
return render(request, 'listing_pages/invoices.html', context)
|
|
|
|
|
|
#DETAILS
|
|
def invoice_details(request, order_id):
|
|
order = get_object_or_404(Order, id=order_id)
|
|
|
|
context = {
|
|
'order' : order,
|
|
}
|
|
|
|
return render(request, 'details_templates/invoice-details.html', context)
|
|
|
|
|
|
def order_details(request, order_id):
|
|
order = get_object_or_404(Order, id=order_id)
|
|
|
|
context = {
|
|
'order' : order,
|
|
}
|
|
|
|
return render(request, 'details_templates/order-details.html', context)
|
|
|
|
|
|
|
|
|