##// END OF EJS Templates
audit-logs: fixed search cases with special chars such as `-`....
dan -
r4135:9b536d10 default
parent child Browse files
Show More
@@ -22,7 +22,7 b' import logging'
22
22
23 from whoosh.qparser.default import QueryParser, query
23 from whoosh.qparser.default import QueryParser, query
24 from whoosh.qparser.dateparse import DateParserPlugin
24 from whoosh.qparser.dateparse import DateParserPlugin
25 from whoosh.fields import (TEXT, Schema, DATETIME)
25 from whoosh.fields import (TEXT, Schema, DATETIME, KEYWORD)
26 from sqlalchemy.sql.expression import or_, and_, not_, func
26 from sqlalchemy.sql.expression import or_, and_, not_, func
27
27
28 from rhodecode.model.db import UserLog
28 from rhodecode.model.db import UserLog
@@ -30,11 +30,12 b' from rhodecode.lib.utils2 import remove_'
30
30
31 # JOURNAL SCHEMA used only to generate queries in journal. We use whoosh
31 # JOURNAL SCHEMA used only to generate queries in journal. We use whoosh
32 # querylang to build sql queries and filter journals
32 # querylang to build sql queries and filter journals
33 JOURNAL_SCHEMA = Schema(
33 AUDIT_LOG_SCHEMA = Schema(
34 username=TEXT(),
34 username=KEYWORD(),
35 repository=KEYWORD(),
36
35 date=DATETIME(),
37 date=DATETIME(),
36 action=TEXT(),
38 action=TEXT(),
37 repository=TEXT(),
38 ip=TEXT(),
39 ip=TEXT(),
39 )
40 )
40
41
@@ -52,7 +53,7 b' def user_log_filter(user_log, search_ter'
52 log.debug('Initial search term: %r', search_term)
53 log.debug('Initial search term: %r', search_term)
53 qry = None
54 qry = None
54 if search_term:
55 if search_term:
55 qp = QueryParser('repository', schema=JOURNAL_SCHEMA)
56 qp = QueryParser('repository', schema=AUDIT_LOG_SCHEMA)
56 qp.add_plugin(DateParserPlugin())
57 qp.add_plugin(DateParserPlugin())
57 qry = qp.parse(safe_unicode(search_term))
58 qry = qp.parse(safe_unicode(search_term))
58 log.debug('Filtering using parsed query %r', qry)
59 log.debug('Filtering using parsed query %r', qry)
General Comments 0
You need to be logged in to leave comments. Login now