def show_customer(customer_id): if not is_logged_in(): return redirect(url_for('login')) if not is_valid_customer_id(customer_id): return redirect(url_for('show_customers')) customer = Customer.get(customer_id) calls = Call.get_for_customer(customer_id, True) return render_template('customer/show-one.html', customer=customer, calls=calls)
def show_customer(customer_id): '''Check for logged in user. Check for valid customer id. Get customer object that matches the given customer id. Get a list of calls that are associated with the given customer id. Render the 'customer/show-one.html' template with the above data.''' if not is_valid_customer_id(customer_id): #flash message saying no cust exists return redirect(url_for('show_customers')) if not is_logged_in(): #flash message saying log in return redirect(url_for('login')) customer = Customer.get(customer_id) calls = Call.get_for_customer(customer_id) return render_template('customer/show-one.html', customer=customer, calls=calls)
def show_customer(customer_id): '''Check for logged in user. Check for valid customer id. Get customer object that matches the given customer id. Get a list of calls that are associated with the given customer id. Render the 'customer/show-one.html' template with the above data.''' if check_for_logged_in() == True: customer = Customer.get(customer_id) auth = Auth() current_user = auth.get_current_user() user_id = current_user['user_id'] calls = Call.get_for_customer(customer_id, user_id) return render_template('customer/show-one.html', customer=customer, calls=calls) else: return redirect(url_for('login'))