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
1feea061
Commit
1feea061
authored
Jun 26, 2016
by
Skia
🤘
Browse files
Add basic refill support
parent
9989b75b
Pipeline
#47
passed with stage
in 1 minute and 16 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
TODO.md
0 → 100644
View file @
1feea061
# TODO
## Easter eggs
*
'A' 'L' 'L' 'O': Entendre le Allooo de Madame Coucoune
*
idem avec cacafe
*
Un meat spin quelque part
*
Konami code
counter/models.py
View file @
1feea061
...
...
@@ -127,16 +127,16 @@ class Refilling(models.Model):
# TODO: add the bank if the payment is made by cheque
def
__str__
(
self
):
return
"Refilling: %f for %s"
%
(
self
.
amount
,
self
.
customer
.
user
.
get_display_name
())
return
"Refilling: %
.2
f for %s"
%
(
self
.
amount
,
self
.
customer
.
user
.
get_display_name
())
# def get_absolute_url(self):
# return reverse('counter:details', kwargs={'counter_id': self.id})
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
full_clean
()
self
.
customer
.
amount
+=
self
.
quantity
*
self
.
unit_price
self
.
customer
.
amount
+=
self
.
amount
self
.
customer
.
save
()
super
(
Se
lling
,
self
).
save
(
*
args
,
**
kwargs
)
super
(
Refi
lling
,
self
).
save
(
*
args
,
**
kwargs
)
class
Selling
(
models
.
Model
):
"""
...
...
counter/templates/counter/counter_click.jinja
View file @
1feea061
...
...
@@ -22,7 +22,20 @@
<p><strong>
Club:
</strong>
{{
counter.club
}}
</p>
<div>
<p>
Customer:
{{
customer.user.get_display_name
()
}}
,
{{
customer.amount
}}
€
</p>
<h5>
Customer
</h5>
<p>
{{
customer.user.get_display_name
()
}}
,
{{
customer.amount
}}
€
</p>
</div>
<div>
<h5>
Refilling
</h5>
<form
method=
"post"
action=
"
{{
url
(
'counter:click'
,
counter_id
=
counter.id
,
user_id
=
customer.user.id
)
}}
"
>
{%
csrf_token
%}
<input
type=
"hidden"
name=
"action"
value=
"refill"
>
<input
type=
"input"
name=
"amount"
value=
""
/>
<input
type=
"submit"
value=
"Go"
/>
</form>
</div>
<div>
<h5>
Selling
</h5>
{%
if
request.session
[
'not_enough'
]
%}
<p><strong>
Not enough money
</strong></p>
{%
endif
%}
...
...
counter/views.py
View file @
1feea061
...
...
@@ -64,6 +64,7 @@ class CounterMain(DetailView, ProcessFormView, FormMixin):
kwargs
=
super
(
CounterMain
,
self
).
get_context_data
(
**
kwargs
)
# TODO: make some checks on the counter type, in order not to make the AuthenticationForm if there is no need to
kwargs
[
'login_form'
]
=
AuthenticationForm
()
kwargs
[
'login_form'
].
fields
[
'username'
].
widget
.
attrs
[
'autofocus'
]
=
True
kwargs
[
'form'
]
=
self
.
get_form
()
kwargs
[
'barmen'
]
=
Counter
.
get_barmen_list
(
self
.
object
.
id
)
if
'last_basket'
in
self
.
request
.
session
.
keys
():
...
...
@@ -120,6 +121,8 @@ class CounterClick(DetailView):
self
.
add_product
(
request
)
elif
'del_product'
in
request
.
POST
[
'action'
]:
self
.
del_product
(
request
)
elif
'refill'
in
request
.
POST
[
'action'
]:
self
.
refill
(
request
)
elif
'code'
in
request
.
POST
[
'action'
]:
return
self
.
parse_code
(
request
)
elif
'cancel'
in
request
.
POST
[
'action'
]:
...
...
@@ -233,6 +236,17 @@ class CounterClick(DetailView):
request
.
session
.
pop
(
'basket'
,
None
)
return
HttpResponseRedirect
(
reverse_lazy
(
'counter:details'
,
args
=
self
.
args
,
kwargs
=
kwargs
))
def
refill
(
self
,
request
):
"""Refill the customer's account"""
if
self
.
is_barman_price
():
operator
=
self
.
customer
.
user
else
:
operator
=
Counter
.
get_random_barman
(
self
.
object
.
id
)
amount
=
float
(
request
.
POST
[
'amount'
])
s
=
Refilling
(
counter
=
self
.
object
,
operator
=
operator
,
customer
=
self
.
customer
,
amount
=
amount
,
payment_method
=
"cash"
)
s
.
save
()
def
get_context_data
(
self
,
**
kwargs
):
""" Add customer to the context """
kwargs
=
super
(
CounterClick
,
self
).
get_context_data
(
**
kwargs
)
...
...
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