Skip to content

Commit e97cb75

Browse files
committed
Visualization list JSON Response
1 parent b599396 commit e97cb75

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

main/management/commands/updatecomponents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def update_visualizations(component, commit_hash, test=False):
7777
except:
7878
req_dependency = JSDependency.objects.create(component=component, sniper_data_value=dependency_string, js_url=dependency)
7979
for dependency in css_dependencies:
80-
if dependency.startswith('https://'):
80+
if dependency.startswith('http'):
8181
dependency, created = CSSDependency.objects.get_or_create(component=component, css_url=dependency)
8282
elif dependency.startswith('/'):
8383
dependency_string = dependency

main/views.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,9 @@ def generate_random_snippets(request):
8686
try:
8787
count = request.GET.get('q')
8888
if int(count) > Component.objects.filter(sniperdata__isnull=False).count():
89-
return HttpResponse('Input number "q" must not exceed %s.'%str(Component.objects.filter(sniperdata__isnull=False).count()))
89+
return JsonResponse({'error':'Input number q must not exceed %s.'%str(Component.objects.filter(sniperdata__isnull=False).count())})
9090
components = Component.objects.filter(sniperdata__isnull=False)
9191
required_components = np.random.choice(components, int(count), replace=False)
92-
req_str = '\n'.join([component.name for component in required_components])
93-
print req_str
94-
return HttpResponse(req_str, content_type="text/plain")
92+
return JsonResponse({'components':BaseComponentSerializer(required_components, many=True).data})
9593
except:
96-
return HttpResponse('Input number as query "q" in the URL.')
94+
return JsonResponse({'error':'Input number as query q in the URL.'})

0 commit comments

Comments
 (0)