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)
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)
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 )
def test_should_return_empty_list_given_invalid_search_term(self): customer = Customer.search_all("invalid search term") self.assertEqual(customer, [])
def test_should_return_list_of_customers_given_valid_rfc(self): customers = Customer.search_all(self.customer.rfc) self.assertEqual(customers, [self.customer])