mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
Hardcoding ecocup values
This commit is contained in:
parent
40927fa13d
commit
7588cc8f73
@ -153,17 +153,11 @@ class Product(models.Model):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_record_product(self):
|
def is_record_product(self):
|
||||||
for product in settings.SITH_RECORD_PRODUCT:
|
return settings.SITH_RECORD_PRODUCT == self.id
|
||||||
if product == self.id:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_unrecord_product(self):
|
def is_unrecord_product(self):
|
||||||
for product in settings.SITH_UNRECORD_PRODUCT:
|
return settings.SITH_UNRECORD_PRODUCT == self.id
|
||||||
if product == self.id:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def is_owned_by(self, user):
|
def is_owned_by(self, user):
|
||||||
"""
|
"""
|
||||||
|
@ -381,7 +381,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
|||||||
if self.customer.amount < (total + round(q * float(price), 2)): # Check for enough money
|
if self.customer.amount < (total + round(q * float(price), 2)): # Check for enough money
|
||||||
request.session['not_enough'] = True
|
request.session['not_enough'] = True
|
||||||
return False
|
return False
|
||||||
if not self.is_record_product_ok(request, product):
|
if product.is_unrecord_product and not self.is_record_product_ok(request, product):
|
||||||
request.session['not_allowed'] = True
|
request.session['not_allowed'] = True
|
||||||
return False
|
return False
|
||||||
if product.limit_age >= 18 and not self.customer.user.date_of_birth:
|
if product.limit_age >= 18 and not self.customer.user.date_of_birth:
|
||||||
@ -446,6 +446,9 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
|||||||
""" Finish the click session, and validate the basket """
|
""" Finish the click session, and validate the basket """
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
request.session['last_basket'] = []
|
request.session['last_basket'] = []
|
||||||
|
if self.sum_basket(request) > self.customer.amount:
|
||||||
|
raise DataError(_("You have not enough money to buy all the basket"))
|
||||||
|
|
||||||
for pid, infos in request.session['basket'].items():
|
for pid, infos in request.session['basket'].items():
|
||||||
# This duplicates code for DB optimization (prevent to load many times the same object)
|
# This duplicates code for DB optimization (prevent to load many times the same object)
|
||||||
p = Product.objects.filter(pk=pid).first()
|
p = Product.objects.filter(pk=pid).first()
|
||||||
@ -453,8 +456,6 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
|||||||
uprice = p.special_selling_price
|
uprice = p.special_selling_price
|
||||||
else:
|
else:
|
||||||
uprice = p.selling_price
|
uprice = p.selling_price
|
||||||
if uprice * infos['qty'] > self.customer.amount:
|
|
||||||
raise DataError(_("You have not enough money to buy all the basket"))
|
|
||||||
request.session['last_basket'].append("%d x %s" % (infos['qty'] + infos['bonus_qty'], p.name))
|
request.session['last_basket'].append("%d x %s" % (infos['qty'] + infos['bonus_qty'], p.name))
|
||||||
s = Selling(label=p.name, product=p, club=p.club, counter=self.object, unit_price=uprice,
|
s = Selling(label=p.name, product=p, club=p.club, counter=self.object, unit_price=uprice,
|
||||||
quantity=infos['qty'], seller=self.operator, customer=self.customer)
|
quantity=infos['qty'], seller=self.operator, customer=self.customer)
|
||||||
|
@ -397,13 +397,9 @@ SITH_COUNTER_BANK = [
|
|||||||
('LA-POSTE', 'La Poste'),
|
('LA-POSTE', 'La Poste'),
|
||||||
]
|
]
|
||||||
|
|
||||||
SITH_RECORD_PRODUCT = [
|
SITH_RECORD_PRODUCT = 1152
|
||||||
1152,
|
|
||||||
]
|
|
||||||
|
|
||||||
SITH_UNRECORD_PRODUCT = [
|
SITH_UNRECORD_PRODUCT = 1151
|
||||||
1151,
|
|
||||||
]
|
|
||||||
|
|
||||||
SITH_RECORD_LIMIT = 3
|
SITH_RECORD_LIMIT = 3
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user