Skip to content

Commit

Permalink
fix cannot create task for some tpl bug
Browse files Browse the repository at this point in the history
  • Loading branch information
binux committed Apr 8, 2017
1 parent f63593a commit 0d4a7be
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion db/tpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def incr_failed(self, id):
self._execute('UPDATE %s SET failed_count=failed_count+1 WHERE `id`=%d' % (
self.escape(self.__tablename__), int(id)))

def list(self, fields=None, limit=100, **kwargs):
def list(self, fields=None, limit=None, **kwargs):
where = '1=1'
where_values = []
for key, value in kwargs.iteritems():
Expand Down
2 changes: 1 addition & 1 deletion web/handlers/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get(self):

tplid = self.get_argument('tplid', None)
fields = ('id', 'sitename', 'success_count')
tpls = sorted(self.db.tpl.list(userid=None, fields=fields), key=lambda t: -t['success_count'])
tpls = sorted(self.db.tpl.list(userid=None, fields=fields, limit=None), key=lambda t: -t['success_count'])
if not tpls:
return self.render('index.html', tpls=[], tplid=0, tpl=None, variables=[])

Expand Down
4 changes: 2 additions & 2 deletions web/handlers/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def get(self):

tpls = []
if user:
tpls += sorted(self.db.tpl.list(userid=user['id'], fields=fields), key=lambda t: -t['id'])
tpls += sorted(self.db.tpl.list(userid=user['id'], fields=fields, limit=None), key=lambda t: -t['id'])
if tpls:
tpls.append({'id': 0, 'sitename': u'以下为公共模板'})
tpls += sorted(self.db.tpl.list(userid=None, fields=fields), key=lambda t: -t['success_count'])
tpls += sorted(self.db.tpl.list(userid=None, fields=fields, limit=None), key=lambda t: -t['success_count'])

if not tplid:
for tpl in tpls:
Expand Down
5 changes: 3 additions & 2 deletions web/handlers/tpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get(self, tplid):
self.evil(+5)
self.finish(u'<span class="alert alert-danger">没有权限</span>')
return
tpls = self.db.tpl.list(userid=None, fields=('id', 'sitename'))
tpls = self.db.tpl.list(userid=None, limit=None, fields=('id', 'sitename'))
self.render('tpl_push.html', tpl=tpl, tpls=tpls)

@tornado.web.authenticated
Expand Down Expand Up @@ -124,7 +124,8 @@ def post(self, tplid):

class PublicTPLHandler(BaseHandler):
def get(self):
tpls = self.db.tpl.list(userid=None, limit=None, fields=('id', 'siteurl', 'sitename', 'banner', 'note', 'disabled', 'lock', 'last_success', 'ctime', 'mtime', 'fork'))
tpls = self.db.tpl.list(userid=None, limit=None, fields=('id', 'siteurl', 'sitename', 'banner', 'note', 'disabled', 'lock', 'last_success', 'ctime', 'mtime', 'fork', 'success_count'))
tpls = sorted(tpl, key=lambda t: -t['success_count'])

self.render('tpls_public.html', tpls=tpls)

Expand Down

0 comments on commit 0d4a7be

Please sign in to comment.