--- a/src/hdalab/views/profile.py Wed Aug 20 16:09:56 2014 +0200
+++ b/src/hdalab/views/profile.py Thu Aug 21 13:01:38 2014 +0200
@@ -18,6 +18,7 @@
from django.shortcuts import get_object_or_404, redirect
from django.shortcuts import resolve_url
from django.template.response import TemplateResponse
+from django.templatetags.static import static
from django.utils.http import is_safe_url
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_exempt, csrf_protect
@@ -121,8 +122,7 @@
# Tags arrive with french label, countries with dbpedia uri
label_list = [t for t in labels if t!=""]
country_list = [c for c in countries if c!=""]
- all_tags = Tag.objects.filter( Q(label__in=label_list) | Q(dbpedia_uri__in=country_list) ).select_related("dbpedia_fields")
-
+ all_tags = Tag.objects.filter( Q(label__in=label_list) | Q(dbpedia_uri__in=country_list) ).select_related("dbpedia_fields", "category")
now = datetime.now().strftime("%Y-%m-%d %H:%M")
@@ -172,14 +172,25 @@
project_id = unicode(uuid.uuid1())
+ cat_dict = {u"Créateur":"category_creator",
+ u"Datation":"category_datation",
+ u"Discipline artistique":"category_discipline",
+ u"Localisation": "category_localisation",
+ u"Ecole/Mouvement":"category_movement"}
+
for t in all_tags:
+ logger.debug(t.category)
+ img_url = t.dbpedia_fields.thumbnail if hasattr(t, 'dbpedia_fields') and t.dbpedia_fields and t.dbpedia_fields.thumbnail else None
+ if img_url is None and t.category is not None:
+ img_url = static("hdalab/img/" + cat_dict[t.category.label] + ".png")
+
content["nodes"].append({
"id": unicode(uuid.uuid1()),
- "title": t.label,
+ "title": t.label + ((" (" + t.category.label + ")") if t.category else ""),
"description": t.dbpedia_uri,
"uri": t.dbpedia_uri,
"position": np.get_place("tags"),
- "image": t.dbpedia_fields.thumbnail if hasattr(t, 'dbpedia_fields') and t.dbpedia_fields and t.dbpedia_fields.thumbnail else None,
+ "image": img_url,
"size": 0,
"project_id": project_id,
"color": None,