Fix bookview gets either any currency or any type

This commit is contained in:
Reckless_Satoshi 2022-01-09 13:54:13 -08:00
parent c08c76b7d8
commit a518daf8cc
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 10 additions and 4 deletions

View File

@ -1,3 +1,4 @@
from re import T
from rest_framework import status, viewsets from rest_framework import status, viewsets
from rest_framework.generics import CreateAPIView, ListAPIView from rest_framework.generics import CreateAPIView, ListAPIView
from rest_framework.views import APIView from rest_framework.views import APIView
@ -349,9 +350,14 @@ class BookView(ListAPIView):
currency = request.GET.get('currency') currency = request.GET.get('currency')
type = request.GET.get('type') type = request.GET.get('type')
queryset = Order.objects.filter(status=Order.Status.PUB) queryset = Order.objects.filter(status=Order.Status.PUB)
# Currency 0 and type 2 are special cases treated as "ANY". They are not possible choices.
if not (int(currency) == 0 and int(type) == 2): # Currency 0 and type 2 are special cases treated as "ANY". (These are not really possible choices)
if int(currency) == 0 and int(type) != 2:
queryset = Order.objects.filter(type=type, status=Order.Status.PUB)
elif int(type) == 2 and int(currency) != 0:
queryset = Order.objects.filter(currency=currency, status=Order.Status.PUB)
elif not (int(currency) == 0 and int(type) == 2):
queryset = Order.objects.filter(currency=currency, type=type, status=Order.Status.PUB) queryset = Order.objects.filter(currency=currency, type=type, status=Order.Status.PUB)
if len(queryset)== 0: if len(queryset)== 0:

View File

@ -8,7 +8,7 @@ export default class BookPage extends Component {
this.state = { this.state = {
orders: new Array(), orders: new Array(),
currency: 0, currency: 0,
type: 2, type: 1,
currencies_dict: {"0":"ANY"} currencies_dict: {"0":"ANY"}
}; };
this.getCurrencyDict() this.getCurrencyDict()