Exemplo n.º 1
0
Arquivo: views.py Projeto: yanghhh0/oa
def recheck(request):
    flag, rank = check_cookie(request)
    if not flag:
        return render(request, 'login.html', {'error_msg': ''})
    dt = dict()
    dt['check_id'] = request.GET.get('check_id')
    return render(request, 'recheck.html', dt)
Exemplo n.º 2
0
Arquivo: views.py Projeto: yanghhh0/oa
def teacher(request):
    flag, rank = check_cookie(request)
    if not flag:
        return render(request, 'login.html')
    rank = model_to_dict(rank)
    print(json.dumps(rank))
    return render(request, 'teacher.html', rank)
Exemplo n.º 3
0
Arquivo: views.py Projeto: yanghhh0/oa
def search_stu(request):
    flag, rank = check_cookie(request)
    if not flag:
        return render(request, 'login.html', {'error_msg': ''})
    dt = dict()
    dt['itemId'] = request.GET.get('itemId')
    return render(request, 'add_stu.html', dt)
Exemplo n.º 4
0
Arquivo: views.py Projeto: yanghhh0/oa
def login(request):
    dt = dict()
    if request.POST:
        info = request.POST
        print(info)
        dt['email'] = info.get('email')
        dt['password'] = info.get('password')
        m = hashlib.sha1()
        m.update(dt['password'].encode(encoding="utf-8"))
        m.hexdigest()
        dt['password'] = m.hexdigest()
        if check_login(dt['email'], dt['password']) == 0:
            # return render(request, 'teacher.html', dt)
            response = redirect('/teacher/')
            response.set_cookie('email', dt['email'], 7200)
            response.set_cookie('password', dt['password'], 7200)
            return response
        else:
            if check_login(dt['email'], dt['password']) == 2:
                dt['error_msg'] = '邮箱错误'
            else:
                dt['error_msg'] = '密码错误'
            return render(request, 'login.html', dt)
    else:
        flag, rank = check_cookie(request)
        if flag:
            return redirect('/teacher/')
        return render(request, 'login.html', {'error_msg': ''})
Exemplo n.º 5
0
Arquivo: views.py Projeto: yanghhh0/oa
def get_stu_item(request):
    flag, rank = check_cookie(request)
    if not flag:
        return render(request, 'login.html', {'error_msg': ''})
    dt = search_stu_item(request.GET.get('itemId'))
    res = {"code": 0, "msg": "", "count": len(dt), "data": dt}
    res = json.dumps(res)
    return HttpResponse(res)
Exemplo n.º 6
0
Arquivo: views.py Projeto: yanghhh0/oa
def del_item(request):
    flag, rank = check_cookie(request)
    if not flag:
        return render(request, 'login.html', {'error_msg': ''})
    uid = model_to_dict(rank).get('uid')
    if request.POST:
        update_item(uid, request.POST.get('name'), 1, request.POST.get('uid'))
    return render(request, 'search_item.html')
Exemplo n.º 7
0
Arquivo: views.py Projeto: yanghhh0/oa
def get_items(request):
    flag, rank = check_cookie(request)
    if not flag:
        return render(request, 'login.html', {'error_msg': ''})
    uid = model_to_dict(rank).get('uid')
    items = search_items(uid)
    items = items_to_table(items)
    res = {"code": 0, "msg": "", "count": len(items), "data": items}
    res = json.dumps(res)
    return HttpResponse(res)
Exemplo n.º 8
0
Arquivo: views.py Projeto: yanghhh0/oa
def add_stu(request):
    flag, rank = check_cookie(request)
    if not flag:
        return render(request, 'login.html', {'error_msg': ''})
    dt = dict()

    if request.POST:
        dt['itemId'] = request.GET.get('itemId')
        print(request.POST)
        add_stu_to_item(dt['itemId'], request.POST.get('uid'))
    return render(request, 'add_stu.html', dt)
Exemplo n.º 9
0
Arquivo: views.py Projeto: yanghhh0/oa
def get_record_table(request):
    flag, rank = check_cookie(request)
    if not flag:
        return render(request, 'login.html', {'error_msg': ''})
    uid = model_to_dict(rank).get('uid')
    total, table = get_check_record_table(uid, page=int(request.GET.get('page'))-1, limit=int(request.GET.get('limit')))
    for obj in table:
        obj['check_time'] = time.strftime("%Y年%m月%d日 %H:%M:%S", time.localtime(obj['check_time']))

    # test_data = {"check_id": 1, "check_item": "计算机171", "check_time": "2021/4/17/15:30", "checked_count": 20,
    #              "total_count": 21, "unchecked_stu": ['石头人']}
    # table.append(test_data)
    res = {"code": 0, "msg": "", "count": total, "data": table}
    res = json.dumps(res)
    return HttpResponse(res)
Exemplo n.º 10
0
Arquivo: views.py Projeto: yanghhh0/oa
def check(request):
    flag, rank = check_cookie(request)
    if not flag:
        return render(request, 'login.html', {'error_msg': ''})
    uid = model_to_dict(rank).get('uid')
    keys = request.GET.keys()
    dt = dict()
    for key in keys:
        dt[key] = request.GET[key]
    print(dt)
    dt['uid'] = uid
    dt['time'] = round(time.time())
    # 生成签到记录
    dt['check_id'] = generate_check_info(t_uid=uid, check_time=dt['time'], item_id=dt['class_list'])
    if not dt.get('N'):
        dt['N'] = 181.0
    if not dt.get('E'):
        dt['E'] = 181.0
    print(dt)
    return render(request, 'check.html', dt)