count fix 2
This commit is contained in:
@@ -45,3 +45,6 @@ def get_section_page(section_id, lim, off):
|
|||||||
|
|
||||||
def section_count(section_id):
|
def section_count(section_id):
|
||||||
return Article.query.filter(Article.section_id==section_id).count()
|
return Article.query.filter(Article.section_id==section_id).count()
|
||||||
|
|
||||||
|
def count():
|
||||||
|
return Article.query.count()
|
||||||
|
|||||||
@@ -24,12 +24,14 @@ def index():
|
|||||||
pp,o=controller.pagination_params(v) # extract per_page and offset from params
|
pp,o=controller.pagination_params(v) # extract per_page and offset from params
|
||||||
if v.has_key("section_id"):
|
if v.has_key("section_id"):
|
||||||
articles=controller.get_section_page(int(v["section_id"]),pp,o)
|
articles=controller.get_section_page(int(v["section_id"]),pp,o)
|
||||||
|
c=controller.section_count(int(v["section_id"]))
|
||||||
else:
|
else:
|
||||||
articles=controller.get_all_page(pp,o)
|
articles=controller.get_all_page(pp,o)
|
||||||
|
c=controller.count()
|
||||||
resp = jsonify(articles=articles)
|
resp = jsonify(articles=articles)
|
||||||
resp.headers['Pagination-Limit']=pp
|
resp.headers['Pagination-Limit']=pp
|
||||||
resp.headers['Pagination-Offset']=o
|
resp.headers['Pagination-Offset']=o
|
||||||
resp.headers['Pagination-TotalCount']=controller.count()
|
resp.headers['Pagination-TotalCount']=c
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@article_pages.route("/<int:id>",methods=['PUT'])
|
@article_pages.route("/<int:id>",methods=['PUT'])
|
||||||
|
|||||||
Reference in New Issue
Block a user