Browse Source

fix: get => filter

master
xuxiaofei 4 years ago
parent
commit
7e02e5ed83
  1. 19
      vislib/views/source.py

19
vislib/views/source.py

@ -93,14 +93,15 @@ def sourceDetail(request, sourceId):
def sourceTables(request, sourceId): def sourceTables(request, sourceId):
json_data = [] json_data = []
try: try:
tables = SourceDataTable.objects.get(database=sourceId) tables = SourceDataTable.objects.filter(database=sourceId)
tables = serializers.serialize('json', [tables])
tables = serializers.serialize('json', tables)
tables = json.loads(tables) tables = json.loads(tables)
for table in tables: for table in tables:
json_data.append(table['fields']) json_data.append(table['fields'])
except: except Exception as e:
print('no linked tables before') print('no linked tables before', e)
source = SourceDataBase.objects.get(source_id=sourceId) source = SourceDataBase.objects.get(source_id=sourceId)
source = serializers.serialize('json', [source]) source = serializers.serialize('json', [source])
@ -161,17 +162,15 @@ def sourceTableSave(request):
@csrf_exempt @csrf_exempt
def sourceLinkedTables(request, sourceId): def sourceLinkedTables(request, sourceId):
try: try:
tables = SourceDataTable.objects.get(database=sourceId) tables = SourceDataTable.objects.filter(database=sourceId)
print(tables) tables = serializers.serialize('json', tables)
tables = serializers.serialize('json', [tables])
print(tables)
tables = json.loads(tables) tables = json.loads(tables)
print(tables)
json_data = [] json_data = []
for table in tables: for table in tables:
json_data.append(table['fields']) json_data.append(table['fields'])
except: except Exception as e:
json_data = [] json_data = []
printz(e)
return JsonResponse({'code': 20000, 'message': 'success', 'data': json_data }) return JsonResponse({'code': 20000, 'message': 'success', 'data': json_data })

Loading…
Cancel
Save