Commit eef9be26 authored by delanoe's avatar delanoe

[FIX ERGO] Corpora ordered by name.

parent 8a0bb9e3
...@@ -101,13 +101,16 @@ class Node(Base): ...@@ -101,13 +101,16 @@ class Node(Base):
# session.add(self) # session.add(self)
# session.commit() # 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. """Return a query to all the direct children of the current node.
Allows filtering by typename (see `constants.py`) Allows filtering by typename (see `constants.py`)
""" """
query = session.query(Node).filter(Node.parent_id == self.id) query = session.query(Node).filter(Node.parent_id == self.id)
if typename is not None: if typename is not None:
query = query.filter(Node.typename == typename) query = query.filter(Node.typename == typename)
if order is not None:
query = query.order_by(Node.name)
return query return query
def add_child(self, **kwargs): def add_child(self, **kwargs):
......
...@@ -110,7 +110,7 @@ def project(request, project_id): ...@@ -110,7 +110,7 @@ def project(request, project_id):
# corpora within this project # corpora within this project
corpora = project.children('CORPUS').all() corpora = project.children('CORPUS', order=True).all()
sourcename2corpora = defaultdict(list) sourcename2corpora = defaultdict(list)
for corpus in corpora: for corpus in corpora:
# we only consider the first resource of the corpus to determine its type # 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