change up status descriptions

This commit is contained in:
Tomáš Mládek 2021-02-11 02:08:59 +01:00
parent bb0c787c9f
commit dcdead591d
2 changed files with 9 additions and 5 deletions

View file

@ -35,6 +35,7 @@ class Lease:
@dataclass
class Status:
open: bool
description: str
text: str
@ -127,12 +128,15 @@ def run_forever(address: str, period: int, ssid: str, output: str):
logging.debug(", ".join([str(lease) for lease in registered_leases]))
if len(registered_leases) > 0:
if len([lease for lease in registered_leases if _is_human(lease)]) > 0:
status = Status(open=True, text="There seem to be people!")
people_cnt = len([lease for lease in registered_leases if _is_human(lease)])
if people_cnt > 3:
status = Status(open=True, description='FILLED', text="There seems to be a lot of people!")
elif people_cnt > 0:
status = Status(open=True, description='POPULATED', text="There seem to be people!")
else:
status = Status(open=False, text="There are only computers.")
status = Status(open=False, description='EMPTY', text="There are only computers.")
else:
status = Status(open=False, text="There are no devices connected?")
status = Status(open=False, description='VOID', text="There are no devices connected?")
logging.debug("Logging into the database...")
cur = db.cursor()

View file

@ -59,7 +59,7 @@
<h2>STATUS</h2>
<div class="status-container">
<div class="status status-{{'populated' if status.open else 'empty'}}">
{{'POPULATED' if status.open else 'EMPTY'}}
{{status.description}}
</div>
<div class="status-explanation">{{status.text}}</div>
</div>