Esempio n. 1
0
    def get(self, request):
        color = Colored()
        current_time = datetime.datetime.now()
        user = request.user

        try:
            LXMB.objects.all()
        except LXMB.DoesNotExist:
            print(
                color.blue('[' + str(current_time) + '] --> ' + user.username +
                           '打开了票件模板的页面,可惜里面并没有模板文件'))
            return render(request, 'TouPiaoXiTong/ckmbwj.html',
                          {'msg': '暂无模板文件,请在后台创建'})
        all_models = LXMB.objects.all()
        lxmc_list = []
        for a in all_models:
            b = XMLX.objects.get(id=a.id)
            lxmc_list.append(b)

        context = {
            'flag2': 'ckmbwj',
            'mb': all_models,
            'lxmc_list': lxmc_list,
        }
        # username = request.COOKIES.get('username')

        print(
            color.blue('[' + str(current_time) + '] --> ' + user.username +
                       '打开了票件模板的页面'))
        return render(request, 'TouPiaoXiTong/ckmbwj.html', context)
Esempio n. 2
0
 def get(self, request):
     color = Colored()
     current_time = datetime.datetime.now()
     context = {
         'flag2': 'cjxtp',
     }
     # username = request.COOKIES.get('username')
     user = request.user
     print(
         color.blue('[' + str(current_time) + '] --> ' + user.username +
                    '打开了添加投票的页面'))
     return render(request, 'TouPiaoXiTong/cjxtp.html', context)
Esempio n. 3
0
    def get(self, request):
        color = Colored()
        current_time = datetime.datetime.now()

        allV = TPXM.objects.all()

        context = {'flag2': 'cktpxm', 'all': allV}
        # username = request.COOKIES.get('username')
        user = request.user
        print(
            color.blue('[' + str(current_time) + '] --> ' + user.username +
                       '打开了所有投票票件列表'))
        return render(request, 'TouPiaoXiTong/cktpxm.html', context)
Esempio n. 4
0
def tongjiFunc(request):
    color = Colored()
    current_time = datetime.datetime.now()
    # gender = request.POST.get("gender")
    # AH = request.POST.getlist("aihao")
    username = request.user
    choice = request.POST.get('tp')
    if not choice:
        return render(request, 'TouPiaoXiTong/ok.html', {
            'msg': '您没选哦~我帮您跳回首页吧,不客气~~~:)',
            'sMSG': '哦不好意思,我不会做自动跳转。。。您自己点点吧~~'
        })
    else:
        print(
            color.yellow('[' + str(current_time) + '] --> ' + str(username) +
                         '选择了' + str(XXSJ.objects.get(XXID=choice))))
        try:
            tongjiCount.objects.get(XXID=(XXSJ.objects.get(XXID=choice)))
        except tongjiCount.DoesNotExist:
            data = tongjiCount(XXID=(XXSJ.objects.get(XXID=choice)), COUNT=0)
            data.save()
            data2 = tongjiCount.objects.get(XXID=(XXSJ.objects.get(
                XXID=choice)))
            temp = data2.COUNT
            data2.COUNT = temp + 1
            data2.save()
            tj = tongji(XXID=(XXSJ.objects.get(XXID=choice)),
                        TPR=(BankAccount.objects.get(account=(User.objects.get(
                            username=username)))))
            tj.save()
            print(
                color.blue('[' + str(current_time) + '] --> ' + str(username) +
                           '的选择在数据库中是新创建的,并且成功写入了数据库'))
            # print(choice)
            return render(request, 'TouPiaoXiTong/ok.html', {'msg': '投票成功'})
        data = tongjiCount.objects.get(XXID=(XXSJ.objects.get(XXID=choice)))
        temp = data.COUNT
        data.COUNT = temp + 1
        data.save()

        tj = tongji(XXID=(XXSJ.objects.get(XXID=choice)),
                    TPR=(BankAccount.objects.get(account=(User.objects.get(
                        username=username)))))
        tj.save()
        print(
            color.blue('[' + str(current_time) + '] --> ' + str(username) +
                       '的选择成功写入了数据库'))
        # print(choice)
        return render(request, 'TouPiaoXiTong/ok.html', {'msg': '投票成功'})
Esempio n. 5
0
    def get(self, request):
        color = Colored()
        current_time = datetime.datetime.now()
        x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
        if x_forwarded_for:
            ip = x_forwarded_for.split(',')[0]  # 所以这里是真实的ip
        else:
            ip = request.META.get('REMOTE_ADDR')  # 这里获得代理ip
        # print(ip)

        print(
            color.blue('[' + str(current_time) + '] --> ' + ip + '打开了数据库操作页面'))

        info = orcl_cz.objects.all()
        context = {'info': info}
        return render(request, 'orcl/idx.html', context)
