本文整理汇总了Python中models.Customer类的典型用法代码示例。如果您正苦于以下问题:Python Customer类的具体用法?Python Customer怎么用?Python Customer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Customer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
def login(request):
info = ''
if request.method == "POST":
form = LoginForm(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
password = form.cleaned_data['password']
if email == '[email protected]':
if password == 'password':
request.session['is_admin'] = True
request.session['uid'] = '-1'
request.session['user'] = 'HotelAdmin'
info = '登陆成功'
else :
info = '密码错误!'
elif not Customer.contain_email(email):
info = 'EMAIL不存在!'
elif not Customer.is_auth(email, password):
info = '密码错误!'
else:
customer = Customer.objects.get(email = email)
request.session['is_admin'] = False
request.session['uid'] = customer.customer_id
request.session['user'] = email
info = '登录成功'
form = LoginForm()
return render(request, 'login.html', {'form' : form, 'info' : info})
示例2: GetCustomerData
def GetCustomerData(self,dataPost):
customerData = Customer()
customerData.email = dataPost['email']
customerData.name_last = dataPost['lastName']
customerData.name_first = dataPost['firstName']
return customerData
示例3: create
def create(self, request, **kwargs):
serializer = CustomerSerializer(data=request.data)
if serializer.is_valid():
user = save_user(request.data, UserPermissions.IS_CUSTOMER)
city = City(**request.data["city"])
customer = Customer(
name=request.data["name"],
type=UserType.CUSTOMER,
lastName=request.data["lastName"],
address=request.data["address"],
identityDoc=request.data["identityDoc"],
homePhone=request.data["homePhone"],
cellPhone=request.data["cellPhone"],
email=request.data["email"],
city=city,
user=user,
)
customer.save()
return Response(
{
"status": "SUCCESS",
"msg_status": "Cliente creado satisfactoriamente. Puede ingresar con su nueva contrasena.",
}
)
else:
messages = []
make_error(serializer.errors.values(), messages)
return Response({"status": "FAILURE", "msg_status": messages})
示例4: post
def post(self):
if not self.is_logged_in():
self.redirect(LOGIN_PAGE_URL)
else:
customer = Customer.get_by_key_name(self.get_current_username())
customer.first_name = self.get_argument('first_name')
customer.last_name = self.get_argument('last_name')
customer.timezone = self.get_argument('timezone')
landline_key = self.get_argument('landline_key')
landline = db.get(db.Key(landline_key))
landline.number = self.get_argument('landline_number')
mobile_key = self.get_argument('mobile_key')
mobile = db.get(db.Key(mobile_key))
mobile.number = self.get_argument('mobile_number')
location_key = self.get_argument('location_key')
location = db.get(db.Key(location_key))
location.city = self.get_argument('city')
location.country = self.get_argument('country')
location.state_or_province = self.get_argument('state_or_province')
location.area_or_suburb = self.get_argument('area_or_suburb')
location.street_name = self.get_argument('street_name')
location.zip_code = self.get_argument('zip_code')
db.put([customer, mobile, landline, location])
self.get()
示例5: test_point_deletion
def test_point_deletion(self):
result = Customer.get_points_for('sudhirurl')
start_count = len(result)
first_point = result[0]
Point.delete_point(first_point['key'], self.sudhir_gmail)
new_result = Customer.get_points_for('sudhirurl')
self.assertEqual(len(new_result), start_count - 1)
self.assertFalse(self.find(new_result, first_point))
示例6: test_get_current_user_url
def test_get_current_user_url(self):
url = Customer.get_url_by_user(self.sudhir_gmail)
self.assertEqual(url, 'sudhirurl')
url = Customer.get_url_by_user(users.User('[email protected]'))
self.assertFalse(url)
url = Customer.get_url_by_user(None)
self.assertFalse(url)
示例7: create_customer
def create_customer(user):
s1 = Customer(user=user,
name=user.username,
address= default_address,
city= default_city,
state= default_state,
email=user.email,
creation_date=datetime.datetime.now(),
active=True)
s1.save()
示例8: createCustomer
def createCustomer(self,request):
c_id = Customer.allocate_ids(size=1)[0]
c_key = ndb.Key(Customer, c_id)
data = {field.name: getattr(request, field.name) for field in request.all_fields()}
data['key'] = c_key
query = Customer.query().filter(Customer.mobileNumber == data['mobileNumber'])
entity = query.get()
if entity:
raise Exception('unique_property must have a unique value!')
Customer(**data).put()
return self._copyCustomerToForm(c_key.get())
示例9: login
def login(request):
if request.method == "POST":
form = LoginForm(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
password = form.cleaned_data['password']
if not Customer.contain_email(email):
return render(request, 'login.html', {'form' : form , 'non_exist_email' : True})
elif not Customer.is_auth(email, password):
return render(request, 'login.html', {'form' : form , 'wrong_password' : True})
else:
print "login successfully"
form = LoginForm()
return render(request, 'login.html', {'form' : form})
示例10: update_customer_credit_debit_total
def update_customer_credit_debit_total(self,data,c_key,credit):
x = Customer.query(ancestor = data['custId'])
obj = c_key.get()
obj.debit = obj.debit + data['orderPrice']
obj.credit = obj.credit + credit
obj.total = obj.debit - obj.credit
obj.put()
示例11: _handler
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))
示例12: login_api
def login_api(request):
info = ''
status_code = -1
customer = None
if request.method == "GET":
form = request.GET
email = form['email']
password = form['password']
if not Customer.contain_email(email):
status_code = 1
elif not Customer.is_auth(email, password):
status_code = 2
else:
customer = Customer.objects.get(email = email)
status_code = 0
return render(request, 'auth.json', {'status_code' : status_code, 'customer' : customer})
示例13: registration
def registration(request):
if request.user.is_authenticated():
# ideal, but not created yet, going with homepage
#return HttpResponseRedirect('/profile/')
return HttpResponseRedirect('/')
if request.method == 'POST':
#fills out with whatever was posted
form = RegistrationForm(request.POST)
# runs all clean methods in form
if form.is_valid():
try: #customer exists
cusAlreadyExists = User.objects.get(username=
form.cleaned_data['username'])
username_taken = True
context = {'form': form, 'username_taken': username_taken}
return render_to_response('register.html', context,
context_instance=RequestContext(request))
except User.DoesNotExist: #customer did not exist
user = User.objects.create_user(
username=form.cleaned_data['username'],
password=form.cleaned_data['password1'])
user.save()
addr = Address(
AddressLineOne = form.cleaned_data['street'],
City = form.cleaned_data['city'],
State = form.cleaned_data['state'],
ZIPCode = form.cleaned_data['zipcode']
)
addr.save()
customer = Customer(user=user, Address=addr,
FirstName = form.cleaned_data['firstName'],
LastName = form.cleaned_data['lastName']
)
customer.save()
customer = authenticate(username=form.cleaned_data['username'],
password=form.cleaned_data['password1'])
login(request, customer)
return HttpResponseRedirect('/')
else:
return render_to_response('register.html', {'form': form},
context_instance=RequestContext(request))
else:
#user not submitting the form, send blank form
form = RegistrationForm()
context = {'form': form}
return render_to_response('register.html', context,
context_instance=RequestContext(request))
示例14: __init__
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)
示例15: getCustomerList
def getCustomerList(self,request):
c = []
query1 = Customer.query()
for q in query1:
setattr(q,'custId',q.key)
c.append(self._copyCustomerTotalDetailToForm(q))
return CustomerList(customerList=c)