Shows the available discounts on the registration form
This commit is contained in:
parent
fc279b1922
commit
941b057865
2 changed files with 29 additions and 4 deletions
|
@ -5,8 +5,6 @@
|
||||||
|
|
||||||
<h1>Product Category: {{ category.name }}</h1>
|
<h1>Product Category: {{ category.name }}</h1>
|
||||||
|
|
||||||
<p>{{ category.description }}</p>
|
|
||||||
|
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
|
@ -14,13 +12,37 @@
|
||||||
{{ voucher_form }}
|
{{ voucher_form }}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<input type="submit">
|
<p><input type="submit"></p>
|
||||||
|
|
||||||
|
{% if discounts %}
|
||||||
|
<h3>Available Discounts</h3>
|
||||||
|
<ul>
|
||||||
|
{% for discount in discounts %}
|
||||||
|
<li>{{ discount.quantity }} x
|
||||||
|
{% if discount.clause.percentage %}
|
||||||
|
{{ discount.clause.percentage|floatformat:"2" }}%
|
||||||
|
{% else %}
|
||||||
|
${{ discount.clause.price|floatformat:"2" }}
|
||||||
|
{% endif %}
|
||||||
|
off
|
||||||
|
{% if discount.clause.category %}
|
||||||
|
{{ discount.clause.category }}
|
||||||
|
{% else %}
|
||||||
|
{{ discount.clause.product.category }}
|
||||||
|
- {{ discount.clause.product }}
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h3>Available Products</h3>
|
||||||
|
<p>{{ category.description }}</p>
|
||||||
<table>
|
<table>
|
||||||
{{ form }}
|
{{ form }}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<input type="submit">
|
<p><input type="submit"></p>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from registrasion import forms
|
from registrasion import forms
|
||||||
from registrasion import models as rego
|
from registrasion import models as rego
|
||||||
|
from registrasion.controllers import discount
|
||||||
from registrasion.controllers.cart import CartController
|
from registrasion.controllers.cart import CartController
|
||||||
from registrasion.controllers.invoice import InvoiceController
|
from registrasion.controllers.invoice import InvoiceController
|
||||||
from registrasion.controllers.product import ProductController
|
from registrasion.controllers.product import ProductController
|
||||||
|
@ -175,8 +176,10 @@ def product_category(request, category_id):
|
||||||
|
|
||||||
voucher_form = forms.VoucherForm(prefix=VOUCHERS_FORM_PREFIX)
|
voucher_form = forms.VoucherForm(prefix=VOUCHERS_FORM_PREFIX)
|
||||||
|
|
||||||
|
discounts = discount.available_discounts(request.user, [], products)
|
||||||
data = {
|
data = {
|
||||||
"category": category,
|
"category": category,
|
||||||
|
"discounts": discounts,
|
||||||
"form": cat_form,
|
"form": cat_form,
|
||||||
"voucher_form": voucher_form,
|
"voucher_form": voucher_form,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue