Added search for books that are signed out.
authorMichael Gregson <mgregson@csclub.uwaterloo.ca>
Wed, 28 Jan 2009 05:47:45 +0000 (00:47 -0500)
committerMichael Gregson <mgregson@csclub.uwaterloo.ca>
Wed, 28 Jan 2009 05:47:45 +0000 (00:47 -0500)
Book signouts now display due dates.

ceo/library.py
ceo/urwid/library.py

index e86fff9..8066b4a 100644 (file)
@@ -77,7 +77,7 @@ class Book(SQLObject):
         if signouts.count() > 0:
             book += "\nSigned Out: "
             for s in signouts:
-                book += s.username + ", "
+                book += s.username + " (" + s.due_date + "), "
 
         book = book.strip(", ")
         
index 9761aaf..df6ea42 100644 (file)
@@ -31,6 +31,7 @@ def search_books(data):
     """
     menu = make_menu([
         ("Overdue Books", overdue_books, None),
+        ("Signed Out Books", outbooks_search, None),
     ])
     push_window(menu, "Book Search")
 
@@ -52,6 +53,24 @@ def overdue_books(data):
 
     None
 
+def outbooks_search(data):
+    """
+    Display a list of all books that are signed out.
+    """
+    overdue = lib.Signout.select(lib.Signout.q.indate==None)
+
+    widgets = []
+
+    for s in overdue:
+        widgets.append(urwid.AttrWrap(ButtonText(None, s.book, str(s.book)),
+                                      None, 'selected'))
+        widgets.append(urwid.Divider())
+        
+    push_window(urwid.ListBox(widgets))
+
+    None
+
+
 def checkout_book(data):
     """
     Display the book checkout wizard.