Ejemplo n.º 1
0
def customers():
    customers = Customer.get_all()
    if request.method == "POST":
        customers = Customer.search_all(request.form["search_term"])

    return render_template('customer/customers.html',
                           customer_heads=customer_heads,
                           customers=customers)
Ejemplo n.º 2
0
 def test_should_add_receipt_and_new_customer_given_valid_customer_data_and_LUHP(self):
     self.login_user(self.admin_user)
     customer_data = dict(
         customer_name="Valid New Name",
         address="Valid Address",
         phone="+123 456 7890"
     )
     prev_receipts = Receipt.get_all()
     with self.client as client:
         client.post(
             url_for('receipt.add'),
             data=customer_data
         )
     
     self.assertNotEqual(len(Receipt.get_all()), len(prev_receipts))
     self.assertEqual(len(Customer.search_all('Valid New Name')), 1)
Ejemplo n.º 3
0
def search_bar():
    search_term = request.form['search_term']
    try:
        customer = Customer.search_all(search_term)[0]
    except IndexError:
        customer = None
    if customer:
        return redirect(
            url_for("customer.update", id=customer.id)
        )
    user = User.search(search_term)
    if user:
        return redirect(
            url_for("user.profile", id=user.id)
        )
    product = Product.search(search_term)
    if product:
        return redirect(
            url_for("product.update", id=product.id)
        )

    return redirect(
        request.referrer
    )
Ejemplo n.º 4
0
    def test_should_return_empty_list_given_invalid_search_term(self):
        customer = Customer.search_all("invalid search term")

        self.assertEqual(customer, [])
Ejemplo n.º 5
0
    def test_should_return_list_of_customers_given_valid_rfc(self):
        customers = Customer.search_all(self.customer.rfc)

        self.assertEqual(customers, [self.customer])