#NEWLINE# @ login_required #NEWLINE# @ app . route ( '/search/' ) #NEWLINE# def search( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# page = int ( request . args . get ( 'p' , 1 ) ) #NEWLINE# #UNINDENT# except ( TypeError , ValueError ) : #NEWLINE# #INDENT# page = 1 #NEWLINE# #UNINDENT# query = request . args . get ( 'q' ) #NEWLINE# has_search = bool ( app . config [ 'SEARCH_ENGINE' ] ) #NEWLINE# if query : #NEWLINE# #INDENT# if uuid_re . match ( query ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# event = Event . objects . get ( query ) #NEWLINE# #UNINDENT# except Event . DoesNotExist : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return redirect ( event . get_absolute_url ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not has_search ) : #NEWLINE# #INDENT# return render_template ( 'sentry/invalid_message_id.html' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise NotImplementedError #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# event_list = Group . objects . none ( ) #NEWLINE# #UNINDENT# sort = request . args . get ( 'sort' ) #NEWLINE# if ( query == 'date' ) : #NEWLINE# #INDENT# event_list = event_list . order_by ( '-last_seen' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( sort == 'new' ) : #NEWLINE# #INDENT# event_list = event_list . order_by ( '-first_seen' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sort = 'relevance' #NEWLINE# #UNINDENT# #UNINDENT# return render_template ( 'sentry/search.html' , ** { #NEWLINE# #INDENT# 'event_list' : event_list , #NEWLINE# 'query' : query , #NEWLINE# 'sort' : sort , #NEWLINE# 'request' : request , #NEWLINE# 'page' : page , #NEWLINE# #UNINDENT# } )