Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Sith
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
40927fa1
Commit
40927fa1
authored
Jul 21, 2017
by
Sli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add limit for ecocup recording
parent
2058d58d
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
285 additions
and
197 deletions
+285
-197
core/management/commands/populate.py
core/management/commands/populate.py
+12
-0
counter/migrations/0013_customer_recorded_products.py
counter/migrations/0013_customer_recorded_products.py
+19
-0
counter/models.py
counter/models.py
+22
-0
counter/views.py
counter/views.py
+27
-0
locale/fr/LC_MESSAGES/django.po
locale/fr/LC_MESSAGES/django.po
+195
-197
sith/settings.py
sith/settings.py
+10
-0
No files found.
core/management/commands/populate.py
View file @
40927fa1
...
...
@@ -340,6 +340,8 @@ Welcome to the wiki page!
c
.
save
()
r
=
ProductType
(
name
=
"Rechargements"
)
r
.
save
()
verre
=
ProductType
(
name
=
"Verre"
)
verre
.
save
()
cotis
=
Product
(
name
=
"Cotis 1 semestre"
,
code
=
"1SCOTIZ"
,
product_type
=
c
,
purchase_price
=
"15"
,
selling_price
=
"15"
,
special_selling_price
=
"15"
,
club
=
main_club
)
cotis
.
save
()
...
...
@@ -355,6 +357,14 @@ Welcome to the wiki page!
cble
=
Product
(
name
=
"Chimay Bleue"
,
code
=
"CBLE"
,
product_type
=
p
,
purchase_price
=
"1.50"
,
selling_price
=
"1.7"
,
special_selling_price
=
"1.6"
,
club
=
main_club
)
cble
.
save
()
cons
=
Product
(
name
=
"Consigne Eco-cup"
,
code
=
"CONS"
,
product_type
=
verre
,
purchase_price
=
"1"
,
selling_price
=
"1"
,
special_selling_price
=
"1"
,
club
=
main_club
)
cons
.
id
=
1152
cons
.
save
()
dcons
=
Product
(
name
=
"Déconsigne Eco-cup"
,
code
=
"DECO"
,
product_type
=
verre
,
purchase_price
=
"-1"
,
selling_price
=
"-1"
,
special_selling_price
=
"-1"
,
club
=
main_club
)
dcons
.
id
=
1151
dcons
.
save
()
Product
(
name
=
"Corsendonk"
,
code
=
"CORS"
,
product_type
=
p
,
purchase_price
=
"1.50"
,
selling_price
=
"1.7"
,
special_selling_price
=
"1.6"
,
club
=
main_club
).
save
()
Product
(
name
=
"Carolus"
,
code
=
"CARO"
,
product_type
=
p
,
purchase_price
=
"1.50"
,
selling_price
=
"1.7"
,
...
...
@@ -362,6 +372,8 @@ Welcome to the wiki page!
mde
=
Counter
.
objects
.
filter
(
name
=
"MDE"
).
first
()
mde
.
products
.
add
(
barb
)
mde
.
products
.
add
(
cble
)
mde
.
products
.
add
(
cons
)
mde
.
products
.
add
(
dcons
)
mde
.
sellers
.
add
(
skia
)
mde
.
save
()
...
...
counter/migrations/0013_customer_recorded_products.py
0 → 100644
View file @
40927fa1
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'counter'
,
'0012_auto_20170515_2202'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'customer'
,
name
=
'recorded_products'
,
field
=
models
.
IntegerField
(
verbose_name
=
'recorded items'
,
default
=
0
),
),
]
counter/models.py
View file @
40927fa1
...
...
@@ -51,6 +51,7 @@ class Customer(models.Model):
user
=
models
.
OneToOneField
(
User
,
primary_key
=
True
)
account_id
=
models
.
CharField
(
_
(
'account id'
),
max_length
=
10
,
unique
=
True
)
amount
=
CurrencyField
(
_
(
'amount'
))
recorded_products
=
models
.
IntegerField
(
_
(
'recorded product'
),
default
=
0
)
class
Meta
:
verbose_name
=
_
(
'customer'
)
...
...
@@ -60,6 +61,13 @@ class Customer(models.Model):
def
__str__
(
self
):
return
"%s - %s"
%
(
self
.
user
.
username
,
self
.
account_id
)
@
property
def
can_record
(
self
):
return
self
.
recorded_products
>
-
settings
.
SITH_RECORD_LIMIT
def
can_record_more
(
self
,
number
):
return
self
.
recorded_products
-
number
>=
-
settings
.
SITH_RECORD_LIMIT
@
property
def
can_buy
(
self
):
return
(
self
.
user
.
subscriptions
.
last
()
and
...
...
@@ -143,6 +151,20 @@ class Product(models.Model):
class
Meta
:
verbose_name
=
_
(
'product'
)
@
property
def
is_record_product
(
self
):
for
product
in
settings
.
SITH_RECORD_PRODUCT
:
if
product
==
self
.
id
:
return
True
return
False
@
property
def
is_unrecord_product
(
self
):
for
product
in
settings
.
SITH_UNRECORD_PRODUCT
:
if
product
==
self
.
id
:
return
True
return
False
def
is_owned_by
(
self
,
user
):
"""
Method to see if that object can be edited by the given user
...
...
counter/views.py
View file @
40927fa1
...
...
@@ -330,6 +330,28 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
except
:
return
0
def
compute_record_product
(
self
,
request
,
product
=
None
):
recorded
=
0
basket
=
request
.
session
[
'basket'
]
if
product
:
if
product
.
is_record_product
:
recorded
-=
1
elif
product
.
is_unrecord_product
:
recorded
+=
1
for
p
in
basket
:
bproduct
=
self
.
get_product
(
str
(
p
))
if
bproduct
.
is_record_product
:
recorded
-=
basket
[
p
][
'qty'
]
elif
bproduct
.
is_unrecord_product
:
recorded
+=
basket
[
p
][
'qty'
]
return
recorded
def
is_record_product_ok
(
self
,
request
,
product
):
return
self
.
customer
.
can_record_more
(
self
.
compute_record_product
(
request
,
product
))
def
add_product
(
self
,
request
,
q
=
1
,
p
=
None
):
"""
Add a product to the basket
...
...
@@ -359,6 +381,9 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
if
self
.
customer
.
amount
<
(
total
+
round
(
q
*
float
(
price
),
2
)):
# Check for enough money
request
.
session
[
'not_enough'
]
=
True
return
False
if
not
self
.
is_record_product_ok
(
request
,
product
):
request
.
session
[
'not_allowed'
]
=
True
return
False
if
product
.
limit_age
>=
18
and
not
self
.
customer
.
user
.
date_of_birth
:
request
.
session
[
'no_age'
]
=
True
return
False
...
...
@@ -438,6 +463,8 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
s
=
Selling
(
label
=
p
.
name
+
" (Plateau)"
,
product
=
p
,
club
=
p
.
club
,
counter
=
self
.
object
,
unit_price
=
0
,
quantity
=
infos
[
'bonus_qty'
],
seller
=
self
.
operator
,
customer
=
self
.
customer
)
s
.
save
()
self
.
customer
.
recorded_products
-=
self
.
compute_record_product
(
request
)
self
.
customer
.
save
()
request
.
session
[
'last_customer'
]
=
self
.
customer
.
user
.
get_display_name
()
request
.
session
[
'last_total'
]
=
"%0.2f"
%
self
.
sum_basket
(
request
)
request
.
session
[
'new_customer_amount'
]
=
str
(
self
.
customer
.
amount
)
...
...
locale/fr/LC_MESSAGES/django.po
View file @
40927fa1
This diff is collapsed.
Click to expand it.
sith/settings.py
View file @
40927fa1
...
...
@@ -397,6 +397,16 @@ SITH_COUNTER_BANK = [
(
'LA-POSTE'
,
'La Poste'
),
]
SITH_RECORD_PRODUCT
=
[
1152
,
]
SITH_UNRECORD_PRODUCT
=
[
1151
,
]
SITH_RECORD_LIMIT
=
3
# Defines pagination for cash summary
SITH_COUNTER_CASH_SUMMARY_LENGTH
=
50
...
...
Write
Preview
Markdown
is supported
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