Example #1
0
def add_contact():

    name = request.form['name']
    email = request.form['email_add']
    phone = request.form['phone']

    if not name or not email or not phone:
        var = "Please fill all the blanks"
        return render_template("add_contact.html", msg=var)

    else:
        check_email = Modules.check_email_exist(email)
        check_number = Modules.valid_number(phone)
        valid_email = Modules.valid_email(email)
        if check_email:
            var = "Email_address already exists"
            return render_template("add_contact.html", msg=var)
        elif (check_number == "False"):
            var = "Please make sure the contact has only numbers in it"
            return render_template("add_contact.html", msg=var)
        elif (valid_email.split("-")[0] == "name"):
            var = "Not a valid email address"
            return render_template("add_contact.html", msg=var)

        else:
            data = Modules.add_contact([name, email, phone])
            return redirect(url_for('home_page'))
Example #2
0
def home_page():

    global main_data

    full_data = Modules.get_whole_db()
    data = Modules.pages(full_data)
    main_data = data[2]
    pages = data[1]
    people = data[0]

    return render_template('contact_page.html', people=people, pages=pages)
Example #3
0
def result1():
    global search_data
    var1 = int(request.form['val1'])
    change_data = Modules.pagination(search_data, var1)
    data1 = change_data[0]
    pages = change_data[1]
    return render_template("search_results.html", people=data1, pages=pages)
Example #4
0
def edit_page():

    id_no = request.form['id']
    name = request.form['name']
    email = request.form['email_add']
    phone = request.form['phone']
    data = Modules.edit_contact([id_no, name, email, phone])

    return redirect(url_for('home_page'))
Example #5
0
def result2():

    global main_data

    var1 = int(request.form['val1'])
    change_data = Modules.pagination(main_data, var1)
    data1 = change_data[0]
    pages = change_data[1]
    return render_template("contact_page.html", people=data1, pages=pages)
Example #6
0
def result():

    global search_data

    search_text = request.form["search_val"]
    if not search_text:
        return redirect(url_for('home_page'))

    else:
        data = Modules.search_text(search_text)
        search_data = data[2]
        pages = data[1]
        people = data[0]

        return render_template("search_results.html",
                               people=people,
                               pages=pages)
Example #7
0
def edit_page_page():

    param = request.args.get('add')
    data = Modules.edit_contact_page(param)

    return render_template('edit_contact.html', people=data, val=data[0][0])
Example #8
0
def delete_page():
    email_add = request.form['val1']
    data = Modules.delete_contact(email_add)
    return redirect(url_for('home_page'))