fixes card ordering so pages are latest to earliest
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import os
|
||||
from flask import Flask, render_template, request, session, send_from_directory, jsonify, url_for, flash, redirect, Response
|
||||
from werkzeug.utils import secure_filename
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy import and_, desc
|
||||
from sqlalchemy.sql import func
|
||||
from datetime import datetime
|
||||
|
||||
@@ -148,7 +148,7 @@ def get_card_dates():
|
||||
@app.route('/api/cardsbydate/<string:datepar>', defaults={'page':1})
|
||||
@app.route('/api/cardsbydate/<string:datepar>/<int:page>')
|
||||
def get_cardsbydate(datepar, page):
|
||||
res = Card.query.with_entities(Card._id, Card.stroke_number, Card.stroke_type, Card.created_on).filter(func.date(Card.created_on, 'localtime') == datepar).paginate(page=page,per_page=20, error_out=False)
|
||||
res = Card.query.with_entities(Card._id, Card.stroke_number, Card.stroke_type, Card.created_on).filter(func.date(Card.created_on, 'localtime') == datepar).order_by(desc(Card.created_on)).paginate(page=page,per_page=20, error_out=False)
|
||||
# Mon, 14 Nov 2016 19:46:09 GMT
|
||||
return jsonify({
|
||||
'cards':[{'_id': i[0], 'stroke_number': i[1], 'stroke_type': i[2], 'created_on': i[3]} for i in res.items],
|
||||
|
||||
Reference in New Issue
Block a user