Commit eef9be26 authored by delanoe's avatar delanoe

[FIX ERGO] Corpora ordered by name.

parent 8a0bb9e3
......@@ -101,13 +101,16 @@ class Node(Base):
# session.add(self)
# session.commit()
def children(self, typename=None):
def children(self, typename=None, order=None):
"""Return a query to all the direct children of the current node.
Allows filtering by typename (see `constants.py`)
"""
query = session.query(Node).filter(Node.parent_id == self.id)
if typename is not None:
query = query.filter(Node.typename == typename)
if order is not None:
query = query.order_by(Node.name)
return query
def add_child(self, **kwargs):
......
......@@ -110,7 +110,7 @@ def project(request, project_id):
# corpora within this project
corpora = project.children('CORPUS').all()
corpora = project.children('CORPUS', order=True).all()
sourcename2corpora = defaultdict(list)
for corpus in corpora:
# we only consider the first resource of the corpus to determine its type
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment