Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Merge branch 'master' of github.com:elwoodxblues/saleor into feature/running-out-products
Marcin Gębalab7da5f0894f7
diff --cc saleor/dashboard/views.pyindex f07f8df478,c553a1561f..1a204b84ee--- a/saleor/dashboard/views.py+++ b/saleor/dashboard/views.py@@@ -56,25 -54,5 +56,23 @@@ class FilterByStatusMixin(object)def index(request):orders_to_ship = Order.objects.filter(status='fully-paid')payments = Payment.objects.filter(status='preauth').order_by('-created')- for payment in payments:- payment.total = Price(payment.total, currency=payment.currency)- ctx = {'preauthorized_payments': payments, 'orders_to_ship': orders_to_ship}++ show_running_out = hasattr(settings, 'STOCKABLE_PRODUCTS')+ running_out = products_running_out() if show_running_out else []++ ctx = {'preauthorized_payments': payments, 'orders_to_ship': orders_to_ship,+ 'show_running_out': show_running_out, 'running_out': running_out}return TemplateResponse(request, 'dashboard/index.html', ctx)+++def products_running_out():+ product_classes = settings.STOCKABLE_PRODUCTS+ try:+ threshold = settings.STOCK_THRESHOLD+ except AttributeError:+ threshold = 10+ products = []+ for cls in product_classes:+ Product = import_string(cls)+ products.extend(Product.objects.filter(stock__lte=threshold))+ return productsdiff --cc saleor/settings.pyindex 5fab3fdaf8,ebe875e855..c765555517--- a/saleor/settings.py+++ b/saleor/settings.py@@@ -229,9 -229,4 +229,11 @@@ MESSAGE_TAGS =messages.ERROR: 'danger',}+STOCKABLE_PRODUCTS = [+ 'saleor.product.models.BagVariant',+ 'saleor.product.models.ShirtVariant'+]++STOCK_THRESHOLD = 10+++ TEST_RUNNER = ''