当前位置: 首页>>代码示例>>Python>>正文


Python Customer.name方法代码示例

本文整理汇总了Python中models.Customer.name方法的典型用法代码示例。如果您正苦于以下问题:Python Customer.name方法的具体用法?Python Customer.name怎么用?Python Customer.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Customer的用法示例。


在下文中一共展示了Customer.name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addCustomer

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import name [as 别名]
def addCustomer():
    form = AddCustomerForm()

    form.recommender.choices = [(0, '')]
    poss_customers = Customer.query\
        .filter(Customer.customer_type == CUSTOMER_TYPES['TYPE_CUSTOMER']).all()
    for cust in poss_customers:
        form.recommender.choices.append((cust.id, cust.name))

    if form.validate_on_submit():
        customer = Customer()

        customer.name = form.name.data
        customer.email = form.email.data
        customer.base_discount = int(form.base_discount.data)/100.0

        if form.recommender.data and form.recommender.data > 0:
                customer.recommender_id = form.recommender.data

        customer.company_name = form.company_name.data
        if form.post_code1.data and form.post_code2.data:
            customer.post_code = int(str(form.post_code1.data) + str(form.post_code2.data))
        else:
            customer.post_code = None
        customer.address1 = form.address1.data
        customer.address2 = form.address2.data
        customer.address3 = form.address3.data

        db.session.add(customer)
        db.session.commit()
        flash(gettext("New customer successfully added."))
        return redirect(url_for("customers"))
    return render_template('settings/addCustomer.html',
                           title=gettext("Add New Customer"),
                           form=form)
开发者ID:HeinzHinek,项目名称:AxiStore,代码行数:37,代码来源:viewsCustomer.py

示例2: post_customer

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import name [as 别名]
def post_customer(request):
	customer_data = json.loads(request.body)
	mail = customer_data.get('mail', None)
	phone = customer_data.get('phone', None)
	password = customer_data.get('password', None)
	name = customer_data.get('name', u'狗蛋儿')

	if mail is None or password is None or phone is None:
		content = dict()
		content['status'] = 422
		content['msg'] = u'信息缺失'
		return create_simple_response(422, json.dumps(content))
	if str(mail).split('@')[-1] != 'bjtu.edu.cn':
		content = dict()
		content['status'] = 422
		content['msg'] = u'邮箱不符,现阶段只对北京交大邮箱开放注册'
		return create_simple_response(422, json.dumps(content))

	new_customer = Customer()
	new_customer.mail = mail
	new_customer.phone = phone
	new_customer.password = password
	new_customer.token = generate_token()
	new_customer.name = name
	if_signed = new_customer.signup_customer()

	if if_signed:
		content = dict()
		try:
			query_str = 'customers/'+str(new_customer.id)+'?validate=true&token='+new_customer.token
			reg_msg = u'感谢您注册顺道儿,请点击链接完成验证: <a href="%s%s%s">- 验证 GO -</a>'%(BASE_SCHEMES, BASE_PATH, query_str)
			send_register_email(new_customer.mail, reg_msg, reg_subject)
		except:
			content['status'] = 422
			content['msg'] = u'验证失败'
		else:
			content['status'] = 201
			content['msg'] = u'注册成功,请登录邮箱进行验证'
			content['href'] = '%s%s%s' % (BASE_PATH, 'customers/', str(new_customer.id))
		finally:
			return create_simple_response(201, json.dumps(content))
	else:
		content = dict()
		content['status'] = 422
		content['msg'] = u'注册失败'
		return create_simple_response(422, json.dumps(content))
开发者ID:carpaanddonkey,项目名称:byway,代码行数:48,代码来源:customers.py


注:本文中的models.Customer.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。