added some desired features
[public/library.git] / librarian.py
index 8806205..eee1ec6 100755 (executable)
@@ -3,7 +3,7 @@
 import curses
 import dbLayer as db
 import browser
-import bookForm
+import form
 import helpBar
 
 import bookData
@@ -13,7 +13,6 @@ stdscr=0
 hb=0
 
 menu_commands = [(' q','quit')]
-browser_commands = [(' u','update'), (' d','delete'), (' q','quit')]
 
 def menutest(s, l):
     global stdscr
@@ -83,10 +82,11 @@ def redrawMenu(w,items,highlight):
 def addForm():
     w=curses.newwin(1,1)
     (my,mx)=stdscr.getmaxyx()
+    bf = form.bookForm(w,hb)
     (r,c)=w.getmaxyx()
     w.mvwin((my-r)/2,(mx-c)/2)
-    bf = bookForm.bookForm(w)
-    bf.lookup=bookData.openLibrary
+    bf.lookup_isbn=bookData.openLibrary_isbn
+    bf.lookup_lccn=bookData.openLibrary_lccn
     bf.caption='Add a Book'
     bf.blabel = 'Add'
     book = bf.eventLoop()
@@ -99,37 +99,36 @@ def updateMenu():
     w.addstr("I will be used to update or modify book records")
     w.refresh()
 
-def deleteMenu():
-    w=curses.newwin(1,50,10,10)
-    w.addstr("I will be used to delete book records")
-    w.refresh()
+def trashMenu():
+    (my,mx)=stdscr.getmaxyx()
+    w=curses.newwin(20,80,(my-20)/2,(mx-80)/2)
+    b = browser.trashBrowser(w,hb)
+    b.refreshBooks()
+    b.eventLoop()
+    b.clear()
 
 def browseMenu():
     (my,mx)=stdscr.getmaxyx()
     w=curses.newwin(20,80,(my-20)/2,(mx-80)/2)
-    b = browser.bookBrowser(w)
+    b = browser.bookBrowser(w,hb)
     b.refreshBooks()
-    hb.commands=browser_commands
-    hb.refresh()
     b.eventLoop()
     b.clear()
 
 def catMenu():
     (my,mx)=stdscr.getmaxyx()
     w=curses.newwin(10,40,(my-10)/2,(mx-40)/2)
-    c = browser.categoryBrowser(w)
+    c = browser.categoryBrowser(w,hb)
     c.refreshCategories()
     c.sortByColumn('category')
-    hb.commands=browser_commands
-    hb.refresh()
     c.eventLoop()
     c.clear()
 
 
 m = [("Browse Library", browseMenu),
-     ("Add Book or other item", addForm),
-     ("View the categories", catMenu),
-     ("Remove book from catalogue", deleteMenu),
+     ("Add Book", addForm),
+     ("Categories", catMenu),
+     ("View Trash", trashMenu),
      ("",exit),
      ("Exit", exit)]
 curses.wrapper(menutest, m)