Made it possible to view uncategorized books
Also "specialized" lists of books (categorized, on shelf, checked out, uncategorized) don't revert to the main book list when refreshing.
This commit is contained in:
parent
91f1ff9c55
commit
89c66c8188
19
librarian
19
librarian
|
@ -119,13 +119,23 @@ def trashMenu():
|
||||||
b.eventLoop()
|
b.eventLoop()
|
||||||
b.clear()
|
b.clear()
|
||||||
|
|
||||||
|
def uncategorizedMenu():
|
||||||
|
w=curses.newwin(3,5)
|
||||||
|
b = browser.bookBrowser(w,hb)
|
||||||
|
(r,c) = w.getmaxyx()
|
||||||
|
(my,mx)=stdscr.getmaxyx()
|
||||||
|
w.mvwin((my-r)//2 -2, (mx-c)//2)
|
||||||
|
b.refreshBooksUncategorized()
|
||||||
|
b.eventLoop()
|
||||||
|
b.clear()
|
||||||
|
|
||||||
def checkedout_menu():
|
def checkedout_menu():
|
||||||
w=curses.newwin(3,5)
|
w=curses.newwin(3,5)
|
||||||
b = browser.bookBrowser(w,hb)
|
b = browser.bookBrowser(w,hb)
|
||||||
(r,c) = w.getmaxyx()
|
(r,c) = w.getmaxyx()
|
||||||
(my,mx)=stdscr.getmaxyx()
|
(my,mx)=stdscr.getmaxyx()
|
||||||
w.mvwin((my-r)//2 -2, (mx-c)//2)
|
w.mvwin((my-r)//2 -2, (mx-c)//2)
|
||||||
b.load_data(db.get_checkedout_books())
|
b.refreshBooksCheckedout()
|
||||||
b.columnDefs = [("id",0,3),
|
b.columnDefs = [("id",0,3),
|
||||||
("uwid",0,8),
|
("uwid",0,8),
|
||||||
("date",0,10),
|
("date",0,10),
|
||||||
|
@ -140,19 +150,19 @@ def onshelf_menu():
|
||||||
(r,c) = w.getmaxyx()
|
(r,c) = w.getmaxyx()
|
||||||
(my,mx)=stdscr.getmaxyx()
|
(my,mx)=stdscr.getmaxyx()
|
||||||
w.mvwin((my-r)//2 -2, (mx-c)//2)
|
w.mvwin((my-r)//2 -2, (mx-c)//2)
|
||||||
b.load_data(db.get_onshelf_books())
|
b.refreshBooksOnshelf()
|
||||||
b.eventLoop()
|
b.eventLoop()
|
||||||
b.clear()
|
b.clear()
|
||||||
|
|
||||||
def co_menu():
|
def co_menu():
|
||||||
w=curses.newwin(1,1)
|
w=curses.newwin(1,1)
|
||||||
(my,mx)=stdscr.getmaxyx()
|
(my,mx)=stdscr.getmaxyx()
|
||||||
co.checkout_procedure(w,hb,my//2,mx//2,mx)
|
co.checkout_procedure(w,hb,my//2,mx//2,mx)
|
||||||
|
|
||||||
def return_menu():
|
def return_menu():
|
||||||
w=curses.newwin(1,1)
|
w=curses.newwin(1,1)
|
||||||
(my,mx)=stdscr.getmaxyx()
|
(my,mx)=stdscr.getmaxyx()
|
||||||
co.return_procedure(w,hb,my//2,mx//2,mx)
|
co.return_procedure(w,hb,my//2,mx//2,mx)
|
||||||
|
|
||||||
def catMenu():
|
def catMenu():
|
||||||
(my,mx)=stdscr.getmaxyx()
|
(my,mx)=stdscr.getmaxyx()
|
||||||
|
@ -172,6 +182,7 @@ if __name__ == "__main__":
|
||||||
("Add Book", addForm),
|
("Add Book", addForm),
|
||||||
("Categories", catMenu),
|
("Categories", catMenu),
|
||||||
("View Trash", trashMenu),
|
("View Trash", trashMenu),
|
||||||
|
("View Uncategorized Books", uncategorizedMenu),
|
||||||
("",exit),
|
("",exit),
|
||||||
("Check Out a Book", co_menu),
|
("Check Out a Book", co_menu),
|
||||||
("Return a Book", return_menu),
|
("Return a Book", return_menu),
|
||||||
|
|
|
@ -91,7 +91,7 @@ def addBook(book):
|
||||||
if v!="":
|
if v!="":
|
||||||
cols.append(_colify(k))
|
cols.append(_colify(k))
|
||||||
vals.append(_stringify(v))
|
vals.append(_stringify(v))
|
||||||
|
|
||||||
query = ("INSERT INTO "+_book_table+" ("+", ".join(cols)+") VALUES ("+
|
query = ("INSERT INTO "+_book_table+" ("+", ".join(cols)+") VALUES ("+
|
||||||
", ".join(vals)+");")
|
", ".join(vals)+");")
|
||||||
c.execute(query)
|
c.execute(query)
|
||||||
|
@ -148,6 +148,18 @@ def getRemovedBooks():
|
||||||
c.close()
|
c.close()
|
||||||
return books
|
return books
|
||||||
|
|
||||||
|
def getUncategorizedBooks():
|
||||||
|
conn = sqlite3.connect(_catalogue_db_file)
|
||||||
|
c = conn.cursor()
|
||||||
|
query = ("SELECT "+",".join(map(_colify,columns))+" FROM "+_book_table+
|
||||||
|
" WHERE id NOT IN (SELECT id FROM "+_book_category_table+")"+
|
||||||
|
" AND deleted=0;")
|
||||||
|
c.execute(query)
|
||||||
|
books = [_query_to_book(b) for b in c]
|
||||||
|
c.close()
|
||||||
|
return books
|
||||||
|
|
||||||
|
|
||||||
def get_book(bookid):
|
def get_book(bookid):
|
||||||
conn = sqlite3.connect(_catalogue_db_file)
|
conn = sqlite3.connect(_catalogue_db_file)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
|
|
@ -375,7 +375,20 @@ class bookBrowser(browserWindow):
|
||||||
self.load_data(db.get_books())
|
self.load_data(db.get_books())
|
||||||
|
|
||||||
def refreshBooksInCategory(self,cat):
|
def refreshBooksInCategory(self,cat):
|
||||||
self.load_data(db.getBooksByCategory(cat))
|
self.refreshBooks = lambda : self.load_data(db.getBooksByCategory(cat))
|
||||||
|
self.refreshBooks()
|
||||||
|
|
||||||
|
def refreshBooksUncategorized(self):
|
||||||
|
self.refreshBooks = lambda : self.load_data(db.getUncategorizedBooks())
|
||||||
|
self.refreshBooks()
|
||||||
|
|
||||||
|
def refreshBooksCheckedout(self):
|
||||||
|
self.refreshBooks = lambda : self.load_data(db.get_checkedout_books())
|
||||||
|
self.refreshBooks()
|
||||||
|
|
||||||
|
def refreshBooksOnshelf(self):
|
||||||
|
self.refreshBooks = lambda : self.load_data(db.get_onshelf_books())
|
||||||
|
self.refreshBooks()
|
||||||
|
|
||||||
def handleInput(self,ch):
|
def handleInput(self,ch):
|
||||||
browserWindow.handleInput(self,ch)
|
browserWindow.handleInput(self,ch)
|
||||||
|
|
Loading…
Reference in New Issue