def title(self, group_id): group = Group.query_by_id(group_id) return group.title
def remove_book(self, group_id, book_id): group = Group.query_by_id(group_id) book = Book.query_by_id(book_id) group.remove_book(book) return "OK"
def leave(self, group_id): user = cherrypy.request.user group = Group.query_by_id(group_id) with session_scope() as s: user.leave_group(s, group)
def index(self, filter = ""): with session_scope() as s: return json.dumps([dict_group(group) for group in Group.list(s, filter)])
def create(self, title, password): group = Group(title, password) with session_scope() as s: s.add(group) return "OK" return "FAIL"
def index(self, filter=""): with session_scope() as s: return json.dumps( [dict_group(group) for group in Group.list(s, filter)])