Exemplo n.º 1
0
def getHeader(query="", category="all"):
    # returns the raw html for the fixed header
    # at the top of the page

    # if user is logged in.
    # then use the logged-in header
    # comment in haiku
    username = userhelper.getCurrentUser()

    user = ""

    if username != None:
        realname = userhelper.getRealName(username)
        userFile = open("userLoggedIn.html", "r")
        user = userFile.read()
        user = user % { "username": username, "realname": realname }
        userFile.close()
    else:
        userFile = open("userLoggedOut.html", "r")
        user = userFile.read()
        userFile.close()

    headerFile = open("header.html", "r")
    header = headerFile.read()
    headerFile.close()

    return header % { "user": user, "query": query, "category": category }
Exemplo n.º 2
0
def bookDetail(isbn):
    if bookhelper.getBook(isbn) != None:
        bookDetailFile = open("bookDetail.html", "r")
        bookDetail = bookDetailFile.read()
        bookDetailFile.close()

        book = bookhelper.getBook(isbn)

        book["header"] = getHeader()

        book["releasedate"] = fancyDate(book["releasedate"])

        if userhelper.isLoggedIn():
            book["disabled"] = ""
            book["cartmessage"] = "Add to Cart"
        else:
            book["disabled"] = "disabled"
            book["cartmessage"] = "Login to purchase"

        book["username"] = userhelper.getCurrentUser()

        return bookDetail % book
    else:
        return error()