Return empty list for datatable errors

This commit is contained in:
JonnyWong16 2021-01-27 11:51:27 -08:00
parent 5ca8184948
commit 674966510d
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
4 changed files with 15 additions and 22 deletions

View file

@ -197,8 +197,7 @@ def get_collections_list(section_id=None, **kwargs):
default_return = {'recordsFiltered': 0,
'recordsTotal': 0,
'draw': 0,
'data': 'null',
'error': 'Unable to get collections: missing section_id.'}
'data': []}
return default_return
collections = get_collections(section_id=section_id)
@ -282,8 +281,7 @@ def get_playlists_list(section_id=None, user_id=None, **kwargs):
default_return = {'recordsFiltered': 0,
'recordsTotal': 0,
'draw': 0,
'data': 'null',
'error': 'Unable to get playlists: missing section_id.'}
'data': []}
return default_return
playlists = get_playlists(section_id=section_id, user_id=user_id)
@ -313,8 +311,7 @@ class Libraries(object):
default_return = {'recordsFiltered': 0,
'recordsTotal': 0,
'draw': 0,
'data': 'null',
'error': 'Unable to execute database query.'}
'data': []}
data_tables = datatables.DataTables()
@ -456,8 +453,9 @@ class Libraries(object):
default_return = {'recordsFiltered': 0,
'recordsTotal': 0,
'draw': 0,
'data': 'null',
'error': 'Unable to execute database query.'}
'data': [],
'filtered_file_size': 0,
'total_file_size': 0}
if not session.allow_session_library(section_id):
return default_return