Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
def delete(id):
    customer = Customer.get(id)
    customer.delete()

    return redirect(url_for('customer.customers'))
Ejemplo n.º 4
0
    def test_should_return_none_given_invalid_id(self):
        customer = Customer.get(2)

        self.assertEqual(customer, None)
Ejemplo n.º 5
0
    def test_should_return_customer_given_valid_id(self):
        customer = Customer.get(self.customer.id)

        self.assertEqual(customer, self.customer)