def update(id): customer = Customer.get(id) if request.method == "POST": update_obj_attrs(customer, customer_heads) error = customer.request.update() if not error: return redirect(url_for('customer.customers')) flash(error) return render_template('customer/update.html', customer_heads=customer_heads, customer=customer)
def receipts(id): selected_date_str = "" customer = Customer.get(id) receipts = customer.receipts if request.method == "POST": selected_date_str = request.form["selected_date"] selected_date = datetime.strptime(selected_date_str, "%Y-%m-%d") receipts = filter_receipts_by_date(receipts, selected_date) return render_template('customer/receipts.html', receipt_heads=receipt_heads, selected_date=selected_date_str, customer=customer, receipts=receipts)
def delete(id): customer = Customer.get(id) customer.delete() return redirect(url_for('customer.customers'))
def test_should_return_none_given_invalid_id(self): customer = Customer.get(2) self.assertEqual(customer, None)
def test_should_return_customer_given_valid_id(self): customer = Customer.get(self.customer.id) self.assertEqual(customer, self.customer)