Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)