Fix sorting in /videos/<id>/comments API endpoint

master
Nikola Forró 6 years ago
parent c52c8b7d43
commit c553d75cc9

@ -151,6 +151,8 @@ class CommentsResource(flask_restful.Resource):
if args['sort_order'] == 'random': if args['sort_order'] == 'random':
q = q.order_by(sqlalchemy.func.random()) q = q.order_by(sqlalchemy.func.random())
elif args['sort_by']: elif args['sort_by']:
col = getattr(Association, args['sort_by'], None)
if not col:
col = getattr(Comment, args['sort_by'], None) col = getattr(Comment, args['sort_by'], None)
if col: if col:
if args['sort_order']: if args['sort_order']:

Loading…
Cancel
Save