Download:
child 325:9ee96b2a1610
parent 323:81a30615a4bb
324:379f61e6569d
Anton Shestakov <av6@dwimlabs.net>, Tue, 28 Nov 2017 11:56:47 +0800
viewer: move status() to class level in AtomHandler, rename

1 файлов изменено, 18 вставок(+), 17 удалений(-) [+]
candolint/handlers.py file | annotate | diff | comparison | revisions
--- a/candolint/handlers.py Tue Nov 28 11:55:40 2017 +0800
+++ b/candolint/handlers.py Tue Nov 28 11:56:47 2017 +0800
@@ -116,6 +116,23 @@
class AtomHandler(BaseHandler):
+ def get_check_status(self, check):
+ if not check.success:
+ return 'unknown'
+ elif check.errors or check.warnings:
+ status = []
+ if check.errors:
+ msg = self.locale.translate(
+ '{} error', '{} errors', check.errors)
+ status.append(msg.format(check.errors))
+ if check.warnings:
+ msg = self.locale.translate(
+ '{} warning', '{} warnings', check.warnings)
+ status.append(msg.format(check.warnings))
+ return ', '.join(status)
+ else:
+ return 'all clean'
+
def get(self, domain, user, name):
project = get_project_or_404(domain, user, name)
checks = (Check
@@ -123,24 +140,8 @@
.join(Change)
.where(Check.project == project)
.order_by(Check.ordinal.desc()))
- def status(check):
- if not check.success:
- return 'unknown'
- elif check.errors or check.warnings:
- status = []
- if check.errors:
- msg = self.locale.translate(
- '{} error', '{} errors', check.errors)
- status.append(msg.format(check.errors))
- if check.warnings:
- msg = self.locale.translate(
- '{} warning', '{} warnings', check.warnings)
- status.append(msg.format(check.warnings))
- return ', '.join(status)
- else:
- return 'all clean'
self.set_header('Content-Type', 'application/atom+xml; charset=utf-8')
- self.render('atom.xml', project=project, checks=checks, status=status)
+ self.render('atom.xml', project=project, checks=checks, status=self.get_check_status)
class CheckHandler(BaseHandler):