forked from s3lph/matemat
Improve support for stock providers
This commit is contained in:
parent
119ed38f28
commit
361144815e
3 changed files with 10 additions and 9 deletions
|
@ -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)
|
||||||
# Create a consumption entry for the (user, product) combination
|
if c.get_dispenser().dispense(product, 1):
|
||||||
db.increment_consumption(user, product)
|
# Create a consumption entry for the (user, product) combination
|
||||||
stock_provider = c.get_stock_provider()
|
db.increment_consumption(user, product)
|
||||||
if stock_provider.needs_update():
|
stock_provider = c.get_stock_provider()
|
||||||
stock_provider.update_stock(product, -1)
|
if stock_provider.needs_update():
|
||||||
c.get_dispenser().dispense(product, 1)
|
stock_provider.update_stock(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('/')
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue