def index(request, username=None, state=None, page=1): reader = Reader.byUsername(username) if not reader: return HttpResponse('No such username') page = int(page) template_values = {} template_values["currentState"] = state template_values["readOnly"] = True template_values["books"] = [] template_values["toReadCount"] = reader.toReadCount template_values["inProgressCount"] = reader.inProgressCount template_values["finishedCount"] = reader.finishedCount template_values["totalCount"] = reader.totalCount # paging stuff paging.preparePagingTemplateForBookcase(template_values, reader, state, page) # end paging stuff for readerBook in ReaderBook.byReaderAndState(reader, state, page - 1): template_values["books"].append( mapping.toReaderBookTemplate(readerBook.book, readerBook)) template_values["navRoot"] = "/public/" + username return render(template_values)
def index(request, username=None, state=None, page=1): reader = Reader.byUsername(username) if not reader: return HttpResponse('No such username') page = int(page) template_values = {} template_values["currentState"] = state template_values["readOnly"] = True template_values["books"] = [] template_values["toReadCount"] = reader.toReadCount template_values["inProgressCount"] = reader.inProgressCount template_values["finishedCount"] = reader.finishedCount template_values["totalCount"] = reader.totalCount # paging stuff paging.preparePagingTemplateForBookcase(template_values, reader, state, page) # end paging stuff for readerBook in ReaderBook.byReaderAndState(reader, state, page - 1): template_values["books"].append(mapping.toReaderBookTemplate(readerBook.book, readerBook)) template_values["navRoot"] = "/public/" + username return render(template_values)
def appendBooks(bookList, viewList): if bookList is None: bookList = BookList() if bookList.list is None: bookList.list = () for key in bookList.list[0:5]: bookKey = db.Key(key) if bookKey.app() == "trackmybooks": bookKey = db.Key.from_path(*bookKey.to_path()) book = Book.get(bookKey) if book: viewList.append( mapping.toReaderBookTemplate(book, None) )
def appendBooks(bookList, viewList): if bookList is None: bookList = BookList() if bookList.list is None: bookList.list = () for key in bookList.list[0:5]: bookKey = db.Key(key) if bookKey.app() == "trackmybooks": bookKey = db.Key.from_path(*bookKey.to_path()) book = Book.get(bookKey) if book: viewList.append(mapping.toReaderBookTemplate(book, None))
def index(request, state=None, page=1): reader = Reader().byCurrentUser() user = users.get_current_user() page = int(page) template_values = {} if state: template_values["currentState"] = state else: template_values["currentState"] = "" if user: template_values["isLoggedIn"] = True else: template_values["isLoggedIn"] = False if not reader: template_values["loginUrl"] = users.create_login_url('/reader') else: template_values["hasReader"] = True template_values["books"] = [] template_values["toReadCount"] = reader.toReadCount template_values["inProgressCount"] = reader.inProgressCount template_values["finishedCount"] = reader.finishedCount template_values["totalCount"] = reader.totalCount template_values["showRatings"] = True # paging stuff paging.preparePagingTemplateForBookcase(template_values, reader, state, page) # end paging stuff if state == "unrated": collection = ReaderBook.byReaderUnrated(reader, page - 1) else: collection = ReaderBook.byReaderAndState(reader, state, page - 1) for readerBook in collection: template_values["books"].append( mapping.toReaderBookTemplate(readerBook.book, readerBook)) template_values["navRoot"] = "/bookcase" template_values["viewtype"] = "searchresult.html" return render(template_values)
def index(request, state=None, page=1): reader = Reader().byCurrentUser() user = users.get_current_user() page = int(page) template_values = {} if state: template_values["currentState"] = state else: template_values["currentState"] = "" if user: template_values["isLoggedIn"] = True else: template_values["isLoggedIn"] = False if not reader: template_values["loginUrl"] = users.create_login_url('/reader') else: template_values["hasReader"] = True template_values["books"] = [] template_values["toReadCount"] = reader.toReadCount template_values["inProgressCount"] = reader.inProgressCount template_values["finishedCount"] = reader.finishedCount template_values["totalCount"] = reader.totalCount template_values["showRatings"] = True # paging stuff paging.preparePagingTemplateForBookcase(template_values, reader, state, page) # end paging stuff if state == "unrated": collection = ReaderBook.byReaderUnrated(reader, page - 1) else: collection = ReaderBook.byReaderAndState(reader, state, page - 1) for readerBook in collection: template_values["books"].append(mapping.toReaderBookTemplate(readerBook.book, readerBook)) template_values["navRoot"] = "/bookcase" template_values["viewtype"] = "searchresult.html" return render(template_values)
def viewByIsbn(request, isbn = ""): user = users.get_current_user() reader = None book = None readerBook = None if user: reader = Reader.byCurrentUser() book = fetchCreateByISBN(isbn, invokeSearchByIsbn, True) readerBook = ReaderBook.byReaderAndBook(reader, book) template_values = mapping.toReaderBookTemplate(book, readerBook) if not user: template_values["loginUrlToAdd"] = users.create_login_url('/book/isbn/' + isbn) else: if not reader: template_values["signupUrl"] = '/reader' return render(template_values)
def viewByIsbn(request, isbn=""): user = users.get_current_user() reader = None book = None readerBook = None if user: reader = Reader.byCurrentUser() book = fetchCreateByISBN(isbn, invokeSearchByIsbn, True) readerBook = ReaderBook.byReaderAndBook(reader, book) template_values = mapping.toReaderBookTemplate(book, readerBook) if not user: template_values["loginUrlToAdd"] = users.create_login_url( '/book/isbn/' + isbn) else: if not reader: template_values["signupUrl"] = '/reader' return render(template_values)
def view(request, identifier): book = db.get(db.Key(identifier)) readerBook = ReaderBook.byReaderAndBook(Reader.byCurrentUser(), book) return render(mapping.toReaderBookTemplate(book, readerBook))
def view(request, identifier): book = db.get(db.Key(identifier)) readerBook = ReaderBook.byReaderAndBook(Reader.byCurrentUser(), book) return render( mapping.toReaderBookTemplate(book, readerBook) )