|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
from django.http import JsonResponse |
|
|
|
|
from django.shortcuts import render |
|
|
|
|
from store.models import Product, Category |
|
|
|
|
from store.models import Product, Category, ProductVariation |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def index(request): |
|
|
|
|
@ -41,3 +42,21 @@ def size_sargan(request): |
|
|
|
|
def size_omer_sporasub(request): |
|
|
|
|
return render(request, 'size/omer_sporasub.jinja') |
|
|
|
|
|
|
|
|
|
def temp_count_update(request, article): |
|
|
|
|
retval = dict(error_code=0) |
|
|
|
|
try: |
|
|
|
|
product = ProductVariation.objects.get(article__iexact=article) |
|
|
|
|
count = request.GET.get('count', None) |
|
|
|
|
if count != None: |
|
|
|
|
if int(count) < 0: |
|
|
|
|
count = 0 |
|
|
|
|
product.in_stock = int(count) |
|
|
|
|
product.save() |
|
|
|
|
else: |
|
|
|
|
retval['error_code'] = 1 |
|
|
|
|
except ProductVariation.DoesNotExist: |
|
|
|
|
retval['error_code'] = 1 |
|
|
|
|
except Exception as e: |
|
|
|
|
retval['error_code'] = e |
|
|
|
|
return JsonResponse(retval) |
|
|
|
|
|
|
|
|
|
|