本文整理汇总了Python中models.Customer.all方法的典型用法代码示例。如果您正苦于以下问题:Python Customer.all方法的具体用法?Python Customer.all怎么用?Python Customer.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Customer
的用法示例。
在下文中一共展示了Customer.all方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _handler
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import all [as 别名]
def _handler(self, account_slug, customer_slug, post=False):
user = users.get_current_user()
if user:
account = Account.all()\
.filter('user =', user).filter('slug =', account_slug).get()
customer = Customer.all()\
.filter('account =', account).filter('slug =', customer_slug).get()
if post:
form = CustomerForm(instance=customer, data=self.request.POST)
if form.is_valid():
# Save the data, and redirect to the view page
form.save()
self.redirect(account.get_absolute_url())
else:
form = CustomerForm(instance=customer)
path = os.path.join(os.path.dirname(__file__), 'templates/customer_details.html')
self.response.out.write(template.render(path, {
'account': account,
'customer': customer,
'form': form,
'user': user,
'logout_url': users.create_logout_url("/")
}))
else:
self.redirect(users.create_login_url(self.request.uri))
示例2: __init__
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import all [as 别名]
def __init__(self, user, *args, **kwargs):
super(IncomeForm, self).__init__(*args, **kwargs)
self.fields['customer'].query = Customer.all().filter('user =', user)\
.order('name').fetch(1000)
self.fields['category'].query = Category.all()\
.filter('user =', user)\
.filter('type =', 'Receita')\
.order('name').fetch(1000)
示例3: get
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import all [as 别名]
def get(self):
self.response.content_type = 'application/json'
c = Customer.all().get()
obj = {
'name': "%s %s" % (c.first_name, c.last_name),
'email': c.email,
'orders': []
}
for o in c.orders:
obj['orders'].append(o.record)
self.response.write(json.encode(obj))
示例4: get
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import all [as 别名]
def get(self, account_slug, customer_slug):
user = users.get_current_user()
if user:
account = Account.all()\
.filter('user =', user).filter('slug =', account_slug).get()
customer = Customer.all()\
.filter('account =', account).filter('slug =', customer_slug).get()
account.n_customers -= 1
account.put()
customer.delete()
self.redirect(account.get_absolute_url())
else:
self.redirect(users.create_login_url(self.request.uri))
示例5: post
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import all [as 别名]
def post(self):
email = self.get_string("email")
c = Customer.all().filter("email =", email).get()
if not c:
logging.info("Create customer %s", email)
c = Customer(first_name=self.get_string("firstname"),
last_name=self.get_string("lastname"),
email=db.Email(email))
db.put(c)
logging.info("Customer: %s is saved? %s, no of orders? %s", str(c), c.is_saved(), c.orders)
o = Order(customer=c,
record = self.get_string("musik"),
address = self.get_string("adress"),
postal_code = db.PostalAddress(self.request.get("postnummer")),
city = self.get_string("ort"),
phone = db.PhoneNumber(self.request.get("telefon")),
message = db.Text(self.request.get("meddelande")))
logging.info("Musik: %s", str(o))
db.put(o)
self.response.out.write("Det gick bra! %s, %s" % (str(c), str(o)))