Download:
child 207:7dcbbcda0a18
parent 205:c1ff7500c753
206:fa568dac5bb0
Anton Shestakov <av6@dwimlabs.net>, Sat, 20 Aug 2016 10:21:05 +0800
viewer: get_check_or_404() helper

1 файлов изменено, 11 вставок(+), 7 удалений(-) [+]
candolint/handlers.py file | annotate | diff | comparison | revisions
--- a/candolint/handlers.py Sat Aug 20 10:10:40 2016 +0800
+++ b/candolint/handlers.py Sat Aug 20 10:21:05 2016 +0800
@@ -25,6 +25,16 @@
return get_or_404(pq)
+def get_check_or_404(project, check_num):
+ cq = (Check
+ .select(Check, Change)
+ .join(Change)
+ .where(Check.project == project))
+ if check_num != 'latest':
+ cq = cq.where(Check.ordinal == check_num)
+ return get_or_404(cq)
+
+
class BaseHandler(RequestHandler):
def prepare(self):
database.connect()
@@ -75,13 +85,7 @@
class CheckHandler(BaseHandler):
def get(self, domain, user, name, check_num, format_='html'):
project = get_project_or_404(domain, user, name)
- check_query = (Check
- .select(Check, Change)
- .join(Change)
- .where(Check.project == project))
- if check_num != 'latest':
- check_query = check_query.where(Check.ordinal == check_num)
- check = get_or_404(check_query)
+ check = get_check_or_404(project, check_num)
lines = json_decode(check.lines)
if format_ == 'raw':
self.get_raw(project, check, lines)