Add inactive state for counters

This commit is contained in:
guillaume-renaud authored and Skia committed 2016-11-08 18:42:12 +01:00
1 parent ba6e2c3712
commit 63f10c13d4
2 files changed
+13 -1

No files matched your search

+3 -1
View File
@@ -26,7 +26,9 @@
{% for bar in Counter.objects.filter(type="BAR").all() %} {% for bar in Counter.objects.filter(type="BAR").all() %}
<li> <li>
<a href="{{ url('counter:activity', counter_id=bar.id) }}" style="padding: 0px"> <a href="{{ url('counter:activity', counter_id=bar.id) }}" style="padding: 0px">
{% if bar.is_open() %} {% if bar.is_inactive(): %}
<span style="color: orange">&#x3f;</span>
{% elif bar.is_open(): %}
<span style="color: green">&#x2713;</span> <span style="color: green">&#x2713;</span>
{% else %} {% else %}
<span style="color: red">&#10007;</span> <span style="color: red">&#10007;</span>
+10
View File
@@ -11,6 +11,7 @@ import random
import string import string
import os import os
import base64 import base64
import datetime
from club.models import Club from club.models import Club
from accounting.models import CurrencyField from accounting.models import CurrencyField
@@ -220,6 +221,15 @@ class Counter(models.Model):
def is_open(self): def is_open(self):
return len(self.get_barmen_list()) > 0 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): def barman_list(self):
""" """
Returns the barman id list Returns the barman id list