From cd5b0fb700f531d3dc7b3313cf030ab0d8d60a7b Mon Sep 17 00:00:00 2001 From: Lukas Metzger Date: Wed, 10 Jun 2020 15:51:05 +0200 Subject: Added minimal date for locations, machines and vms --- pages/locations.py | 17 ++++++++++++++++- pages/machines.py | 13 +++++++++++++ pages/vms.py | 13 +++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/pages/locations.py b/pages/locations.py index 9cb36bc..85adcfc 100644 --- a/pages/locations.py +++ b/pages/locations.py @@ -33,6 +33,7 @@ def layout(): date=get_newest_date(), display_format='DD-MM-YYYY', max_date_allowed=get_newest_date(), + min_date_allowed=get_oldest_date(), initial_visible_month=get_newest_date(), first_day_of_week=1, persistence=True, @@ -44,7 +45,9 @@ def layout(): id='locations-satellite', options=[{'label': s, 'value': s} for s in get_satellites()], value=None, - placeholder='All Satellites' + placeholder='All Satellites', + persistence=True, + persistence_type='memory' ) ]) ]), @@ -224,3 +227,15 @@ def get_newest_date(): db.closeConnection(dbcon) return data[0]['date'] + +def get_oldest_date(): + dbcon = db.getConnection() + cursor = dbcon.cursor() + + cursor.execute("""SELECT date FROM reports ORDER BY date ASC LIMIT 1""") + + data = cursor.fetchall() + + db.closeConnection(dbcon) + return data[0]['date'] + diff --git a/pages/machines.py b/pages/machines.py index f314777..b82df43 100644 --- a/pages/machines.py +++ b/pages/machines.py @@ -33,6 +33,7 @@ def layout(): date=get_newest_date(), display_format='DD-MM-YYYY', max_date_allowed=get_newest_date(), + min_date_allowed=get_oldest_date(), initial_visible_month=get_newest_date(), first_day_of_week=1, persistence=True, @@ -291,3 +292,15 @@ def get_newest_date(): db.closeConnection(dbcon) return data[0]['date'] + +def get_oldest_date(): + dbcon = db.getConnection() + cursor = dbcon.cursor() + + cursor.execute("""SELECT date FROM reports ORDER BY date ASC LIMIT 1""") + + data = cursor.fetchall() + + db.closeConnection(dbcon) + return data[0]['date'] + diff --git a/pages/vms.py b/pages/vms.py index f0b9a05..c9ca141 100644 --- a/pages/vms.py +++ b/pages/vms.py @@ -33,6 +33,7 @@ def layout(): date=get_newest_date(), display_format='DD-MM-YYYY', max_date_allowed=get_newest_date(), + min_date_allowed=get_oldest_date(), initial_visible_month=get_newest_date(), first_day_of_week=1, persistence=True, @@ -143,3 +144,15 @@ def get_newest_date(): db.closeConnection(dbcon) return data[0]['date'] + +def get_oldest_date(): + dbcon = db.getConnection() + cursor = dbcon.cursor() + + cursor.execute("""SELECT date FROM reports ORDER BY date ASC LIMIT 1""") + + data = cursor.fetchall() + + db.closeConnection(dbcon) + return data[0]['date'] + -- cgit v1.2.3-55-g7522