예제 #1
0
파일: views.py 프로젝트: lionel126/antireg
def mobile(request, mobile):
    if request.method == 'GET':
        qs = MERCHANT_OPERATOR.objects.filter(login_name__contains=mobile)
        print(qs)
        return render(request, 'polls/list.html', {"mobiles": qs})

    if request.method == 'POST':
        qs = MERCHANT_OPERATOR.objects.filter(id=mobile)
        print(connection.queries)
        print(qs)
        utils.validate('MERCHANT_OPERATOR', len(qs))

        r = qs[0]
        print('MERCHANT_OPERATOR {} to be delete..'.format(r))
        if request.POST.get('op') == 'unbind':
            r.delete()
        print(connection.queries)
        qs = MERCHANT_OPERATOR.objects.filter(id=mobile)
        utils.validate('MERCHANT_OPERATOR', len(qs), 0)
        return JsonResponse(serializers.serialize('json', qs),
                            safe=False)
예제 #2
0
파일: views.py 프로젝트: lionel126/antireg
def ksnno(request, ksnno):
    if request.method == 'GET':
        ksns = MCR_KSN.objects.filter(ksn_no__contains=ksnno)
        return render(request, 'polls/list.html', {"ksns": ksns})
        # return JsonResponse(dict(ksns=list(ksns)))
    if request.method == 'POST':
        ksns = MCR_KSN.objects.filter(ksn_no=ksnno)
        print(ksns)
        utils.validate('ksn', len(ksns))
        k = ksns[0]
        print('ksn {} to be unbound..'.format(k))
        if request.POST.get('op') == 'unbind':
            result = {"is_used": "0", "is_activated": "0", "mac_address": ""}
            for key, value in result.items():
                setattr(k, key, value)
            k.save()
        ksns = MCR_KSN.objects.filter(ksn_no=ksnno)
        utils.validate('ksn', len(ksns))
        print(ksns.values())
        return JsonResponse(serializers.serialize('json', ksns),
                            safe=False)
예제 #3
0
파일: views.py 프로젝트: lionel126/antireg
def sn(request, sn):
    if request.method == 'GET':
        sns = MCR_SERIAL_NUMBER.objects.filter(code__contains=sn)
        return render(request, 'polls/list.html', {"sns": sns})

    if request.method == 'POST':
        sns = MCR_SERIAL_NUMBER.objects.filter(code=sn)
        print(sns)
        utils.validate('sn', len(sns))

        k = sns[0]
        print('sn {} to be unbound..'.format(k))
        if request.POST.get('op') == 'unbind':
            result = {"is_used": "0", "ksn_id": None,
                      "terminal_id": None, "is_cancell": 0}
            for key, value in result.items():
                setattr(k, key, value)
            k.save()

        sns = MCR_SERIAL_NUMBER.objects.filter(code=sn)
        utils.validate('sn', len(sns))
        return JsonResponse(serializers.serialize('json', sns),
                            safe=False)
예제 #4
0
파일: views.py 프로젝트: lionel126/antireg
def bankaccount(request, bankaccount):
    if request.method == 'GET':
        qs = BANK_ACCOUNT.objects.filter(account_no__contains=bankaccount)
        print(qs)
        return render(request, 'polls/list.html', {"bank_accounts": qs})

    if request.method == 'POST':
        qs = BANK_ACCOUNT.objects.filter(account_no=bankaccount)
        print(qs)
        utils.validate('bankaccount', len(qs))

        r = qs[0]
        print('bankaccount {} to be unbound..'.format(r))
        if request.POST.get('op') == 'unbind':
            result = {"is_used": "0", "ksn_id": None,
                      "terminal_id": None, "is_cancell": 0}
            for key, value in result.items():
                setattr(r, key, value)
            r.save()

        qs = BANK_ACCOUNT.objects.filter(account_no=bankaccount)
        utils.validate('bankaccount', len(qs))
        return JsonResponse(serializers.serialize('json', qs),
                            safe=False)