[879b32]: / qiita_pet / handlers / logger_handlers.py

Download this file

39 lines (33 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -----------------------------------------------------------------------------
# Copyright (c) 2014--, The Qiita Development Team.
#
# Distributed under the terms of the BSD 3-clause License.
#
# The full license is in the file LICENSE, distributed with this software.
# -----------------------------------------------------------------------------
from tornado.web import authenticated
from .base_handlers import BaseHandler
from qiita_db.logger import LogEntry
from qiita_core.util import execute_as_transaction
from tornado.web import HTTPError
class LogEntryViewerHandler(BaseHandler):
def check_access(self):
if self.current_user.level not in {'admin', 'dev'}:
raise HTTPError(403, reason="User %s doesn't have sufficient "
"privileges to view error page" %
self.current_user.email)
@authenticated
@execute_as_transaction
def get(self):
self.check_access()
logentries = LogEntry.newest_records()
self.render("error_log.html", logentries=logentries)
@authenticated
@execute_as_transaction
def post(self):
self.check_access()
numentries = int(self.get_argument("numrecords"))
if numentries <= 0:
numentries = 100
logentries = LogEntry.newest_records(numentries)
self.render("error_log.html", logentries=logentries)