示例#1
0
 def get(self):
     
     # Get all the displayable books
     books_query = Book.query(ancestor=ROOT_BOOK_KEY)  
     # Get the books currently in the cart
     cart_query = []
     
     # check for a person and filter the books
     if self.person:
         books_query = books_query.filter(ndb.OR(Book.cart_key == None, Book.cart_key == self.person.key))
         cart_query = self.person.get_cart()
     else:
         # remove all the books that are in someone's cart
         books_query = books_query.filter(Book.cart_key == None)    
     books_query = books_query.order(-Book.last_touch_date_time)
     
     # Get additional details needed to populate lists
     dept_query = Department.query(ancestor=ROOT_DEPT_KEY).order(Department.abbrev)
     book_conditions = Book.get_conditions()
     
     self.values.update({"books_query": books_query,
                         "cart_query" : cart_query,
                         "dept_query": dept_query, 
                         "book_conditions": book_conditions})        
     self.render(**self.values)
示例#2
0
 def get(self):
     books_query = self.person.get_books_for_sale()
     dept_query = Department.query(ancestor=ROOT_DEPT_KEY).order(Department.abbrev)
     book_conditions = Book.get_conditions()
     self.values.update({"books_query": books_query,
                         "dept_query": dept_query, 
                         "book_conditions": book_conditions})           
     self.render(**self.values)
示例#3
0
    def get(self):
        books_query = Book.query(ancestor=ROOT_BOOK_KEY).order(-Book.last_touch_date_time)
        
        # Get additional details needed to populate lists
        dept_query = Department.query(ancestor=ROOT_DEPT_KEY).order(Department.abbrev)
        book_conditions = Book.get_conditions()

        # Perform the search from the "q"uery param
        q = self.request.get("q")
        if q:
            q = q.lower()
            books_query = books_query.filter(ndb.OR(Book.title_lower == q,
                                Book.dept == q, 
                                Book.author_lower == q, 
                                Book.isbn == q))

        self.values.update({"books_query": books_query,
                            "dept_query": dept_query, 
                            "book_conditions": book_conditions})        
        self.render(**self.values)