Skip to content

Commit f9297ab

Browse files
authored
Merge pull request #36 from biojs/visualization_list
Visualization list
2 parents c4bd0ed + e97cb75 commit f9297ab

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

main/management/commands/updatecomponents.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def update_visualizations(component, commit_hash, test=False):
5252
css = []
5353
css_dependencies = buildCSS + css
5454
for dependency in js_dependencies:
55-
if dependency.startswith('https://'):
55+
if dependency.startswith('http') :
5656
dependency, created = JSDependency.objects.get_or_create(component=component, js_url=dependency)
5757
elif dependency.startswith('/'):
5858
dependency_string = dependency
@@ -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)