Fixing audit filtering and sorting. (#827)
This commit is contained in:
parent
9c92138f2d
commit
d4d6d832b1
|
@ -8,8 +8,11 @@
|
||||||
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
||||||
"""
|
"""
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
from lemur import database
|
from lemur import database
|
||||||
from lemur.logs.models import Log
|
from lemur.logs.models import Log
|
||||||
|
from lemur.users.models import User
|
||||||
|
from lemur.certificates.models import Certificate
|
||||||
|
|
||||||
|
|
||||||
def create(user, type, certificate=None):
|
def create(user, type, certificate=None):
|
||||||
|
@ -51,6 +54,20 @@ def render(args):
|
||||||
|
|
||||||
if filt:
|
if filt:
|
||||||
terms = filt.split(';')
|
terms = filt.split(';')
|
||||||
query = database.filter(query, Log, terms)
|
|
||||||
|
if 'certificate.name' in terms:
|
||||||
|
sub_query = database.session_query(Certificate.id)\
|
||||||
|
.filter(Certificate.name.ilike('%{0}%'.format(terms[1])))
|
||||||
|
|
||||||
|
query = query.filter(Log.certificate_id.in_(sub_query))
|
||||||
|
|
||||||
|
elif 'user.email' in terms:
|
||||||
|
sub_query = database.session_query(User.id)\
|
||||||
|
.filter(User.email.ilike('%{0}%'.format(terms[1])))
|
||||||
|
|
||||||
|
query = query.filter(Log.user_id.in_(sub_query))
|
||||||
|
|
||||||
|
else:
|
||||||
|
query = database.filter(query, Log, terms)
|
||||||
|
|
||||||
return database.sort_and_page(query, Log, args)
|
return database.sort_and_page(query, Log, args)
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
<table ng-table="logsTable" class="table table-striped" show-filter="showFilter" template-pagination="angular/pager.html">
|
<table ng-table="logsTable" class="table table-striped" show-filter="showFilter" template-pagination="angular/pager.html">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="log in $data track by $index">
|
<tr ng-repeat="log in $data track by $index">
|
||||||
<td data-title="'Logged'" sortable="'logged_at'" filter="{ 'logged_at': 'text' }">
|
<td data-title="'Logged'" sortable="'logged_at'">
|
||||||
<span class="pull-right" uib-tooltip="{{ log.loggedAt }}">
|
<span uib-tooltip="{{ log.loggedAt }}">
|
||||||
{{ momentService.createMoment(log.loggedAt) }}
|
{{ momentService.createMoment(log.loggedAt) }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<td data-title="'User'" sortable="'user'" filter="{ 'user.email': 'text' }">
|
<td data-title="'User'" sortable="'user'" filter="{ 'user.email': 'text' }">
|
||||||
{{ log.user.email }}
|
{{ log.user.email }}
|
||||||
</td>
|
</td>
|
||||||
<td data-title="'Type'" sortable="'type'" filter="{ 'type': 'text' }">
|
<td data-title="'Type'">
|
||||||
{{ log.logType }}
|
{{ log.logType }}
|
||||||
</td>
|
</td>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue