예제 #1
0
def edit_information(request):
    height = request.POST['height']
    weight = request.POST['weight']
    gender = request.POST['gender']
    birth  = request.POST['birth']
    uid = request.POST['uid']
    if (uid == '0') :
        return HttpResponse("user/error.html")
    else :
        user = User.objects.get(pk = uid)
        user.height = height
        user.weight = weight
        user.gender = gender
        user.birth  = birth
        f = request.FILES.get('pic')
        print 'there-->',f
        if (f != None) :
            print 'entring '
            if(user.pic != ''):
                # print 'yes'
                BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
                oldpath = os.path.join(BASE_DIR, user.pic)
                if os.path.exists(oldpath):
                    os.remove(oldpath)
            later_path = 'static/upload/images/'+get_number()+'.jpg'
            write_pic(f,later_path)
            user.pic = later_path
        user.save()
        return HttpResponseRedirect("/catelator/user/go_check_information")
예제 #2
0
def complete_information(request):
    print 'here'
    height = request.POST['height']
    weight = request.POST['weight']
    gender = request.POST['gender']
    birth  = request.POST['birth']
    uid = request.POST['uid']

    if (uid == '0') :
        return render_to_response("user/error.html",{},context_instance=RequestContext(request))
    else :
        user = User.objects.get(pk = uid)
        user.height = height
        user.weight = weight
        user.gender = gender
        user.birth  = birth
        f = request.FILES.get('pic')
        if (f != None):
            later_path = 'static/upload/images/'+get_number()+'.jpg'
            write_pic(f,later_path)
            user.pic = later_path
        user.save()
        return HttpResponseRedirect("/catelator/user/go_check_information")