示例#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
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)