Merge branch 'diego' into development

This commit is contained in:
Sam
2021-03-17 10:18:07 +00:00
2 changed files with 5 additions and 4 deletions

View File

@@ -144,7 +144,7 @@ def ranked_product_search(keyword, shipping_cost=None, discount=None, category=N
# filter by category # filter by category
if category is not None: if category is not None:
products_qs = products_qs.filter(category=category) products_qs = products_qs.filter(category__name__in=category)
# filter by tags # filter by tags
if tags is not None: if tags is not None:

View File

@@ -161,7 +161,8 @@ def product_search(request):
discount = False discount = False
else: else:
discount = None discount = None
category = request.GET.get('category', None) # category = request.GET.get('category', None)
category = request.query_params.getlist('category[]') or None
tags = request.GET.get('tags', None) tags = request.GET.get('tags', None)
price_min = request.GET.get('price_min', None) price_min = request.GET.get('price_min', None)
price_max = request.GET.get('price_max', None) price_max = request.GET.get('price_max', None)
@@ -185,7 +186,7 @@ def product_search(request):
if tags: if tags:
products_qs = Product.objects.filter(tags=tags) products_qs = Product.objects.filter(tags=tags)
if category: if category:
products_qs = Product.objects.filter(category=category) products_qs = Product.objects.filter(category__name__in=category)
# serialize and list data # serialize and list data
serializer = ProductSerializer(products_qs, many=True) serializer = ProductSerializer(products_qs, many=True)
result_list = [dict(i) for i in serializer.data] result_list = [dict(i) for i in serializer.data]
@@ -290,7 +291,7 @@ def purchase_email(request):
return Response({"error": "Invalid value for product"}, status=status.HTTP_406_NOT_ACCEPTABLE) return Response({"error": "Invalid value for product"}, status=status.HTTP_406_NOT_ACCEPTABLE)
# check company.email # check company.email
if company.email is None: if company.email is None:
return Response({"error": "Related compay has no contact email address"}, status=status.HTTP_406_NOT_ACCEPTABLE) company.email = managing_user.email
try: try:
# send email to company # send email to company
company_message = render_to_string('purchase_notification_v2.html', { company_message = render_to_string('purchase_notification_v2.html', {