gestioCOF/journaldecaisse/views.py

37 lines
986 B
Python
Raw Normal View History

2020-02-16 18:37:16 +01:00
from django.http import HttpResponse
2020-02-18 18:25:54 +01:00
from .models import JournalEntry, Produit
2020-02-17 11:40:58 +01:00
from django.shortcuts import render
2020-02-18 18:25:54 +01:00
from django.http import JsonResponse
2020-02-16 18:37:16 +01:00
def index(request):
2020-02-17 11:40:58 +01:00
entry_list = JournalEntry.objects.order_by('entry_date')
context = {'entry_list': entry_list}
2020-02-18 18:25:54 +01:00
return render(request, 'journaldecaisse/index.html', context)
def vente(request):
product_list = Produit.objects.all().values_list()
products = []
for elem in product_list:
products.append(elem[1])
products = list(set(products))
context = {"product_list" : products}
return render(request, 'journaldecaisse/vente.html', context)
def iterate_options(request):
options_selected = request.GET.get('option', None)
options_selected = options_selected.split(":")
print(options_selected)
test = Produit.objects.filter(**{ options_selected[0] : options_selected[1] })
print(test)
data = {
'is_taken': None
}
return JsonResponse(data)