From 82fd22b8e8228c71ec99c1f170a49348124f1006 Mon Sep 17 00:00:00 2001 From: Flancian <0@flancia.org> Date: Sun, 17 Jan 2021 22:03:19 +0100 Subject: [PATCH] Fix pushing to non-existent nodes. --- app/agora.py | 2 ++ app/db.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/agora.py b/app/agora.py index a5dc5a4..9c7d607 100644 --- a/app/agora.py +++ b/app/agora.py @@ -111,6 +111,8 @@ def node(node): # earlier in the list means more highly ranked. n.subnodes = util.uprank(n.subnodes, users=['agora', 'flancian']) + print("in agora.py: ", n.pushed_subnodes()) + search_subnodes = db.search_subnodes(node) return render_template( diff --git a/app/db.py b/app/db.py index f3edfc4..5fca93c 100644 --- a/app/db.py +++ b/app/db.py @@ -57,7 +57,8 @@ class Graph: # this used to be even worse :) try: nodes = [node for node in G.nodes() if node.wikilink == uri] - return nodes[0] + node = nodes[0] + return node except (KeyError, IndexError): # We'll handle 404 in the template, as we want to show backlinks to non-existent nodes. # Return an empty. @@ -228,7 +229,7 @@ class Node: # Congratulations! You've gotten to the hackiest place in the [[agora]]. # ...as of the time of writing :) subnodes = [] - if other in self.push_nodes(): + if other.wikilink in [n.wikilink for n in self.push_nodes()]: for subnode in self.subnodes: # I tried parsing the marko tree but honestly this seemed easier/simpler. html = render.markdown(subnode.content)