Example #1
0
def add_call(customer_id):
    '''Check for logged in user. Check for valid customer id.
    Get customer object that matches the given customer id.
    Get the user_id of the currently logged-in user.
    Get the current date-time.
    Get the notes from the POST request.
    Use the above data to create a new Call object. Save it.
    Redirect to the /customers/<customer_id>/ page.'''
    if check_for_logged_in() == True:
        if check_for_valid_customer_id(customer_id) == True:
            customer_id = customer_id
            c = Customer.get(customer_id)

            auth = Auth()
            current_user = auth.get_current_user()
            user_id = current_user['user_id']

            current_dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            note = request.form.get('note')
            call_id = None

            new_call = Call(current_dt, note, call_id, customer_id, user_id)
            new_call.save()
            return redirect(url_for('show_customer', customer_id=customer_id))
        else:
            return redirect(url_for('show_customers'))
    else:
        return redirect(url_for('login'))
Example #2
0
def add_call():
    if not is_logged_in():
        return redirect(url_for('login'))

    customer_id = request.form.get('customer_id')
    if not is_valid_customer_id(customer_id):
        return redirect(url_for('show_customers'))

    customer = Customer.get(customer_id)
    user = Auth().get_current_user()
    user_id = user['user_id']

    date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    notes = request.form.get('notes', '')

    call = Call(customer_id, user_id, date, notes)
    call.save()
    flash('Call saved')
    return redirect(url_for('show_customer', customer_id=customer_id))
Example #3
0
def add_call(customer_id):
    '''Check for logged in user. Check for valid customer id.
    Get customer object that matches the given customer id.
    Get the user_id of the currently logged-in user.
    Get the current date-time.
    Get the notes from the POST request.
    Use the above data to create a new Call object. Save it.
    Redirect to the /customers/<customer_id>/ page.'''
    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'))
    auth = Auth()
    current_user = auth.get_current_user()
    current_user = current_user['user_id']
    call_message = request.form.get('call_message', None)
    call = Call(customer_id, current_user, call_message)
    call.save()
    return redirect(url_for('show_customer', customer_id=customer_id))