changeset 14:b33f35b57b93

added authors to details view.
author casties
date Mon, 05 Oct 2015 19:30:28 +0200
parents 394bd5cfc508
children 7c4475cd747a
files ismi-python-neo4jrestclient/ismi-vis.py ismi-python-neo4jrestclient/static/commentaries_authors.html
diffstat 2 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ismi-python-neo4jrestclient/ismi-vis.py	Mon Oct 05 18:56:19 2015 +0200
+++ b/ismi-python-neo4jrestclient/ismi-vis.py	Mon Oct 05 19:30:28 2015 +0200
@@ -130,27 +130,33 @@
 @app.route("/textandcommentaries/<text_id>")
 def get_textandcommentaries(text_id):
     query = ("match (t:TEXT {ismi_id:{text_id}})"
-             " optional match (s:TEXT)<-[sr:is_commentary_on]-(t)"
-             " optional match (t)<-[cr:is_commentary_on]-(c:TEXT)" 
-             " return t,s.label, s.ismi_id,c.label,c.ismi_id")
+             " optional match (t)-[:was_created_by]->(a:PERSON)"
+             " optional match (s:TEXT)<-[:is_commentary_on]-(t)"
+             " optional match (s)-[:was_created_by]->(sa:PERSON)"
+             " optional match (t)<-[:is_commentary_on]-(c:TEXT)" 
+             " optional match (c)-[:was_created_by]->(ca:PERSON)"
+             " return t,a.label,s.label,s.ismi_id,sa.label,c.label,c.ismi_id,ca.label")
     print("query:%s"%query)
-    results = gdb.query(query, returns=(Node,str,str,str,str), 
+    results = gdb.query(query, returns=(Node,str,str,str,str,str,str,str), 
                         params={"text_id": int(text_id)})
     
     print("result:%s"%results)
     text = None
+    author = None
     scs = {}
     cs = {}
-    for [t,s_label,s_id,c_label,c_id] in results:
+    for [t,a_label,s_label,s_id,sa_label,c_label,c_id,ca_label] in results:
         text = t
+        author = a_label
         if s_id is not None and s_id != "None":
-            scs[int(s_id)] = s_label
+            scs[int(s_id)] = {"title": s_label, "author":sa_label}
             
         if c_id is not None and c_id != "None":
-            cs[int(c_id)] = c_label
+            cs[int(c_id)] = {"title": c_label, "author":ca_label}
         
     print("text:%s scs:%s cs:%s"%(text, scs, cs))
     return Response(dumps({"title": text['label'], "attrs": text.properties, 
+                           "author": author,
                            "commenting": scs, "commentaries": cs}),
                     mimetype="application/json")
 
--- a/ismi-python-neo4jrestclient/static/commentaries_authors.html	Mon Oct 05 18:56:19 2015 +0200
+++ b/ismi-python-neo4jrestclient/static/commentaries_authors.html	Mon Oct 05 19:30:28 2015 +0200
@@ -44,6 +44,7 @@
             <table id="results" class="table table-striped table-hover">
                 <thead>
                 <tr>
+                    <th>Author (translit)</th>
                     <th>Title (translit)</th>
                     <th>Title (arabic)</th>
                     <th>ismi_id</th>
@@ -95,6 +96,7 @@
                         if (!data) return;
                         $("#title").text(data.title);
                         var $list = $("#info").empty();
+                        $list.append($("<li> author: " + data.author + "</li>"));
                         for (var key in data.attrs) {
                             var val = data.attrs[key];
                             if (key === "link") {
@@ -105,13 +107,13 @@
                         var $commentaries = $("#commentaries").empty();
                         for (var key in data.commentaries) {
                             var val = data.commentaries[key];
-                            $commentaries.append($("<li>" + val + " [<span class=\"text_id\">" + key + "</span>]" + "</li>")
+                            $commentaries.append($("<li>" + val.title + " [<span class=\"text_id\">" + key + "</span>] by " + val.author + "</li>")
                             .click(function() { showText($(this).find("span.text_id").text());}));
                         }
                         var $commenting = $("#commenting").empty();
                         for (var key in data.commenting) {
                             var val = data.commenting[key];
-                            $commenting.append($("<li>" + val + " [<span class=\"text_id\">" + key + "</span>]" + "</li>")
+                            $commenting.append($("<li>" + val.title + " [<span class=\"text_id\">" + key + "</span>] by " + val.author + "</li>")
                             .click(function() { showText($(this).find("span.text_id").text());}));
                         }
                     }, "json");