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
63f10c13
Commit
63f10c13
authored
Oct 16, 2016
by
guillaume-renaud
Committed by
Skia
Nov 08, 2016
Browse files
Add inactive state for counters
parent
ba6e2c37
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/templates/core/base.jinja
View file @
63f10c13
...
...
@@ -26,7 +26,9 @@
{%
for
bar
in
Counter.objects.
filter
(
type
=
"BAR"
)
.
all
()
%}
<li>
<a
href=
"
{{
url
(
'counter:activity'
,
counter_id
=
bar.id
)
}}
"
style=
"padding: 0px"
>
{%
if
bar.is_open
()
%}
{%
if
bar.is_inactive
()
:
%}
<span
style=
"color: orange"
>
?
</span>
{%
elif
bar.is_open
()
:
%}
<span
style=
"color: green"
>
✓
</span>
{%
else
%}
<span
style=
"color: red"
>
✗
</span>
...
...
counter/models.py
View file @
63f10c13
...
...
@@ -11,6 +11,7 @@ import random
import
string
import
os
import
base64
import
datetime
from
club.models
import
Club
from
accounting.models
import
CurrencyField
...
...
@@ -220,6 +221,15 @@ class Counter(models.Model):
def
is_open
(
self
):
return
len
(
self
.
get_barmen_list
())
>
0
def
is_inactive
(
self
):
"""
Returns True if the counter self is inactive from 5 minutes, else False
"""
if
(
self
.
is_open
()):
return
((
timezone
.
now
()
-
self
.
permanencies
.
model
.
objects
.
order_by
(
'-activity'
).
first
().
activity
)
>
datetime
.
timedelta
(
minutes
=
5
))
else
:
return
False
def
barman_list
(
self
):
"""
Returns the barman id list
...
...
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