예제 #1
0
파일: views.py 프로젝트: captaintl/lll
def update(request):
    if request.POST:
        con=sqlite3.connect ('db.sqlite3')
        cur = con.cursor ()
        cur.execute ('delete from addr_book_people where id=?',(request.GET['id'],))
        con.commit()
        con.close()
        post = request.POST
        new_people = People(
        name = post["name"],
        number = post["number"],
        phone = post["phone"],
        QQ = post["QQ"],
        email = post["email"],
        address = post["address"],
        birth = post["birth"],)
        if post["sex"] == 'M':
            new_people.sex = True
        else:
            new_people.sex = False
        new_people.save()
        people_list = People.objects.all()
        c = Context({"people_list":people_list,}) 
        return render_to_response("updates.html",c)
    for people in People.objects.all():
        if int(request.GET['id'])==people.id:
            c = Context({"people":people,})
            return render_to_response("update.html",c)
예제 #2
0
def insert( request ):
    if request.POST:
        post = request.POST
        new_people = People(
                name = post["name"],
                phone = post["phone"],
                email = post["email"],
                address = post["address"], )
        if post["sex"] == 'M':
            new_people.sex = True
        else:
            new_people.sex = False
        new_people.save()
        
    return render_to_response ( "insert.html" )
예제 #3
0
파일: views.py 프로젝트: captaintl/lll
def add_people(request):
    global ids
    if request.POST:
        post = request.POST
        new_people = People(
        name = post["name"],
        number = post["number"],
        phone = post["phone"],
        QQ = post["QQ"],
        email = post["email"],
        address = post["address"],
        birth = post["birth"],)
        if post["sex"] == 'M':
            new_people.sex = True
        else:
            new_people.sex = False
        new_people.save()
    people_list = People.objects.all()
    c = Context({"people_list":people_list,})   
    return render_to_response("form.html",c)
예제 #4
0
파일: views.py 프로젝트: feilifan/Project-1
def class_register(request):
    if request.POST:
        post = request.POST
        if post['code']==post['codex']:
            nickname =request.POST['name']
            code =request.POST['code']
            try:
                user = User.objects.create_user(username=nickname,password=code)
                user.save()
                new_people = People(user = user,
                                    email= post['email'],
                                    nickname = post['nickname'],
                                    name = post['name'],
                                    school_number = post['id'])
                new_people.save()
            except:
                return render_to_response("class_register.html",{'judge':True})
        else:
            error = Context({'judge':False})
            return render_to_response("class_register.html",error)
    error = Context({'judge':True})
    return render_to_response("class_register.html",error)