Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
7588cc8f
Commit
7588cc8f
authored
Jul 27, 2017
by
Sli
Browse files
Hardcoding ecocup values
parent
40927fa1
Changes
3
Hide whitespace changes
Inline
Side-by-side
counter/models.py
View file @
7588cc8f
...
@@ -153,17 +153,11 @@ class Product(models.Model):
...
@@ -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
):
"""
"""
...
...
counter/views.py
View file @
7588cc8f
...
@@ -381,7 +381,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
...
@@ -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):
...
@@ -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):
...
@@ -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
)
...
...
sith/settings.py
View file @
7588cc8f
...
@@ -397,13 +397,9 @@ SITH_COUNTER_BANK = [
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment