本文整理匯總了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)))