Beispiel #1
0
 def on_delete(info):
     book_key_str = info['book_key']
     old_borrower = info.get('old_borrower', None)
     owner = info['owner']
     from bookcache import CacheBookIdsOwned, CacheBookIdsBorrowed, CachedBook
     CacheBookIdsOwned.remove_book(owner, book_key_str)
     CachedBook.reset(book_key_str)
     if old_borrower: CacheBookIdsBorrowed.remove_book(old_borrower, book_key_str)
Beispiel #2
0
 def change_nickname(self, new_nick):
     self.wtmb_nickname = new_nick
     self.put()
     from bookcache import CachedBook, CacheBookIdsOwned, CacheBookIdsBorrowed
     for book_key_str in CacheBookIdsOwned.get(self.key()):
         CachedBook.reset(book_key_str)
     for book_key_str in CacheBookIdsBorrowed.get(self.key()):
         CachedBook.reset(book_key_str)
Beispiel #3
0
 def on_lent(book):
     mail.send_mail(
                  sender=AppUser.me().email(),
                  to=book.borrower.email(),
                  cc=(WTMB_SENDER, AppUser.me().email()),
                  subject='[whotookmybook] %s' % book.title,
                  body="%s has lent this book to %s" % (book.owner.display_name(), book.borrower.display_name()))
     from bookcache import CachedBook, CacheBookIdsBorrowed
     book_key_str = str(book.key())
     CacheBookIdsBorrowed.add_book(str(book.borrower.key()), book_key_str)
     CachedBook.reset(book_key_str)
Beispiel #4
0
 def on_borrow(book):
     mail.send_mail(
              sender=AppUser.me().email(),
              to=book.owner.email(),
              cc=(WTMB_SENDER, AppUser.me().email()),
              subject='[whotookmybook] %s' % book.title,
              body=textwrap.dedent("""Hi %s\n
                                     %s has requested or borrowed this book from you.\n
                                     p.s.email sent by http://whotookmybook.appspot.com"""
                                     % (book.owner.display_name(), book.borrower.display_name())))
     from bookcache import CachedBook, CacheBookIdsBorrowed
     book_key_str = str(book.key())
     CacheBookIdsBorrowed.add_book(str(book.borrower.key()), book_key_str)
     CachedBook.reset(book_key_str)
Beispiel #5
0
    def on_return(info):
        returner = info['returner']
        book = info['book']
        old_borrower = info['old_borrower']
        message = None
        if (returner != book.owner):
            message = " has returned this book to %s" % book.owner.display_name()
        else:
            message = "%s has reclaimed this book" % returner.display_name()

        mail.send_mail(
                     sender=AppUser.me().email(),
                     to=book.owner.email(),
                     cc=(WTMB_SENDER, AppUser.me().email()),
                     subject='[whotookmybook] %s' % book.title,
                     body=message)
        book_key_str = str(book.key())
        from bookcache import CachedBook, CacheBookIdsBorrowed
        CacheBookIdsBorrowed.remove_book(str(old_borrower.key()), book_key_str)
        CachedBook.reset(book_key_str)