Improve support for stock providers

This commit is contained in:
s3lph 2021-04-07 01:25:45 +02:00
parent 119ed38f28
commit 361144815e
3 changed files with 10 additions and 9 deletions

View file

@ -25,11 +25,11 @@ def buy():
if 'pid' in request.params: if 'pid' in request.params:
pid = int(str(request.params.pid)) pid = int(str(request.params.pid))
product = db.get_product(pid) product = db.get_product(pid)
if c.get_dispenser().dispense(product, 1):
# Create a consumption entry for the (user, product) combination # Create a consumption entry for the (user, product) combination
db.increment_consumption(user, product) db.increment_consumption(user, product)
stock_provider = c.get_stock_provider() stock_provider = c.get_stock_provider()
if stock_provider.needs_update(): if stock_provider.needs_update():
stock_provider.update_stock(product, -1) stock_provider.update_stock(product, -1)
c.get_dispenser().dispense(product, 1)
# Redirect to the main page (where this request should have come from) # Redirect to the main page (where this request should have come from)
redirect('/') redirect('/')

View file

@ -1,5 +1,5 @@
Package: matemat Package: matemat
Version: 0.2.4 Version: 0.2.6
Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol> Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
Section: web Section: web
Priority: optional Priority: optional

View file

@ -34,8 +34,9 @@
</span><br/> </span><br/>
<div class="imgcontainer"> <div class="imgcontainer">
<img src="/static/upload/thumbnails/products/{{ product.id }}.png" alt="Picture of {{ product.name }}"/> <img src="/static/upload/thumbnails/products/{{ product.id }}.png" alt="Picture of {{ product.name }}"/>
{% if product.stockable %} {% set pstock = stock.get_stock(product) %}
<span class="thumblist-stock">{{ stock.get_stock(product) }}</span> {% if pstock is not none %}
<span class="thumblist-stock">{{ pstock }}</span>
{% endif %} {% endif %}
</div> </div>
</a> </a>