Esempio n. 6
0
    def get(self, request):
        current_time = datetime.datetime.now()
        color = Colored()
        """退出登录"""
        # now_time = times()
        user = request.user
        # 清除用户的session信息
        logout(request)
        # print("[" + str(now_time) + "]" + user + "退出登录")
        print(color.green(user.username + "退出登录"))

        if 'username' in request.COOKIES:
            usCookies = request.COOKIES.get('username')
            print(color.red('[' + str(current_time) + '] --> ' + usCookies + '的Cookies记录没有清除,或许登陆时该用户选择了“记住用户名'))
        else:
            print(color.red(
                '[' + str(current_time) + '] --> ' + user.username + '的Cookies记录不存在或者在登陆时已被清除,原因是登陆时该用户没有选择“记住用户名'))

        # 跳转到首页
        return redirect(reverse('index:oa_index'))
Esempio n. 7
0
def jlip(request, czID):
    cz = orcl_cz.objects.get(id=czID)
    color = Colored()
    current_time = datetime.datetime.now()
    x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
    if x_forwarded_for:
        ip = x_forwarded_for.split(',')[0]  # 所以这里是真实的ip
    else:
        ip = request.META.get('REMOTE_ADDR')  # 这里获得代理ip
    # print(ip)

    print(
        color.blue('[' + str(current_time) + '] --> ' + ip + '执行了' + cz.czmc +
                   '操作'))

    username = request.user
    ls = orcl_cz_ls(ip=str(ip),
                    isSuccess='是',
                    czbm=(orcl_cz.objects.get(id=czID)),
                    czr=(BankAccount.objects.get(account=(User.objects.get(
                        username=username)))))
    ls.save()
Esempio n. 8
0
def useModel(request, mb_id):
    color = Colored()
    current_time = datetime.datetime.now()
    username = request.user
    mb = LXMB.objects.get(MBID=mb_id)
    mbmc = XMLX.objects.get(LXID=str(mb))
    # mblx = XMLXZD
    user = User.objects.get(username=username)
    cjr = BankAccount.objects.get(account_id=user.id)

    context = {'mb': mb, 'mbmc': mbmc, 'cjr': cjr, 'cjrq': current_time}
    print(mb)
    return render(request, 'TouPiaoXiTong/XMMB/' + str(mb.MBID) + '.html',
                  context)
Esempio n. 9
0
    def post(self, request):
        current_time = datetime.datetime.now()
        """登录校验"""
        # 接收数据
        username = request.POST.get('username')
        password = request.POST.get('password')
        nextURL = request.POST.get('next')

        # 校验数据
        if not all([username, password]):
            return render(request, 'user/login.html', {'errmsg': '数据不完整'})

        # 业务处理:登录校验
        user = authenticate(username=username, password=password)
        if user is not None:
            # 用户名密码正确
            if user.is_active:
                # 用户已激活
                # 记录用户的登陆状态
                # 天坑!!!!!!!
                # 未激活用户依旧返回None
                # 详见settings解决方案
                login(request, user)

                # 登陆装饰器
                # 获取登陆后所要跳转的地址
                ctx = {
                    'user': user
                }
                next_url = request.GET.get('next', reverse('index:oa_index'))
                # now_time = times()
                # print("[" + now_time + "]" + username + "登陆了。")
                color = Colored()
                print(color.green('[' + str(current_time) + '] --> ' + username + "登陆了"))
                print(color.green('[' + str(current_time) + '] --> ' + "是即将跳转的URL"))

                # 假若这个人故意删除next后面的地址,则next_URL = None
                # 后面的response就会报错
                # 所以在最后要设置默认跳转,以防小人捣乱

                # 跳转到接收到的next值
                response = redirect(next_url, ctx)  # HttpResponseRedirect

                # 判断是否需要记住用户名
                remember = request.POST.get('remember')

                if remember == 'on':
                    # 记住用户名
                    response.set_cookie('username', username, max_age=7 * 24 * 3600)
                    print(color.green('[' + str(current_time) + '] --> ' + username + '的登录信息已经被写进了Cookies'))
                else:
                    response.delete_cookie('username')
                    print(
                        color.red('[' + str(current_time) + '] --> ' + username + '的登录信息已经从Cookies中移除,原因是用户未选择“记住用户名”'))

                # 返回response
                # response.set_cookie('username', username, max_age=7 * 24 * 3600)
                # print(username + '的登录信息已经被写进了Cookies')
                return response
            else:
                # 用户未激活
                return render(request, 'user/login.html', {'errmsg': '账户未激活'})
        else:
            # 用户名或密码错误
            return render(request, 'user/login.html', {'errmsg': '用户名或密码错误'})