Feature: Client list shows last login time.
This commit is contained in:
parent
f3b4e95072
commit
78a064a723
@ -7,6 +7,7 @@
|
||||
<th>Enabled</th>
|
||||
<th>OTP</th>
|
||||
<th>Created</th>
|
||||
<th>Last Login</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -16,6 +17,7 @@
|
||||
<td>{{item.Enabled}}</td>
|
||||
<td>{{item.OTP}}</td>
|
||||
<td>{{item.CreationDate | localTime}}</td>
|
||||
<td>{{item.LastLogin | localTime}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user