diff --git a/brewman/static/partial/client-list.html b/brewman/static/partial/client-list.html
index cb65faca..ddff8899 100644
--- a/brewman/static/partial/client-list.html
+++ b/brewman/static/partial/client-list.html
@@ -7,6 +7,7 @@
Enabled |
OTP |
Created |
+ Last Login |
@@ -16,6 +17,7 @@
{{item.Enabled}} |
{{item.OTP}} |
{{item.CreationDate | localTime}} |
+ {{item.LastLogin | localTime}} |
diff --git a/brewman/views/auth/client.py b/brewman/views/auth/client.py
index e05b522a..9d3798b2 100644
--- a/brewman/views/auth/client.py
+++ b/brewman/views/auth/client.py
@@ -3,10 +3,11 @@ import uuid
import pkg_resources
from pyramid.response import Response, FileResponse
from pyramid.view import view_config
+from sqlalchemy import desc
import transaction
from brewman.models import DBSession
-from brewman.models.auth import Client
+from brewman.models.auth import Client, LoginHistory
from brewman.models.validation_exception import TryCatchFunction
@@ -54,9 +55,12 @@ def show_list(request):
list = Client.list()
clients = []
for item in list:
+ last_login = DBSession.query(LoginHistory) \
+ .filter(LoginHistory.client_id == item.id).order_by(desc(LoginHistory.date)).first()
+ last_login = 'Never' if last_login is None else last_login.date.strftime('%d-%b-%Y %H:%M')
clients.append(
{'ClientID': item.id, 'Code': item.code, 'Name': item.name, 'Enabled': item.enabled, 'OTP': item.otp,
- 'CreationDate': item.creation_date.strftime('%d-%b-%Y %H:%M'),
+ 'CreationDate': item.creation_date.strftime('%d-%b-%Y %H:%M'), 'LastLogin': last_login,
'Url': request.route_url('client_id', id=item.id)})
return clients