renkan from notice
authorcavaliet
Fri, 22 Aug 2014 15:02:39 +0200
changeset 314 515a46247b13
parent 313 a3b1046639f3
child 315 5f8d4897c9f7
renkan from notice
.hgignore
src/hdalab/static/hdalab/css/facettes.css
src/hdalab/static/hdalab/img/mind_map_icon.png
src/hdalab/static/hdalab/img/page_icon.png
src/hdalab/static/hdalab/js/gomina.js
src/hdalab/templates/facettes.html
src/hdalab/views/profile.py
--- a/.hgignore	Thu Aug 21 15:05:41 2014 +0200
+++ b/.hgignore	Fri Aug 22 15:02:39 2014 +0200
@@ -29,4 +29,6 @@
 syntax: regexp
 ^run$
 syntax: regexp
-^src/hdabo/config\.py$
\ No newline at end of file
+^src/hdabo/config\.py$
+syntax: regexp
+^web/static/media/thumbnails/renkan/renkan_default_icon\.png\.100x100_q85\.png$
\ No newline at end of file
--- a/src/hdalab/static/hdalab/css/facettes.css	Thu Aug 21 15:05:41 2014 +0200
+++ b/src/hdalab/static/hdalab/css/facettes.css	Fri Aug 22 15:02:39 2014 +0200
@@ -328,6 +328,9 @@
 .content-item p {
     font-size: 12px; margin: 3px 0;
 }
