diff --git a/lemur/logs/service.py b/lemur/logs/service.py index d73c17af..59097cb0 100644 --- a/lemur/logs/service.py +++ b/lemur/logs/service.py @@ -8,8 +8,11 @@ .. moduleauthor:: Kevin Glisson """ from flask import current_app + from lemur import database from lemur.logs.models import Log +from lemur.users.models import User +from lemur.certificates.models import Certificate def create(user, type, certificate=None): @@ -51,6 +54,20 @@ def render(args): if filt: 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) diff --git a/lemur/static/app/angular/logs/view/view.tpl.html b/lemur/static/app/angular/logs/view/view.tpl.html index f8d1244b..496c998c 100644 --- a/lemur/static/app/angular/logs/view/view.tpl.html +++ b/lemur/static/app/angular/logs/view/view.tpl.html @@ -15,8 +15,8 @@ - @@ -26,7 +26,7 @@ -
- + + {{ momentService.createMoment(log.loggedAt) }} {{ log.user.email }} + {{ log.logType }}