# HG changeset patch # User cavaliet # Date 1408618898 -7200 # Node ID 1c2c8e16bdbe91823de97bbbe22e8c9e7a5af64e # Parent 6c16170f947f926bcf91c06eb5c12ccbf8b0bbb9 default node image for categories diff -r 6c16170f947f -r 1c2c8e16bdbe src/hdalab/static/hdalab/img/category_creator.png Binary file src/hdalab/static/hdalab/img/category_creator.png has changed diff -r 6c16170f947f -r 1c2c8e16bdbe src/hdalab/static/hdalab/img/category_datation.png Binary file src/hdalab/static/hdalab/img/category_datation.png has changed diff -r 6c16170f947f -r 1c2c8e16bdbe src/hdalab/static/hdalab/img/category_discipline.png Binary file src/hdalab/static/hdalab/img/category_discipline.png has changed diff -r 6c16170f947f -r 1c2c8e16bdbe src/hdalab/static/hdalab/img/category_localisation.png Binary file src/hdalab/static/hdalab/img/category_localisation.png has changed diff -r 6c16170f947f -r 1c2c8e16bdbe src/hdalab/static/hdalab/img/category_movement.png Binary file src/hdalab/static/hdalab/img/category_movement.png has changed diff -r 6c16170f947f -r 1c2c8e16bdbe src/hdalab/views/profile.py --- 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,