+.mind-map-icon{
+	width: 16px; height: 16px; background: url(../img/mind_map_icon.png) no-repeat; display: inline-block; text-indent:-9999px;
+}
 
 .content-annotation ul {
     list-style : disc; margin: 2px 0; padding-left: 1.5em; font-size: 12px;
Binary file src/hdalab/static/hdalab/img/mind_map_icon.png has changed
Binary file src/hdalab/static/hdalab/img/page_icon.png has changed
--- a/src/hdalab/static/hdalab/js/gomina.js	Thu Aug 21 15:05:41 2014 +0200
+++ b/src/hdalab/static/hdalab/js/gomina.js	Fri Aug 22 15:02:39 2014 +0200
@@ -267,12 +267,13 @@
     if (contentdata && contentdata.length) {
         var _htmlCl = '<ul id="contentlist">'
             + contentdata.map(function(_d) {
+                console.log("coucou", gomNs, gomNs.urls);
                 var _dsurl = gomNs.urls.datasheet.replace(/ID$/,_d.hda_id);
                 var _html = '<li class="content-item"><h3><a href="'
                     + _dsurl
                     + '">'
                     + _d.title
-                    + '</a></h3>'
+                    + '</a>&nbsp;<a class="mind-map-icon" href="' + gomNs.urls.renkan + '?notice=' + _d.hda_id + '" target="_blank">placeholder</a></h3>'
                     + ( typeof _d.coords == "object" ?
                         '<div class="maplet"><img src="http://maps.googleapis.com/maps/api/staticmap?center=47,1.5&zoom=4&size=160x160&maptype=roadmap&markers=color:red%7C'
                         + _d.coords.latitude
--- a/src/hdalab/templates/facettes.html	Thu Aug 21 15:05:41 2014 +0200
+++ b/src/hdalab/templates/facettes.html	Fri Aug 22 15:02:39 2014 +0200
@@ -30,7 +30,8 @@
             'session_info': "{% url 'session_info' %}",
             'countries': "{% static 'hdalab/lib/countries.geo.json' %}",
             'tag_search': "{% url 'tag_search' %}",
-            'datasheet': "{% url 'notice' 'ID' %}"
+            'datasheet': "{% url 'notice' 'ID' %}",
+            'renkan': "{% url 'renkan_edit' %}"
         };
         ZeroClipboard.setMoviePath('{{STATIC_URL}}hdalab/lib/ZeroClipboard.swf');
         </script>
--- a/src/hdalab/views/profile.py	Thu Aug 21 15:05:41 2014 +0200
+++ b/src/hdalab/views/profile.py	Fri Aug 22 15:02:39 2014 +0200
@@ -24,7 +24,7 @@
 from django.views.decorators.csrf import csrf_exempt, csrf_protect
 from django.views.decorators.debug import sensitive_post_parameters
 from django.views.generic import TemplateView, View
-from hdabo.models import Tag
+from hdabo.models import Tag, Datasheet, TaggedSheet
 from hdalab.models.renkan import HdalabRenkan
 from hdalab.views.ajax import filter_generic
 from renkanmanager.models import Renkan
@@ -115,15 +115,7 @@
             rk = get_object_or_404(Renkan, rk_id=rk_id)
             return HttpResponse(rk.content, content_type="application/json")
         
-        # Otherwise we build the datas
-        # Get tags and countries
-        labels = request.GET.get("label", "").split(",")
-        countries = request.GET.get("country", "").split(",")
-        # 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", "category")
-        
+        # Start dict for renkan json
         now = datetime.now().strftime("%Y-%m-%d %H:%M")
         
         content = {
@@ -138,6 +130,72 @@
           "users": [],
         }
         
+        # category image dict
+        cat_dict = {u"Créateur": static("hdalab/img/category_creator.png"),
+                    u"Datation": static("hdalab/img/category_datation.png"),
+                    u"Discipline artistique": static("hdalab/img/category_discipline.png"),
+                    u"Localisation": static("hdalab/img/category_localisation.png"),
+                    u"Ecole/Mouvement": static("hdalab/img/category_movement.png")}
+        
+        
+        # Renkan Project ID
+        project_id = unicode(uuid.uuid1())
+        
+        
+        # If a notice id is set
+        notice_id = request.GET.get("notice", "")
+        if notice_id!="":
+            notice = get_object_or_404(Datasheet, hda_id=notice_id)
+            # We get the ORDERED tags if we display one sheet (case valid = 0 and 1)
+            ordered_tags = TaggedSheet.objects.filter(datasheet=notice).select_related("tag", "tag__dbpedia_fields", "tag__category").order_by('order')[:15]
+            # Prepare Node placer :
+            np = LineNodePlacer()
+            np.init({"datasheet": (1, 1), "tags": (2, len(ordered_tags))})
+            # Place notice :
+            content["nodes"].append({
+                "id": unicode(uuid.uuid1()),
+                "title": notice.title,
+                "description": notice.description,
+                "uri": notice.url,
+                "position": np.get_place("datasheet"),
+                "image": static("hdalab/img/page_icon.png"),
+                "size": 0,
+                "project_id": project_id,
+                "color": None,
+                #"created_by": "roster_user-84fe909f-ba37-48e6-a25f-9d2f129a95b7"
+            })
+            
+            for ot in ordered_tags:
+                t = ot.tag
+                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 = cat_dict[t.category.label]
+                
+                content["nodes"].append({
+                  "id": unicode(uuid.uuid1()),
+                  "title": t.label + ((" (" + t.category.label + ")") if t.category else ""),
+                  "description": t.dbpedia_uri,
+                  "uri": t.dbpedia_uri,
+                  "position": np.get_place("tags"),
+                  "image": img_url,
+                  "size": 0,
+                  "project_id": project_id,
+                  "color": None,
+                  #"created_by": "roster_user-84fe909f-ba37-48e6-a25f-9d2f129a95b7"
+                })
+            
+            response = json.dumps(content)
+            return HttpResponse(response, content_type="application/json")
+        
+        # Otherwise we build the datas
+        # Get tags and countries
+        labels = request.GET.get("label", "").split(",")
+        countries = request.GET.get("country", "").split(",")
+        # 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", "category")
+        
         
         # Get datasheets from ajax filter search
         filter_output = filter_generic(request.GET.get('lang',request.LANGUAGE_CODE), None, ",".join(label_list), ",".join(country_list))
@@ -166,13 +224,6 @@
                     related_tags_dict[c["id"]].append(t["id"])
         
         
-        cat_dict = {u"Créateur": static("hdalab/img/category_creator.png"),
-                    u"Datation": static("hdalab/img/category_datation"),
-                    u"Discipline artistique": static("hdalab/img/category_discipline"),
-                    u"Localisation": static("hdalab/img/category_localisation"),
-                    u"Ecole/Mouvement": static("hdalab/img/category_movement")}
-        
-        
         # If possible, we search a dbpedia_fields thumbnail or category thumbnail for related tags
         r_tags = [t["label"] for t in related_tags if t["thumbnail"] is None or t["thumbnail"]=="" ]
         r_tags = Tag.objects.filter( label__in=r_tags ).select_related("dbpedia_fields", "category")
@@ -193,8 +244,6 @@
         np = LineNodePlacer()
         np.init({"tags": (1, len(all_tags)), "datasheet": (2, len(filter_output["contents"])), "related": (3, len(related_tags))})
         
-        project_id = unicode(uuid.uuid1())
-        
         for t in all_tags:
             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: