本文整理汇总了Python中models.Customer类的典型用法代码示例。如果您正苦于以下问题:Python Customer类的具体用法?Python Customer怎么用?Python Customer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Customer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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})
开发者ID:vaputa,项目名称:chain-hotel-book-system,代码行数:28,代码来源:views.py
示例2: GetCustomerData
def GetCustomerData(self,dataPost):
customerData = Customer()
customerData.email = dataPost['email']
customerData.name_last = dataPost['lastName']
customerData.name_first = dataPost['firstName']
return customerData
开发者ID:GregMartinUCB,项目名称:djangoStripe,代码行数:7,代码来源:dataLinker.py
示例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})
开发者ID:emosquera,项目名称:ticketIntelligence,代码行数:29,代码来源:viewsets.py
示例4: 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))
开发者ID:dlokesh,项目名称:mappr,代码行数:8,代码来源:point_model_tests.py
示例5: 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)
开发者ID:dlokesh,项目名称:mappr,代码行数:9,代码来源:customer_model_tests.py
示例6: 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()
开发者ID:rvanderwall,项目名称:Trading-Zone,代码行数:10,代码来源:services.py
示例7: 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())
开发者ID:nipun0212,项目名称:Shiv-Dugdh-Bhandar,代码行数:11,代码来源:dairymanagement.py
示例8: 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})
开发者ID:guoch,项目名称:chain-hotel-book-system,代码行数:14,代码来源:views.py
示例9: 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()
开发者ID:nipun0212,项目名称:Shiv-Dugdh-Bhandar,代码行数:7,代码来源:dairymanagement.py
示例10: _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))
开发者ID:jbochi,项目名称:depoisdavirgula,代码行数:28,代码来源:main.py
示例11: 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()
开发者ID:yesudeep,项目名称:maths-school-activation,代码行数:30,代码来源:handlers.py
示例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})
开发者ID:vaputa,项目名称:chain-hotel-book-system,代码行数:16,代码来源:views.py
示例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))
开发者ID:cwardcode,项目名称:DatabaseProject-cs453st2,代码行数:47,代码来源:views.py
示例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)
开发者ID:jbochi,项目名称:depoisdavirgula,代码行数:8,代码来源:forms.py
示例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)
开发者ID:nipun0212,项目名称:Shiv-Dugdh-Bhandar,代码行数:8,代码来源:dairymanagement.py
示例16: test_point_editing
def test_point_editing(self):
result = Customer.get_points_for('sudhirurl')
start_count = len(result)
new_point_dict = dict(lat=7.0, lon=7.0, title="seven")
new_point_key = Point.create_point(self.sudhir, new_point_dict).key().__str__()
result = Customer.get_points_for('sudhirurl')
self.assertEqual(len(result), start_count + 1)
self.assertTrue(self.find(result, new_point_dict))
new_point_dict = dict(lon=7.0, lat=8.0, title='seveneight')
Point.edit(new_point_key, new_point_dict, self.sudhir_gmail)
new_results = Customer.get_points_for('sudhirurl')
self.assertEqual(len(new_results), start_count + 1)
self.assertTrue(self.find(new_results, new_point_dict))
self.assertRaises(db.BadValueError, Point.edit, new_point_key, dict(lon=2345, lat=3, title='invalid values'), self.sudhir_gmail)
开发者ID:dlokesh,项目名称:mappr,代码行数:17,代码来源:point_model_tests.py
示例17: test_setting_points_for_user
def test_setting_points_for_user(self):
mom = models.Customer(user=users.User('[email protected]'), url='momurl')
mom.put()
confirmation = Point.create_point(mom, dict(lat=34.678, lon= -44.3456))
self.assertTrue(confirmation)
result = Customer.get_points_for('momurl')
self.assertEqual(len(result), 1)
self.assertEqual(result.count(dict(lat=34.678, lon= -44.3456, title='Untitled', key=str(confirmation.key()))), 1)
开发者ID:dlokesh,项目名称:mappr,代码行数:8,代码来源:point_model_tests.py
示例18: test_get
def test_get(self):
c = Customer(name='foobar', sites=["foo.com", "bar.co.uk"])
self.session.add(c)
self.session.commit()
b = Customer.get(c.id)
self.assertEqual(c.id, b.id)
self.assertEqual(c.name, b.name)
self.assertEqual(c.sites, b.sites)
开发者ID:venkateshRS,项目名称:ape,代码行数:9,代码来源:tests.py
示例19: register
def register(self, request, username, password, password_again):
if password_again != password:
raise Exception("Passwords don't match")
user = User(username=username)
user.set_password(password)
try:
user.save()
except:
raise Exception("Email already taken")
customer = Customer(user=user)
customer.save()
self.login(request, username, password)
return customer
开发者ID:Chitrank-Dixit,项目名称:backbone-tastypie-example,代码行数:18,代码来源:services.py
示例20: get
def get(self):
if not self.is_logged_in():
self.redirect(LOGIN_PAGE_URL)
else:
customer = Customer.get_by_key_name(self.get_current_username())
subscriptions = []
for order in customer.orders:
subscriptions.append(order.subscription)
self.render('unsubscribe.html', subscriptions=subscriptions)
开发者ID:yesudeep,项目名称:maths-school-activation,代码行数:9,代码来源:handlers.py
注:本文中的models.Customer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论