예제 #1
0
파일: upload.py 프로젝트: mdmoss/unswmate
def do_upload(request):
    fileitem = request['file']
    image_file_name = get_unique_image_name()
    user = authbar.get_current_login()
    
    if user and fileitem.filename:
        open(config.data_dir + image_file_name, 'wb').write(fileitem.file.read())
        db.add_image(user, image_file_name)
        if 'profile' in request:
            db.set_data(user, 'profile_picture', image_file_name)
       
    return '<script type="text/javascript">window.location.href="unswmate.cgi?who=' + authbar.get_current_login() + '"</script>'
예제 #2
0
파일: editor.py 프로젝트: mdmoss/unswmate
def do_edit(request):
    # This is where things get interesting
    user = authbar.get_current_login()
    if 'name' in request: 
        db.set_data(user, 'name', make_safe(request['name'].value)) 
    if 'about' in request: 
        db.set_data(user, 'about', make_safe(request['about'].value)) 
    if 'gender' in request: 
        db.set_data(user, 'gender', make_safe(request['gender'].value)) 
    if 'degree' in request: 
        db.set_data(user, 'degree', make_safe(request['degree'].value)) 
    if 'student_number' in request: 
        db.set_data(user, 'student_number', make_safe(request['student_number'].value)) 
    # Reload the edited page
    return '<script type="text/javascript">window.location.href="unswmate.cgi?who=' + user + '"</script>'