File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed
admin/templates/admin/users Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,12 @@ def test_now():
2424 assert now () <= datetime .datetime .now ()
2525
2626
27+ def test_now_with_timezone ():
28+ assert isinstance (now (tz = True ), datetime .datetime )
29+ assert now (tz = True ).tzinfo is not None
30+ assert now (tz = True ) < datetime .datetime .now (datetime .UTC )
31+
32+
2733def test_camo_url ():
2834 request = pretend .stub (
2935 registry = pretend .stub (
Original file line number Diff line number Diff line change @@ -1002,6 +1002,7 @@ <h3 class="card-title">Unique logins</h3>
10021002 < th scope ="col "> Created</ th >
10031003 < th scope ="col "> IP address</ th >
10041004 < th scope ="col "> Status</ th >
1005+ < th scope ="col "> Expired?</ th >
10051006 < th scope ="col "> Device Information</ th >
10061007 </ tr >
10071008 </ thead >
@@ -1011,6 +1012,17 @@ <h3 class="card-title">Unique logins</h3>
10111012 < td > {{ login.created }}</ td >
10121013 < td > < a href ="{{ request.route_path('admin.ip_address.detail', ip_address=login.ip_address ) }} "> {{ login.ip_address }}</ a > </ td >
10131014 < td > {{ login.status.value }}</ td >
1015+ < td >
1016+ {% if login.status.value == 'pending' %}
1017+ {% if login.expires < now (tz =True) %}
1018+ < span title ="Expired: {{ login.expires|format_datetime }} "> 🔴</ span >
1019+ {% else %}
1020+ < span title ="Expires: {{ login.expires|format_datetime }} "> 🟠</ span >
1021+ {% endif %}
1022+ {% elif login.status.value == 'confirmed' %}
1023+ < span title ="Confirmed "> 🟢</ span >
1024+ {% endif %}
1025+ </ td >
10141026 < td > {{ login.device_information }}</ td >
10151027 </ tr >
10161028 {% endfor %}
Original file line number Diff line number Diff line change 33import datetime
44
55
6- def now () -> datetime .datetime :
7- """Return the current datetime in UTC without a timezone."""
8- return datetime .datetime .now (datetime .UTC ).replace (tzinfo = None )
6+ def now (tz = False ) -> datetime .datetime :
7+ """Return the current datetime in UTC with or without a timezone."""
8+ now = datetime .datetime .now (datetime .UTC )
9+ return now if tz else now .replace (tzinfo = None )
910
1011
1112def dotted_navigator (path ):
You can’t perform that action at this time.
0 commit comments