예제 #1
0
파일: app.py 프로젝트: gyang01/StuyWiggles
def classinfo():
    if not session.has_key('user'):
        return redirect(url_for("about"))
    username=session['user']
    name=database.get_name(username)
    osis=database.get_osis(username)
    digits=database.get_id(username)
    email=database.get_email(username)
    schedule=database.get_schedule(username)
    classes=database.get_class_info()
    if request.method=='GET':
        return render_template("class.html"
                               ,name=name
                               ,osis=osis
                               ,digits=digits
                               ,email=email
                               ,classes=classes
                               ,schedule=schedule
                               ,get=True)
    if request.method=="POST":
        value=request.form['button']
        value=value.split(" ")
        index=int(value[1])-1
        validate=True
        if (str(value[0])=="set"):
            period=classes[index][0]
            clas=classes[index]
            schedule=database.get_schedule(username)
            if schedule[int(period)-1][1]=="free":
                database.set_period(username,period,clas)
            else:
                validate=False
        if (str(value[0])=="req"):
            req=classes[index]
            period=classes[index][0]
            if database.has_lunch(username,period) or l_equal(schedule[int(period)-1],req):
                validate=False
            else:
                database.post_request(username,req)
        return render_template("class.html"
                               ,name=name
                               ,osis=osis
                               ,digits=digits
                               ,email=email
                               ,classes=classes
                               ,schedule=schedule
                               ,validate=validate)
예제 #2
0
파일: app.py 프로젝트: gyang01/StuyWiggles
def edit():
    if not session.has_key('user'):
        return redirect(url_for("about"))
    username=session['user']
    email=database.get_email(username)
    osis=database.get_osis(username)
    digit=database.get_id(username)
    if request.method=='GET':
        return render_template("edit.html"
                               ,username=username
                               ,email=email
                               ,osis=osis
                               ,digit=digit
                               ,loggedout=False)
    if request.method=='POST':
        if request.form['button']=='Edit':
            password=request.form['password']
            email=request.form['email']
            digit=request.form['digit']
            osis=request.form['osis']
            lunch=request.form['lunch']
            schedule=database.get_schedule(username)
            current_lunch=database.get_lunch(username)
            pos=database.get_period(username,int(lunch))[1]
            if not (pos == 'free' or pos=='Cafe'):
                return render_template("edit.html"
                                       ,username=username
                                       ,email=email
                                       ,osis=osis
                                       ,digit=digit
                                       ,loggedout=False
                                       ,invalid=True)
            database.set_period(username,current_lunch,["","free","n/a","",""])
            database.set_period(username,lunch,[str(lunch),"Cafe","Chi Kun Wang","ZLN5","0"+str(lunch)])
            database.set_password(username,password)
            database.set_email(username,email)
            database.set_id(username,digit)
            database.set_osis(username,osis)
            return redirect(url_for('profile'))
        return redirect(url_for('edit'))
예제 #3
0
파일: app.py 프로젝트: gyang01/StuyWiggles
def profile():
    if not session.has_key('user'):
        return redirect(url_for('about'))
    username=session['user']
    name=database.get_name(username)
    osis=database.get_osis(username)
    digits=database.get_id(username)
    email=database.get_email(username)
    schedule=database.get_schedule(username)
    notif=database.get_notification(username)
    if request.method=='GET':        
        return render_template("profile.html"
                               ,name=name
                               ,osis=osis
                               ,digits=digits
                               ,schedule=schedule
                               ,email=email
                               ,accept=notif["accept"]
                               ,accepted=notif["accepted"]
                               )
    elif request.method=="POST":
        value=request.form["button"]
        value=value.split(" ")
        index=int(value[1])-1
        if str(value[0])=="drop":
            schedule=database.get_schedule(username)
            clas=schedule[index]
            if not (clas[1]=="free" or clas[1]=="Cafe"):
                database.drop_period(username,clas[0])
                schedule=database.get_schedule(username)
        return render_template("profile.html"
                               ,name=name
                               ,osis=osis
                               ,digits=digits
                               ,schedule=schedule
                               ,email=email
                               ,accept=notif["accept"]
                               ,accepted=notif["accepted"]
                               )
예제 #4
0
파일: app.py 프로젝트: gyang01/StuyWiggles
def visit(username=""):
    if not session.has_key('user'):
        return redirect(url_for('about'))
    me=session['user']
    if str(username)==str(me):
        return redirect(url_for('profile'))
    name=database.get_name(username)
    osis=database.get_osis(username)
    digits=database.get_id(username)
    email=database.get_email(username)
    schedule=database.get_schedule(username)
    notif=database.get_notification(username)
    if request.method=='GET':        
        return render_template("visit.html"
                               ,name=name
                               ,osis=osis
                               ,digits=digits
                               ,schedule=schedule
                               ,email=email
                               ,accept=notif["accept"]
                               ,accepted=notif["accepted"]
                               )
예제 #5
0
파일: app.py 프로젝트: gyang01/StuyWiggles
def tradingfloor():
    if not session.has_key('user'):
        return redirect(url_for("about"))
    username=session['user']
    name=database.get_name(username)
    osis=database.get_osis(username)
    digits=database.get_id(username)
    email=database.get_email(username)
    database.refresh_floor()
    floor=database.get_floor()
    if request.method=='GET':
        return render_template("trading.html"
                               ,name=name
                               ,osis=osis
                               ,digits=digits
                               ,floor=floor
                               ,email=email
                               ,validate=False)
    if request.method=='POST':
        value=request.form["button"]
        value=value.split(" ")
        index=int(value[1])-1
        req=floor[index]["request"]
        period=int(req[0])-1
        acceptername=username
        postername=floor[index]['username']
        schedule=database.get_schedule(username)[period]
        validate=False
        myself=False
        illegaldel=False
        try:
            if not str(postername)==str(username):
                if value[0]=="accept":
                    if l_equal(req,schedule):
                        database.accept_request(postername,acceptername,req)
                        return redirect(url_for("tradingfloor"))
                    else:
                        validate=True
                elif value[0]=="delete":
                    validate=True
                    myself=False
                    illegaldel=True
            else:
                if value[0]=="accept":
                    validate=True
                    myself=True
                else:
                    database.remove_request(username,req)
                    database.refresh_floor()
                    floor=database.get_floor()
            return render_template("trading.html"
                                   ,name=name
                                   ,osis=osis
                                   ,digits=digits
                                   ,email=email
                                   ,floor=floor
                                   ,validate=validate
                                   ,myself=myself
                                   ,illegaldel=illegaldel)
        except Exception:
            return render_template("trading.html"
                                   ,name=name
                                   ,osis=osis
                                   ,digits=digits
                                   ,email=email
                                   ,floor=floor
                                   ,validate=True)