示例#1
0
def register(req):
    body = {}
    if req.method == 'POST':
        resjson = simplejson.loads(req.body)
        phone = resjson['phone']
        verify = resjson['verify_code']
        passwd = resjson['password']
        mer_name = resjson['merchant_name']
        me_list = Merchant.objects.filter(alin_account=phone)
        if me_list.exists():
            body['msg'] = 'account aleady exist'
            return HttpResponse(encodejson(6, body),
                                content_type="application/json")
        if not verify_code(phone, verify):
            body['msg'] = 'verify code does not exist'
            return HttpResponse(encodejson(7, body),
                                content_type='application/json')
        hashpass = hashlib.md5(passwd).hexdigest()
        mytoken = createtoken()
        newmerchant = Merchant(alin_account=phone,
                               password=hashpass,
                               update_time=datetime.datetime.now(),
                               netspider_time=datetime.datetime.now(),
                               name=mer_name,
                               belongs=get_phone_belong(phone),
                               private_token=mytoken)
        newmerchant.save()
        body['msg'] = 'register success, wait for auth'
        return HttpResponse(encodejson(0, body),
                            content_type='application/json')
    else:
        raise Http404
示例#2
0
def register(req):
    body={}
    if req.method == 'POST':
        resjson = simplejson.loads(req.body)
        phone = resjson['phone']
        verify = resjson['verify_code']
        passwd = resjson['password']
        mer_name = resjson['merchant_name']
        me_list = Merchant.objects.filter(alin_account=phone)
        if me_list.exists():
            body['msg'] = 'account aleady exist'
            return HttpResponse(encodejson(6, body), content_type="application/json")
        if not verify_code(phone, verify):
            body['msg'] = 'verify code does not exist'
            return HttpResponse(encodejson(7, body), content_type='application/json')
        hashpass = hashlib.md5(passwd).hexdigest()
        mytoken = createtoken()
        newmerchant = Merchant(alin_account=phone,
                               password=hashpass,
                               update_time=datetime.datetime.now(),
                               netspider_time=datetime.datetime.now(),
                               name=mer_name,
                               belongs=get_phone_belong(phone),
                               private_token=mytoken)
        newmerchant.save()
        body['msg'] = 'register success, wait for auth'
        return HttpResponse(encodejson(0, body), content_type='application/json')
    else:
        raise Http404
示例#3
0
文件: views.py 项目: sbyinin/Alinone
def register(request):
    if request.method == 'POST':
        password = request.POST.get('password')
        merchant_name = request.POST.get('merchant_name')
        phone = request.POST.get('phone')
        verify = request.POST.get('verify')
        if password and merchant_name and phone and verify and len(phone) == 11:
            user_test_list = Merchant.objects.filter(alin_account=phone)
            if user_test_list.count() > 0:
                return render_to_response('register.html', {'phone': phone, 'merchant_name': merchant_name,
                                                            'fault2': 'T'}, context_instance=RequestContext(request))
            phone_verify = PhoneVerify.objects.filter(phone=str(phone), verify_code=str(verify))
            if phone_verify.count() > 0:
                update_time = phone_verify[0].update_time
                if (update_time.replace(tzinfo=None) + datetime.timedelta(minutes=30)) < \
                        datetime.datetime.utcnow():
                    return render_to_response('register.html', {'phone': phone, 'merchant_name': merchant_name,
                                                                'fault1': 'T'}, context_instance=RequestContext(request))
                else:
                    newmerchant = Merchant()
                    newmerchant.alin_account = phone
                    password = hashlib.md5(password).hexdigest()
                    newmerchant.password = password
                    newmerchant.name = merchant_name
                    newmerchant.belongs = get_phone_belong(phone)
                    newmerchant.save()
                    request.session['username'] = phone
                    qr_bind = createqr(2, newmerchant.id)
                    request.session['qr_bind'] = qr_bind
                    phone_verify.delete()
                    newlog = AccountLog()
                    newlog.atype = '商家'
                    newlog.content = '商家注册'
                    newlog.ltype = 14
                    newlog.note = '注册'
                    newlog.account = str(phone)
                    newlog.save()
                    return render_to_response('login_page.html', {'flag': 2}, context_instance=RequestContext(request))
            else:
                return render_to_response('register.html', {'phone': phone, 'merchant_name': merchant_name,
                                                            'fault3': 'T'}, context_instance=RequestContext(request))
        else:
            return render_to_response('register.html', context_instance=RequestContext(request))
    else:
        return render_to_response('register.html', context_instance=RequestContext(request))
示例#4
0
文件: views.py 项目: sbyinin/Alinone
def register(req):
    body = {}
    if req.method == 'POST':
        reqdata = simplejson.loads(req.body)
        username = reqdata['username']
        nick = reqdata['nick']
        passwd = reqdata['password']
        code = reqdata['reg_code']
        ishave = Sender.objects.filter(phone=str(username))
        if ishave.count() == 0:
            is_send_list = PhoneVerify.objects.filter(phone=str(username))
            if is_send_list.count() == 0:
                return HttpResponse(encodejson(11, body),
                                    content_type="application/json")
            is_send = is_send_list[0]
            if str(is_send.verify_code) == str(code):
                mytoken = createtoken()
                newsender = Sender()
                newsender.phone = username
                newsender.password = hashlib.md5(passwd).hexdigest()
                newsender.active_time = datetime.datetime.now()
                newsender.nick = nick
                newsender.belongs = get_phone_belong(username)
                newsender.private_token = mytoken
                newsender.save()
                body["private_token"] = mytoken
                is_send.delete()
                newlog = AccountLog()
                newlog.account = str(username)
                newlog.atype = '物流'
                newlog.ltype = 2
                newlog.note = '注册'
                newlog.content = '外卖人员注册'
                newlog.save()
                return HttpResponse(encodejson(1, body),
                                    content_type="application/json")
            else:
                return HttpResponse(encodejson(12, body),
                                    content_type="application/json")
        else:
            return HttpResponse(encodejson(6, body),
                                content_type="application/json")
    else:
        raise Http404
示例#5
0
def register(req):
    body = {}
    if req.method == 'POST':
        reqdata = simplejson.loads(req.body)
        username = reqdata['username']
        nick = reqdata['nick']
        passwd = reqdata['password']
        code = reqdata['reg_code']
        ishave = Sender.objects.filter(phone = str(username))
        if ishave.count() == 0:
            is_send_list = PhoneVerify.objects.filter(phone = str(username))
            if is_send_list.count() == 0:
                return HttpResponse(encodejson(11, body), content_type="application/json")
            is_send = is_send_list[0]
            if str(is_send.verify_code) == str(code):
                mytoken = createtoken()
                newsender = Sender()
                newsender.phone = username
                newsender.password = hashlib.md5(passwd).hexdigest()
                newsender.active_time = datetime.datetime.now()
                newsender.nick = nick
                newsender.belongs = get_phone_belong(username)
                newsender.private_token = mytoken
                newsender.save()
                body["private_token"] = mytoken
                is_send.delete()
                newlog = AccountLog()
                newlog.account = str(username)
                newlog.atype = '物流'
                newlog.ltype = 2
                newlog.note = '注册'
                newlog.content = '外卖人员注册'
                newlog.save()
                return HttpResponse(encodejson(1, body), content_type="application/json")
            else:
                return HttpResponse(encodejson(12, body), content_type="application/json")
        else:
            return HttpResponse(encodejson(6, body), content_type="application/json")
    else:
        raise Http404