Пример #1
0
def edit_contact(contact_id):
    if request.method == "POST":
        # Populate the Data
        name_first = request.form["name_first"]
        name_last = request.form["name_last"]
        phone = request.form["phone"]
        email = request.form["email"]
        address = request.form["address"]

        contact = Contact.get_by_id(contact_id)

        # Update data and save
        contact.name_first = name_first
        contact.name_last = name_last
        contact.phone = phone
        contact.email = email
        contact.address = address
        contact.save_to_mongo()

        # Future: some sort of confirmation that this worked
        return redirect(url_for('contacts.details_contact', contact_id=contact_id))

    return render_template("contacts/edit_contact.html", contact=Contact.get_by_id(contact_id))
Пример #2
0
def details_contact(contact_id):
    return render_template("contacts/details.html", contact=Contact.get_by_id(contact_id))
Пример #3
0
def delete_contact(contact_id):
    contact = Contact.get_by_id(contact_id)
    if contact.user_email == session['email']:
        contact.remove_from_mongo()
    return redirect(url_for(".index"))