示例#1
0
def add_address():
    address = Address()
    res = address.a_position = "半人马座-{}".format(randrange(1000))
    # 注意这里倒序的写法
    address.a_customer_id = Customer.query.order_by(
        Customer.id.desc()).first().id

    models.session.add(address)
    models.session.commit()

    return "[ {} ][ 地址添加成功 ]".format(res)
示例#2
0
def add_address(request):
    if request.method == "GET":
        return render(request, 'order/order_add_address.html')

    elif request.method == "POST":
        address = Address()
        address.a_nickname = request.POST['nickname']
        address.a_phone = request.POST['phone']
        address.a_detail = request.POST['detail']
        address.a_user = request.user
        address.save()

        return redirect(reverse('App:address'))
示例#3
0
def add_address():
    a = Address()
    a.email = "*****@*****.**"
    a.person_id = Person.query.order_by(Person.id.desc()).first().id
    a.save()

    return "add address success"
示例#4
0
def add_address():
    address = Address()
    address.a_address = "召唤师峡谷{}".format(random.randrange(10000))
    address.c_customer_id = Customer.query.order_by(
        Customer.id.desc()).first().id

    address.save()

    return "add address success %s " % address.c_customer_id
示例#5
0
def add_address(request):
    new_address = request.GET.get("new_address")

    print(new_address)

    address_obj = Address()
    address_obj.a_address = new_address
    address_obj.a_user = request.user
    address_obj.a_using = True
    address_obj.save()

    data = {
        "status": 200,
        "msg": "ok",
    }
    return JsonResponse(data)
示例#6
0
文件: order.py 项目: gaozhenliang/axf
def shipAddress(req):
    if req.method == 'GET':
        return render(req, 'shippaddress.html')
    if req.method == 'POST':
        name = req.POST.get('name')
        phone = req.POST.get('phone')
        address = req.POST.get('address')
        choose = req.POST.get('choose')
        try:
            Bool = False
            if choose:
                Bool = True
                Address.objects.all().update(choose=False)
            Address(address=address,
                    phone=phone,
                    name=name,
                    choose=Bool,
                    user=req.user).save()
        except Exception as e:
            print('error is {}'.format(e))
        return redirect(reverse('App:showaddress'))
    def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument(name='user_id', type=int)
        parser.add_argument(name='receiver', type=str)
        parser.add_argument(name='phone', type=str)
        parser.add_argument(name='details', type=str)
        parser.add_argument(name='isDefault', type=int)
        parse = parser.parse_args()
        user_id = parse.get('user_id')
        linkman = parse.get('receiver')
        tel = parse.get('phone')
        detail = parse.get('details')
        is_default = parse.get('isDefault')
        addres = Address.query.all()
        if is_default == 1:
            if addres:
                for addre in addres:
                    if addre.is_default == 1:
                        addre.is_default = 0
                        db.session.commit()
                    else:
                        pass

                address = Address()
                address.user_id = user_id
                address.linkman = linkman
                address.tel = tel
                address.detail = detail
                address.is_default = is_default
                db.session.add(address)
                db.session.commit()
                return jsonify({'msg':'添加成功!'})
            else:
                address = Address()
                address.user_id = user_id
                address.linkman = linkman
                address.tel = tel
                address.detail = detail
                address.is_default = is_default
                db.session.add(address)
                db.session.commit()
                return jsonify({'msg': '添加成功!'})

        elif is_default == 0:
            address = Address()
            address.user_id = user_id
            address.linkman = linkman
            address.tel = tel
            address.detail = detail
            address.is_default = is_default
            db.session.add(address)
            db.session.commit()
            return jsonify({'msg': '添加成功!'})
示例#8
0
def add_address():
    a = Address()
    a.address = "长岛%s号" % random.randrange(10000)
    a.save()

    return "add address success"
示例#9
0
def add_address(request):
    user = request.user
    if request.method == "GET":
        data = {
            "title": "添加收货地址",
        }
        return render(request, 'address/add_address.html', data)
    elif request.method == "POST":
        name = request.POST.get("name")
        phone = request.POST.get("phone")
        province = request.POST.get("province")
        city = request.POST.get("city")
        county = request.POST.get("county")
        more_addr = request.POST.get("more_addr")
        print(name, phone, province, city, county, more_addr)
        address = Address()
        address.a_username = name
        address.a_phone = phone
        address.a_province = province
        address.a_city = city
        address.a_county = county
        address.a_detailed_address = more_addr
        address.a_user = user
        address.save()
        return redirect(reverse("axf:selectaddress"))