Exemple #1
0
def delFilterInfo(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())

    filterid = utils.getParam(request, "filterid")
    if filterid == "" or filterid is None:
        responseReturn = Response(-1, "请选择一个班级")
        return HttpResponse(responseReturn.__str__())

    filterinfo = FilterInfoService.getFilterInfoById(filterid)
    if filterinfo is None:
        responseReturn = Response(-1, "此班级不存在~")
        return HttpResponse(responseReturn.__str__())

    count = StudentService.getCountStudentByFilterInfo(filterid)
    if count > 0:
        responseReturn = Response(-1, "该班级下还有同学,不能删除哦~")
        return HttpResponse(responseReturn.__str__())

    filterdelinfo = FilterInfoService.delFilterInfo(filterid)
    if filterdelinfo is None:
        responseReturn = Response(-1, "删除失败,请重试!")
        return HttpResponse(responseReturn.__str__())

    responseReturn = Response(None, None)
    return HttpResponse(responseReturn.__str__())
Exemple #2
0
def addFilterInfo(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    registyear = utils.getParam(request, "registyear")
    major = utils.getParam(request, "major")
    classname = utils.getParam(request, "classname")
    if registyear is None or registyear == "":
        responseReturn = Response(-1, "请输入入学年份~")
        return HttpResponse(responseReturn.__str__())

    if major is None or major == "":
        responseReturn = Response(-1, "请输入专业~")
        return HttpResponse(responseReturn.__str__())

    if classname is None or classname == "":
        responseReturn = Response(-1, "请输入班级~")
        return HttpResponse(responseReturn.__str__())

    filterinfo = FilterInfoService.getFilterInfo(registyear, major, classname)
    if filterinfo is None:
        filterinfoid = FilterInfoService.addFilterInfo(registyear, major,
                                                       classname)
        responseReturn = Response(None, None)
        return HttpResponse(responseReturn.__str__())
    else:
        responseReturn = Response(-1, "已有此班级,请重新输入~")
        return HttpResponse(responseReturn.__str__())
Exemple #3
0
def getStudentByFilterInfoId(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        responseReturn = Response(-2, "请登录")
        return HttpResponse(responseReturn.__str__())
    filterid = utils.getParam(request, "filterid")
    if (filterid == "" or filterid is None):
        responseReturn = Response(-1, "请选择班级!")
        return HttpResponse(responseReturn.__str__())
    filterinfo = FilterInfoService.getFilterInfoById(filterid)
    if filterinfo is None:
        responseReturn = Response(-1, "班级不存在!")
        return HttpResponse(responseReturn.__str__())
    studentList = StudentService.getStudentListByFilterInfo(filterid)
    if studentList is None:
        responseReturn = Response(-1, "此班级没有学生!")
        return HttpResponse(responseReturn.__str__())
    studentDictList = []
    for student in studentList:
        dict = model_to_dict(student)
        del dict["isdelete"]
        del dict["createtime"]
        del dict["updatetime"]
        dict["registyear"] = filterinfo.registyear
        dict["major"] = filterinfo.major
        dict["classname"] = filterinfo.classname
        studentDictList.append(dict)
    studentDictListStr = json.dumps(studentDictList, ensure_ascii=False)
    responseReturn = Response(None, None)
    responseReturn.setRes(studentDictListStr)
    return HttpResponse(responseReturn.__str__())
Exemple #4
0
def getStudentListByExcel(filename):
    executestate = 0  # 执行状态 0:成功,1:失败
    failtext = ""  # 失败信息
    studentlist = []
    book = xlrd.open_workbook(CONSTANTS.STUDENTLISTURL_PRE + filename)
    sheet0 = book.sheet_by_index(0)
    nrows = sheet0.nrows  # 获取行总数
    for i in range(nrows):
        if i == 0:
            continue
        row_data = sheet0.row_values(i)
        registyear = str(sheet0.cell_value(i, 2))
        major = str(sheet0.cell_value(i, 3))
        classname = str(sheet0.cell_value(i, 4))
        filterinfo = FilterInfoService.getFilterInfo(registyear, major,
                                                     classname)
        if filterinfo is None:
            executestate = 1
            failtext = """班级不存在,入学年份:%s,专业:%s,班级:%s""" % (registyear, major,
                                                          classname)
            return studentlist, executestate, failtext

        student = {
            "name": sheet0.cell_value(i, 0),
            "number": str(sheet0.cell_value(i, 1)),
            "filterinfoid": filterinfo.id
        }
        studentobj = StudentService.getStudentByNum(student["number"])
        if studentobj is not None:
            executestate = 1
            failtext = """该学生已存在,姓名:%s,学号:%s""" % (student["name"],
                                                   student["number"])
            return studentlist, executestate, failtext
        studentlist.append(student)
    return studentlist, executestate, failtext
Exemple #5
0
def v_studentmanagement(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        return getloginResponse(request)
    issuperadmin = utils.getCookie(request, "issuperadmin")
    adminname = utils.getCookie(request, "adminname")
    stunum = utils.getParam(request, "searchnum")
    name = utils.getParam(request, "searchname")
    page = utils.getParam(request, "page")
    if (page is None) or page == "":
        page = 1
    else:
        page = int(page)

    if (stunum == "" or stunum is None) and (name == "" or name is None):
        count = StudentService.getCountStudent()
        countpage = 0
        i = 0
        if count > 0:
            if count % 10 > 0:
                i = 1
            countpage = count / 10 + i
        studentList = StudentService.getAllStudent(page)
    else:
        count = StudentService.getCountStudentByNameAndNumber(name, stunum)
        countpage = 0
        i = 0
        if count > 0:
            if count % 10 > 0:
                i = 1
            countpage = count / 10 + i
        studentList = StudentService.getManyStudentByNameAndNumber(
            name, stunum, page)

    for student in studentList:
        filterinfo = FilterInfoService.getFilterInfoById(student.filterinfoid)
        student.registyear = filterinfo.registyear
        student.major = filterinfo.major
        student.classname = filterinfo.classname

    param = "?"
    if stunum != "":
        param = param + "searchnum=" + stunum
    if name != "":
        if param != "?":
            param = param + "&"
        param = param + "searchname=" + name
    if param == "?":
        param = ""
    return render(
        request, "studentmanagement.html", {
            "studentList": studentList,
            "stunum": stunum,
            "searchname": name,
            "adminname": adminname,
            "countpage": countpage,
            "issuperadmin": issuperadmin
        })
Exemple #6
0
def setBasicInformation(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        return getloginResponse(request)
    filterInfoList = FilterInfoService.getFilterInfoList(None)
    issuperadmin = utils.getCookie(request, "issuperadmin")
    adminname = utils.getCookie(request, "adminname")
    return render(
        request, "set_basic_information.html", {
            "filterInfoList": filterInfoList,
            "issuperadmin": issuperadmin,
            "adminname": adminname
        })
Exemple #7
0
def v_adduser(request):
    adminid = utils.getCookie(request, "adminid")
    if adminid == "" or adminid is None:
        return getloginResponse(request)
    issuperadmin = utils.getCookie(request, "issuperadmin")
    adminname = utils.getCookie(request, "adminname")
    filterInfoList = FilterInfoService.getFilterInfoList(None)
    filterInfoDictList = []
    for filterinfo in filterInfoList:
        dict = model_to_dict(filterinfo)
        del dict["isdelete"]
        del dict["createtime"]
        del dict["updatetime"]
        filterInfoDictList.append(dict)
    filterInfoListstr = json.dumps(filterInfoDictList, ensure_ascii=False)
    return render(
        request, "adduser.html", {
            "issuperadmin": issuperadmin,
            "adminname": adminname,
            "filterInfoList": filterInfoList,
            "filterInfoListstr": filterInfoListstr
        })
Exemple #8
0
def v_addexp(request):
    teacherid = utils.getCookie(request, "teacherid")
    if (teacherid is None) or teacherid == "":
        return getloginResponse(request)
    teachername = utils.getCookie(request, "teachername")
    teachingCount = getTeachingCount(teacherid)
    experimentList = ExperimentService.getAllExperiment()
    # 获取用于菜单的实验列表
    experimentMenuList = []
    for experiment in experimentList:
        experimentTemp = experiment.copy()
        experimentName = experimentTemp["name"]
        if len(experimentName) > 8:
            experimentName = experimentName[0:10] + "..."
        experimentTemp["name"] = experimentName
        experimentMenuList.append(experimentTemp)
    filterInfoList = FilterInfoService.getFilterInfoList(None)
    filterInfoDictList = []
    for filterinfo in filterInfoList:
        dict = model_to_dict(filterinfo)
        del dict["isdelete"]
        del dict["createtime"]
        del dict["updatetime"]
        filterInfoDictList.append(dict)
    filterInfoListstr = json.dumps(filterInfoDictList, ensure_ascii=False)

    response = render(
        request, "addexp.html", {
            "teachingCount": teachingCount,
            "experimentList": experimentList,
            "experimentMenuList": experimentMenuList,
            "teachername": teachername,
            "filterInfoListstr": filterInfoListstr
        })

    return response