コード例 #1
0
def create_album():
    if not 'MyWebsite_user_id' in session.keys():
        return redirect('/')
    if not User.is_logged_in(session['MyWebsite_user_id'],session['login_session']):
        return redirect('/danger')    
    # print(request.form)
    new_album=Album.new(session['MyWebsite_user_id'],request.form['name'],request.form['description'])
    if new_album==None:
        # handle error
        pass
    return redirect ('/dashboard')
コード例 #2
0
def register_user():
    errors=User.validate_new(request.form)
    for error in errors:
        flash(error[0],error[1])
    if len(errors)==0:
        user_id=User.register_new(request.form)
        if user_id>0:
            session['MyWebsite_user_id']=user_id
            session['user_name']=request.form['first_name']+" "+request.form['last_name']
            session['login_session']=User.get_session_key(user_id)
            session['email_address']=request.form['email_address']
            # Note: email sanitization checked in User.validate_new(request.form)
            os.mkdir('UserFiles/'+request.form['email_address'])
            os.mkdir('UserFiles/thumbnails/'+request.form['email_address'])
            album=Album.new(user_id,'Default')
            user=User.get_one(user_id)
            user.set_active_album(album.id)
            return redirect('/user')
    return redirect('/signin')