Fix datetime compare error
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
This commit is contained in:
parent
e8ad176824
commit
1a56e32415
@ -1,5 +1,5 @@
|
||||
from datetime import datetime, timedelta
|
||||
from dateutil.parser import parse
|
||||
from dateutil.parser import parse, ParserError
|
||||
|
||||
from bson.objectid import ObjectId
|
||||
from flask import Blueprint, g, redirect, render_template, request
|
||||
@ -221,9 +221,23 @@ def view_doorboy_admin():
|
||||
|
||||
orphaned_keyfobs = sorted(orphaned_keyfobs, key = lambda o : (not bool(o.get("comment")), o.get("comment", "")))
|
||||
no_keyfobs = sorted(no_keyfobs, key = lambda u : u.display_name or u.username)
|
||||
last_seen = dict(sorted(last_seen.items(), key = lambda item: item[1] or datetime.min, reverse=True))
|
||||
last_seen = dict(sorted(last_seen.items(), key=lambda i : datetime_handle(i[1]), reverse=True))
|
||||
return render_template("doorboy_admin.html", **locals())
|
||||
|
||||
def datetime_handle(item):
|
||||
if not item:
|
||||
return datetime.min
|
||||
elif type(item) is str:
|
||||
try:
|
||||
return parse(item)
|
||||
except ParserError as e:
|
||||
print(e)
|
||||
return datetime.min
|
||||
elif type(item) is datetime:
|
||||
return item
|
||||
else:
|
||||
return datetime.min
|
||||
|
||||
@page_doorboy.route("/m/doorboy/swipes")
|
||||
@login_required
|
||||
def view_doorboy_events():
|
||||
|
Loading…
Reference in New Issue
Block a user