예제 #1
0
파일: app.py 프로젝트: gyang01/StuyWiggles
def register():
    if session.has_key('user'):
        session.pop('user')
    if request.method=="GET":
        return render_template("register.html", loggedout=True)
    elif request.method=='POST':
        if request.form['button']=='Register':
            username=request.form['username']
            password=request.form['password']
            osis=request.form['osis']
            digit=request.form['digit']
            name=request.form['name']
            email=request.form['email']
            lunch=request.form['lunch']
            exist=database.add_student(username,password)
            if exist:
                return render_template("register.html",loggedout=True,exists=exist)
            database.set_osis(username,osis)
            database.set_id(username,digit)
            database.set_name(username,name)
            database.set_email(username,email)
            database.set_period(username,
                                 int(lunch),
                                 [str(lunch),
                                  "Cafe",
                                  "Chi Kun Wang",
                                  "ZLN5",
                                  "0"+str(lunch)])
                                  
            return redirect(url_for("profile"))
    return redirect(url_for("register"))
예제 #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'))