From a3d54b7426284fe3d06534c923ba8d78b31682fb Mon Sep 17 00:00:00 2001 From: xavier Date: Thu, 11 May 2017 16:00:21 +0200 Subject: [PATCH 01/13] Add ontology tree d3 --- datasets/views.py | 6 ++ freesound_datasets/urls.py | 1 + templates/base.html | 2 + templates/ontology_tree.html | 169 +++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 templates/ontology_tree.html diff --git a/datasets/views.py b/datasets/views.py index 5acf7651..528da76a 100644 --- a/datasets/views.py +++ b/datasets/views.py @@ -22,6 +22,7 @@ from utils.async_tasks import data_from_async_task import os import random +import json ####################### @@ -98,6 +99,11 @@ def taxonomy_node(request, short_name, node_id): return render(request, 'taxonomy_node.html', {'dataset': dataset, 'node': node}) +def ontology_tree(request, short_name): + dataset = get_object_or_404(Dataset, short_name=short_name) + ontology = json.load(open('ontology_html5.json', encoding='utf-8')) + return render(request, 'ontology_tree.html', {'dataset': dataset, 'ontology':json.dumps(ontology)}) + ############################# # CONTRIBUTE TO DATASET VIEWS ############################# diff --git a/freesound_datasets/urls.py b/freesound_datasets/urls.py index 23ca5e9f..d8bfee9e 100644 --- a/freesound_datasets/urls.py +++ b/freesound_datasets/urls.py @@ -28,6 +28,7 @@ url(r'^(?P[^\/]+)/contribute/$', contribute, name='contribute'), url(r'^(?P[^\/]+)/contribute/validate_annotations/$', contribute_validate_annotations, name='contribute-validate-annotations'), url(r'^(?P[^\/]+)/contribute/validate_annotations/(?P[^\/]+)/$', contribute_validate_annotations_category, name='contribute-validate-annotations-category'), + url(r'^(?P[^\/]+)/tree/$', ontology_tree, name='exploration-tree'), ] if settings.DEBUG: diff --git a/templates/base.html b/templates/base.html index bcd76e1c..fb52a814 100644 --- a/templates/base.html +++ b/templates/base.html @@ -16,6 +16,7 @@ + {% block extra_head %} {% endblock extra_head%} @@ -38,6 +39,7 @@ {% else %} Download {% endif %} + Ontology {% endif %}