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


Python Customer.save方法代码示例

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


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

示例1: create

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import save [as 别名]
    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,代码行数:31,代码来源:viewsets.py

示例2: create_customer

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import save [as 别名]
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,代码行数:12,代码来源:services.py

示例3: save

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import save [as 别名]
 def save(self, user):
     try:	
         data = user.get_profile()
     except:
         data = Customer(user=user)
         
     print 'Inside save method of UserRegForm'
     
     data.first_name = self.cleaned_data["first_name"]
     data.last_name = self.cleaned_data["last_name"]
     data.address = self.cleaned_data["address"]
     data.city = self.cleaned_data["city"]
     data.zip = self.cleaned_data["zip"]
     data.date_of_birth = self.cleaned_data["date_of_birth"]
     data.save()
开发者ID:honzikd,项目名称:rc,代码行数:17,代码来源:profile.py

示例4: registration

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import save [as 别名]
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,代码行数:49,代码来源:views.py

示例5: save2db

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import save [as 别名]
 def save2db(self, details):
     
     for p in details:
         result = Customer.objects.filter(name__exact = p.get(helper.SHPDDataFile.NAME), 
                                          custom_no__exact= p.get(helper.SHPDDataFile.CUSTOMER_NO), 
                                          branch_name__exact = p.get(helper.SHPDDataFile.BRANCH))
         if len(result) == 1:
             'update'
             customer = result[0]
             customer.card_no = p.get(helper.SHPDDataFile.CARD_NO)
         else:
             'insert'
             customer = Customer(name=p.get(helper.SHPDDataFile.NAME), 
                                 custom_no = p.get(helper.SHPDDataFile.CUSTOMER_NO), 
                                 branch_name = p.get(helper.SHPDDataFile.BRANCH), 
                                 card_no = p.get(helper.SHPDDataFile.CARD_NO), 
                                 mobile=p.get(helper.SHPDDataFile.MOBILE))
         customer.save()
开发者ID:privateprojects,项目名称:sosproject,代码行数:20,代码来源:task.py

示例6: clean_email

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import save [as 别名]
 def clean_email(self):
     email = self.cleaned_data.get('email')
     name = self.cleaned_data.get('name',u'').strip()
     if name == noname:
         email='[email protected]'
     if email=='':
         raise forms.ValidationError("如果您要留名的话请输入邮箱地址")
  
     try:
         exist=Customer.objects.filter(name=name)[0]
     except:
         c=Customer(name=name,email=email)
         c.save()
         return email
     if exist.email != email:
         raise forms.ValidationError("邮箱与此用户名不匹配")
         return email
     return email
开发者ID:Crackpot,项目名称:gftop,代码行数:20,代码来源:forms.py

示例7: register

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import save [as 别名]
    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,代码行数:20,代码来源:services.py

示例8: register

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import save [as 别名]
def  register(request):
	register = Customer(firstname 	= 	request.POST.get('firstName'),
						lastname 	= 	request.POST.get('lastName'),
						username 	= 	request.POST.get('userName'),
						password 	= 	request.POST.get('password'),
						contactno 	= 	request.POST.get('contactNo'))
	register.save()
	custId = register.custid

	addAccount = Account(customerid = custId,
						 balance= request.POST.get('balance'))

	addAccount.save()
	# cust_id = res[0].id
	# return HttpResponse(cust_id)
	#return render(request,"myprojects/welcome.html")
	t 		= 	get_template("myprojects/sucess.html")
	text 	= 	'Registered Sucessfully'
	c 		= 	RequestContext(request, { 'text' : text } )
	return HttpResponse(t.render(c))
开发者ID:madhuvanthi,项目名称:Django-projects,代码行数:22,代码来源:views.py

示例9: register

# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import save [as 别名]
def register(request):
    """
    Save account info into db for customer and barber
    :param request: member raw_post_data should be raw json string,
                     with key username, password, gender, role
    :return: "success": save successfully
    """
    req = json.loads(request.body)
    usn = req['username']
    pwd = req['password']
    gd = req['gender']

    if cmp(req['role'], 'Customer') == 0:
        c = Customer(username=usn, password=pwd, gender=gd)
        c.save()
        return HttpResponse("success")
    else:
        b = Barber(username=usn, password=pwd, gender=gd)
        b.save()
        return HttpResponse("success")
开发者ID:herrsechs,项目名称:zhifa,代码行数:22,代码来源:views.py


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