def editStudent(request): if request.method == "GET": nid = request.GET.get('nid') result = sqlhelper.get_one( 'select id,stu_name,class_id from student where id=%s', [ nid, ]) class_list = sqlhelper.get_list("select id,title from class", []) return render(request, 'editStudent.html', { 'result': result, 'class_list': class_list }) else: nid = request.GET.get('nid') id = request.POST.get('id') name = request.POST.get('stu_name') class_id = request.POST.get('class_id') sqlhelper.modify( "update student set id=%s, stu_name=%s, class_id=%s where id = %s", [ id, name, class_id, nid, ]) return redirect('/students/')
def myaccount(request): if request.user.is_authenticated: nid = request.user.id username = sqlhelper.get_one( "select username from auth_user where id=%s", [nid]) email = sqlhelper.get_one("select email from auth_user where id=%s", [nid]) print(username) if request.method == 'POST': nid = request.POST.get('id') opw = request.POST.get('Opwd') npw = request.POST.get('Npwd') cpw = request.POST.get('Cpwd') if not request.user.check_password(opw): error = "Original Password is Wrong" return render( request, 'compare/myaccount.html', { 'id': nid, 'username': username, 'email': email, 'error': error }) if npw != cpw: error = "Inconsistent new password entry" return render( request, 'compare/myaccount.html', { 'id': nid, 'username': username, 'email': email, 'error': error }) request.user.set_password(npw) request.user.save() logout(request) return render(request, 'compare/home.html') return render(request, 'compare/myaccount.html', { 'id': nid, 'username': username, 'email': email }) else: return redirect('login')
def edit_student(request): if request.method == "GET": nid = request.GET.get('nid') class_list = sqlhelper.get_List("select id,title from class",[]) current_student_info = sqlhelper.get_one("select id,name,class_id from student where id=%s",[nid,]) return render(request,'edit_student.html',{'class_list':class_list,'current_student_info':current_student_info}) else: nid = request.GET.get('nid') name = request.POST.get('name') class_id = request.POST.get('class_id') sqlhelper.modify("update student set name=%s,class_id=%s where id=%s",[name,class_id,nid]) return redirect('/students/')
def edit_student(request): if request.method == "GET": nid = request.GET.get('nid') class_list = sqlhelper.get_list('select cid,cname from class', []) curr_stu = sqlhelper.get_one( 'select sid,sname,classid from student where sid=%s', [ nid, ]) return render(request, 'edit_student.html', { 'class_list': class_list, 'curr_stu': curr_stu }) else: nid = request.GET.get('nid') stuname = request.POST.get('sname') class_id = request.POST.get('class_id') sqlhelper.modify("update student set sname=%s,classid=%s where sid=%s", [stuname, class_id, nid]) return redirect('/students/')
def edit_students(request): if request.method == 'GET': pk = request.GET.get('pk') class_list = sqlhelper.get_list("select id,title from class", []) current_stuinfo = sqlhelper.get_one( "select id,name,cid from students where id=%s", [ pk, ]) return render(request, 'edit_students.html', { 'class_list': class_list, 'current_stuinfo': current_stuinfo }) else: pk = request.GET.get('pk') edit_name = request.POST.get('edit_name') c_id = request.POST.get('c_id') sqlhelper.modify("update students set name=%s,cid=%s where id=%s", [edit_name, c_id, pk]) return redirect('stu:students')
def edit_student(request): nid = request.GET.get('nid') if request.method == 'GET': class_list = sqlhelper.get_list( 'select class_id,class_name from class_info', []) stu_name = sqlhelper.get_one( 'select stu_id,stu_name,stu_class_id from stu_info where stu_id=%s', [ nid, ]) return render(request, 'edit_student.html', { 'class_list': class_list, 'stu_name': stu_name }) else: stu_name = request.POST.get('stu_name') class_id = request.POST.get('classId') sqlhelper.modify( 'update stu_info set stu_name = %s,stu_class_id=%s where stu_id = %s', [stu_name, class_id, nid]) return redirect('/students/')