def confirm_order():
    if not html.check_logged_in(loggedIn):
        return
    viewerID = sql.run_sql("""SELECT ViewerID FROM ViewerLogin
                               WHERE UserName = '******'"""%username)[0][0]
    videoids = sql.run_sql("""SELECT VideoID FROM ViewerOrderLine
                               WHERE ViewerOrderID IN (SELECT ViewerOrderID FROM ViewerOrder
                                                           WHERE ViewerID = %d)"""%viewerID)

    for item in videoids:
        if int(vidid) in item:
            redirect.refresh("viewer_order.py?error=1", sess.cookie)
            return
    

    viewerorderID = sql.run_insert("""INSERT INTO ViewerOrder VALUES
                                           (DEFAULT, CURDATE(), NULL, 'Pending', %d)"""%viewerID)
    viewerType = sql.run_sql("""SELECT ViewerType FROM Viewer
                                     WHERE ViewerID = %d"""%viewerID)[0][0]
    if viewerType == 'C':
        viewerType = 1
    else:
        viewerType = 0
    sql.run_insert("""INSERT INTO ViewerOrderLine VALUES
                       (%s, %s, %s)"""%(vidid, viewerorderID, str(bool(viewerType)).upper()))
    redirect.refresh("viewer_order.py", sess.cookie)

    return
Exemplo n.º 2
0
def main():
    if not html.check_logged_in(loggedIn):
        return
    video_id = get_vid_id(params)
    
    html.open_html(sess.cookie, loggedIn)
    print_body(video_id, params)
    html.close_html()
    
    sess.close()
    return
def main():
    if not html.check_logged_in(loggedIn):
        return
    html.open_html(sess.cookie, loggedIn)
    
    print_body()
    html.close_html()
    sess.data['loggedIn'] = 0 # log them out
    sess.data['userName'] = "******"
    sess.set_expires('')
    sess.close()
    return
def main():
    if not html.check_logged_in(loggedIn):
        return
    html.open_html(sess.cookie, loggedIn)
    error = False
    username = params['userName'].value
    if (loggedIn != 2) and (sess.data['userName'] != username):
        redirect.refresh("home.py", sess.cookie)
        return
    if params.has_key('error'):
        error = True
    print_body(username, error)

    html.close_html()
    sess.close()
    return
def main():
    if not html.check_logged_in(loggedIn):
        return
    html.open_html(sess.cookie, loggedIn)
    error = False
    # Get data through params and SQL

    username = sess.data["userName"]
    if loggedIn != 2:
        redirect.refresh("home.py", sess.cookie)
        return
    if params.has_key("error"):
        error = True
    print_body(username, error)

    html.close_html()
    sess.close()
    return
#######################################################################################################

sess = session.Session(expires=20*60, cookie_path='/')
loggedIn = sess.data.get('loggedIn')
params= cgi.FieldStorage()

#######################################################################################################



#######################################################################################################

#edit only if run ends up being true
run = True
#Check if user is loggedIn with authority and does not have deletion flag set up
if not html.check_logged_in(loggedIn):
    run = False
#If run is still set to true, get all the information from CGI fieldstorage
if run:
    playerID= params['pID'].value
    playerfname= params['fname'].value
    playerlname= params['lname'].value
    playerole= params['role'].value
    plaerdesc= params['describtion'].value
    playeremail = params['email'].value
    playerhandle= params['handle'].value
    playerphone= params['phone'].value
    playervoip= params['voip'].value
    
    addID= params['aID'].value
    addNo= params['stNo'].value
#######################################################################################################

# Authors: Beaudan Campbell-Brown, Derek Mui, Ha Jin Song, Jerry Chen
# INFO20003 assessment
# File to handle editting of viewer player using player

#######################################################################################################

import cgi, sql_handler as sql, redirect, session, html_template as html

#######################################################################################################

# Get Session from cookie and fieldstorage that has been passed on from previous page
sess = session.Session(expires=20 * 60, cookie_path="/")
loggedIn = sess.data.get("loggedIn")
params = cgi.FieldStorage()

#######################################################################################################

viewerID = params["viewerID"].value
result = sql.run_sql("""SELECT UserName FROM ViewerLogin WHERE ViewerLogin.ViewerID = %s""" % viewerID)
if result:
    username = result[0][0]
    if html.check_logged_in(loggedIn):
        redirect.refresh("viewer_edit_profile.py?userName=%s" % (username), sess.cookie)
else:
    redirect.refresh("player_find_viewer.py?notFound=1", sess.cookie)