Esempio n. 1
0
        c.load(cookieString)

        if "teacherID" in c:
            teacherID = int(c["teacherID"].value)

        else:
            raise Exception("A cookie expired")

    else:
        raise Exception("You do not have permission to view this page")

    pupil = Pupil(pupilID=pupilID)
    playerList = pupil.players()

    if not teacherID is None:
        body = teacherMenuBar()

    else:
        body = "<a href='/'><div class='centreForeground' style='font-size: 20px;'>Go home</div></a>"

    body += "<div class='centreForegroundWide' style='overflow: hidden'>"

    body += "<h1>Pupil: %s %s </h1>" % (pupil.forename, pupil.surname)
    body += "<div class='objectContainer' style='margin-left: 34px;'>" + pupil.pupilToHTML(
        teacherID) + "</div>"
    body += "<table id='objectTable'>"

    for i in range(len(playerList)):
        if i % 3 == 0:
            body += "<tr>"
Esempio n. 2
0
            raise Exception("A cookie expired")
    else:
        raise Exception("A cookie expired")

    searchBy = post["pupilDataType"].value
    searchData = post["pupilSearchData"].value.lower()

    result = getFromDatabase("SELECT DISTINCT pupilID FROM pupil \
                              WHERE LOWER(%s)='%s';" % (searchBy, searchData))
    pupilList = [Pupil(pupilID=row[0]) for row in result]

    for i in range(len(pupilList)):
        if i % 3 == 0:
            resultTable += "<tr>"

        resultTable += "<td class='objectContainer'>" + pupilList[
            i].pupilToHTML(teacherID) + "</td>"

        if i % 3 == 2 or i == len(pupilList) - 1:
            resultTable += "</tr>"

    print page % (teacherMenuBar(), resultTable)

except Exception as e:
    page = errorPage()
    if teacherID is None:
        print page % ("", str(e))

    else:
        print page % (teacherMenuBar, str(e))
Esempio n. 3
0
try:
    post = cgi.FieldStorage()

    if "successData" in post:  #Accessing homepage from login
        teacherID = int(post["successData"].value)
        newCookie = Cookie.SimpleCookie()
        newCookie["teacherID"] = str(teacherID)
        print newCookie

    elif "HTTP_COOKIE" in os.environ:  #Accessing from another page
        cookieString = os.environ.get("HTTP_COOKIE")
        oldCookie = Cookie.SimpleCookie()
        oldCookie.load(cookieString)
        if "teacherID" in oldCookie:
            teacherID = int(oldCookie["teacherID"].value)

    else:
        raise Exception("You do not have permission to view this page")

    print page % (teacherMenuBar(), teacherID, teacherID)

except Exception as e:
    page = errorPage()

    if teacherID is None:
        print page % ("", str(e))

    else:
        print page % (teacherMenuBar(), str(e))