diff --git a/app/models.py b/app/models.py index 4981498e..fbc40990 100644 --- a/app/models.py +++ b/app/models.py @@ -292,6 +292,18 @@ class Topic(db.Model): parent_id = db.Column(db.Integer) communities = db.relationship('Community', lazy='dynamic', backref='topic', cascade="all, delete-orphan") + def path(self): + return_value = [self.machine_name] + parent_id = self.parent_id + while parent_id is not None: + parent_topic = Topic.query.get(parent_id) + if parent_topic is None: + break + return_value.append(parent_topic.machine_name) + parent_id = parent_topic.parent_id + return_value = list(reversed(return_value)) + return '/'.join(return_value) + class Community(db.Model): query_class = FullTextSearchQuery diff --git a/app/templates/list_topics.html b/app/templates/list_topics.html index cf57ab2f..5a928ec1 100644 --- a/app/templates/list_topics.html +++ b/app/templates/list_topics.html @@ -10,7 +10,11 @@ {% if len(topics) > 0 %} {% macro render_topic(topic, depth) %} - {{ '--' * depth }} {{ topic['topic'].name }} + {{ '--' * depth }} + {% if depth == 0 %}{% endif %} + {{ topic['topic'].name }} + {% if depth == 0 %}{% endif %} + {% if topic['children'] %} {% for topic in topic['children'] %}