def post(self): ''' Create a new customer. Returns its ID. ''' form = RegistrationForm.from_json(request.get_json()) if not form.validate_on_submit(): return jsonify(errors=form.errors) customer = Customer(email=form.email.data, password=form.password.data) CustomerService.add_customer(customer) return jsonify(id=customer.id)
def post(self): ''' Create a new customer. Returns its ID. ''' form = RegistrationForm.from_json(request.get_json()) if not form.validate_on_submit(): return jsonify(errors=form.errors) customer = Customer( email=form.email.data, password=form.password.data ) CustomerService.add_customer(customer) return jsonify(id=customer.id)
def post(self): ''' Create a new customer Returns a json representation of a customer. ''' form = CreateCustomerForm.from_json(request.get_json()) if not form.validate_on_submit(): return jsonify(errors=form.errors) customer = Customer(email=form.email.data, password=AdminCustomer._generate_password()) customer.data.cellphone = form.cellphone.data customer.data.first_name = form.first_name.data customer.data.last_name = form.last_name.data customer.data.newsletter = form.newsletter.data CustomerService.add_customer(customer) return jsonify(customer=customer.json)
def post(self): ''' Create a new customer Returns a json representation of a customer. ''' form = CreateCustomerForm.from_json(request.get_json()) if not form.validate_on_submit(): return jsonify(errors=form.errors) customer = Customer( email=form.email.data, password=AdminCustomer._generate_password() ) customer.data.cellphone = form.cellphone.data customer.data.first_name = form.first_name.data customer.data.last_name = form.last_name.data customer.data.newsletter = form.newsletter.data CustomerService.add_customer(customer) return jsonify(customer=customer.json)