From cec08e05eb0da0b6965ddec56522ee4c9045f3bc Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 18 Feb 2012 14:31:43 +0100 Subject: Fixed directory browsing and added player control buttons. --- db.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'db.py') diff --git a/db.py b/db.py index aadcda5..aa7ea6a 100644 --- a/db.py +++ b/db.py @@ -38,11 +38,18 @@ class Directory(Base): session.commit() return directory + @staticmethod + def get_by_id(session, id): + return session.query(Directory).filter(Directory.id == id).one() + def get_relpath(self): return os.path.relpath(self.path, config.get('music_root')) def dict(self): + # FIXME: Recursively returns all parents, this is not very efficient. return { + 'id': self.id, + 'parent': self.parent.dict() if self.parent else None, 'type': 'dir', 'name': self.get_relpath(), 'metadata': {}, -- cgit v1.2.3