Exemplo n.º 1
0
def modal_add_class(request):
    title = request.POST.get('title')
    if len(title) > 0:
        pymysqlhepler.movde_list('insert into class(title) values(%s)', [
            title,
        ])
        return HttpResponse('ok')
    else:
        return HttpResponse('班级标题不能为空')
Exemplo n.º 2
0
def modal_edit_class(request):
    ret = {'status': True, 'message': None}
    try:
        nid = request.POST.get('nid')
        content = request.POST.get('content')
        pymysqlhepler.movde_list("update class set title=%s WHERE id=%s",
                                 [content, nid])
    except Exception as e:
        ret['status'] = False
        ret['message'] = str(e)

    return HttpResponse(json.dumps(ret))
Exemplo n.º 3
0
def add_student(request):
    if request.method == "GET":
        class_list = pymysqlhepler.get_list("select id,title from class", [])
        return render(request, 'studentmanagent/add_student.html',
                      {'class_list': class_list})
    else:
        nid = request.POST.get('stu_name')
        title = request.POST.get('cls_sel')
        print(nid, title)
        pymysqlhepler.movde_list(
            "insert into student(name,class_id) VALUES (%s,%s)", [nid, title])
        return redirect('/students/')
Exemplo n.º 4
0
def modal_add_student(request):
    ret = {'status': True, 'message': None}
    try:
        name = request.POST.get('name')
        class_id = request.POST.get('class_id')
        pymysqlhepler.movde_list(
            "insert into student(name,class_id) VALUES (%s,%s)", [
                name,
                class_id,
            ])
    except Exception as e:
        ret['status'] = False
        ret['message'] = str(e)
    return HttpResponse(json.dumps(ret))
Exemplo n.º 5
0
def modal_edit_student(request):
    ret = {'status': True, 'message': None}
    try:
        studentId = request.POST.get('nid')
        studentName = request.POST.get('name')
        cls_Id = request.POST.get('class_id')
        pymysqlhepler.movde_list(
            "update student set name=%s,class_id=%s WHERE id=%s", [
                studentName,
                cls_Id,
                studentId,
            ])
    except Exception as e:
        ret['status'] = False
        ret['message'] = str(e)
    return HttpResponse(json.dumps(ret))
Exemplo n.º 6
0
def ed_student(request):
    if request.method == "GET":
        nid = request.GET.get('nid')
        stu_name = pymysqlhepler.get_one("select * from student WHERE id=%s", [
            nid,
        ])
        class_name = pymysqlhepler.get_list("select id,title from class", [])

        return render(request, 'studentmanagent/ed_student.html', {
            'class_name': class_name,
            'stu_name': stu_name
        })

    else:
        nid = request.GET.get('nid')
        st_name = request.POST.get('st_n')
        cls_name = request.POST.get('class_name')
        pymysqlhepler.movde_list(
            "update student set name=%s, class_id=%s WHERE id=%s",
            [st_name, cls_name, nid])
        return redirect('/students/')