def add_contact(): if request.form: contact = Contact(name=request.form.get('name'), phone=request.form.get('phone'), email=request.form.get('email')) contact.put() return render_template('add_contact.html')
def add_comtact(): if request.form: contact = Contact(name=request.form.get('name'), phone=request.form.get('phone'), email=request.form.get('email')) contact.put() flash('¡Se añadió el contacto!') return render_template('add_contact.html')
def add_contact(): if request.form: contact = Contact(name=request.form.get("name"), phone=request.form.get("phone"), email=request.form.get("email")) contact.put() flash("Se añadió el contacto!") return render_template("add_contact.html")
def add_fake_contact(name): print 'Make contact: ', name c = Contact() #c.user = User.objects.get(name='TestRobot') #c.name = name #c.address = 'Here' #c.phone = '900-555-1212' c.save() return c
def add_contact(): if request.form: contact = Contact(name=request.form.get('name'), phone=request.form.get('phone'), email=request.form.get('email')) contact.put() flash('Se ha agregado el contacto') return render_template('add_contact.html')
def add_contact(): if request.form: with client.context(): contact = Contact(name=request.form.get('name'), email=request.form.get('email'), phone=request.form.get('phone'), message=request.form.get('message')) contact.put() return render_template('contact.html')
def add_contact(): if request.form: with client.context(): contact = Contact(name=request.form.get('name'), phone=request.form.get('phone'), email=request.form.get('email')) contact.put() flash('Contact Add it!!') return render_template('add_contact.html')
def add_contact(): if request.form: contact = Contact(name=request.form.get('name'), phone=request.form.get('phone'), email=request.form.get('email')) contact.put() flash("Se añadió contacto: {}".format(request.form.get('name'))) return render_template('add_contact.html')
def add_contact(): if request.form: client = ndb.Client() with client.context(): contact = Contact(name=request.form.get('name'), phone=request.form.get('phone'), email=request.form.get('email')) contact.put() flash('¡Se añadió el contacto') return render_template('add_contact.html')
def add_contact(): try: if request.method == "POST": contact = Contact(name=request.form['name'], phone=request.form['phone'], email=request.form['email']) contact.put() flash('¡Se añadio el contacto!') return render_template('add_contact.html') except Exception as e: print('Error')
def prueba4(): import time global ahora ahora = time.strftime("%y/%m/%d %H:%M:%S") if request.form: identification = request.form.get('identification') name = request.form.get('name') gender = request.form.get('gender') age = request.form.get('age') company = request.form.get('company') currentdate = request.form.get('currentdate') test1 = request.form.get('test1') test2 = request.form.get('test2') test3 = request.form.get('test3') test4 = request.form.get('prueba_4') time = ahora client = ndb.Client() with client.context(): contact = Contact(identification=identification, name=name, gender=gender, age=age, company=company, currentdate=currentdate, test1=test1, test2=test2, test3=test3, test4=test4, time=time) contact.put() usuario = (identification, name, company, currentdate) p4 = int(test4) p3 = int(test3) p2 = int(test2) p1 = int(test1) final = p1 + p2 + p3 + p4 if final == 4: flash('POSITIVO PARA ANOSMIA') elif final == 3 or final == 2: flash('POSITIVO PARA HIPOSMIA') elif final == 1 or final == 0: flash('NEGATIVO') return render_template('final.html', usuario=usuario) return render_template('prueba_4.html')
def delete_contact(): client = ndb.Client() with client.context(): contact = Contact.get_by_id(int(request.form.get('uid'))) contact.key.delete() return redirect('/contacts/{}'.format(contact.key.id()))
def contact_details(uid): contact = Contact.get_by_id(int(uid)) if not contact: return redirect('/', code=301) return render_template('contact.html', contact=contact)
def contact_details(uid): contact = Contact.get_by_id(int( uid)) # Consulta el contacto según la key que tiene el mismo en BD. if not contact: return redirect('/', code=301) # 301: Redirección permanente. return render_template('contact.html', contact=contact)
def delete_contact(): contact = Contact.get_by_id(int(request.form.get('uid'))) contact.key.delete() return redirect('/contacts/{}'.format(contact.key.id()) if __name__ == '__main__': app.run()
def contact_details(uid): client = ndb.Client() with client.context(): contact = Contact.get_by_id(int(uid)) if not contact: return redirect('/', code=301) return render_template('contact.html', contact=contact)
def contact_book(): #show all contacts in the view contacts = [] for i in range(10): contacts.append( Contact("name{}".format(i), "phone{}".format(i), "email{}".format(i))) return render_template('contact_book.html', contacts=contacts)
def update_contact(uid): contact = Contact.get_by_id(int(uid)) if request.form: contact.name = request.form.get('name') contact.phone = request.form.get('phone') contact.email = request.form.get('email') contact.put() return redirect('/contacts/{}'.format(contact.key.id())) return render_template('update_contact.html', contact=contact)
def test_foreign_keys(): c = Contact( username='******', first_name='Anna', last_name='Zander') e1 = Email( address='*****@*****.**', contact=c) e2 = Email( address='*****@*****.**', contact=c) assert c.to_dict() == { 'username': '******', 'first_name': 'Anna', 'last_name': 'Zander', 'emails': ['*****@*****.**', '*****@*****.**']} assert e1.to_dict() == { 'address': '*****@*****.**', 'contact': 'anna'}
def update_contact(): contact = Contact.get_by_id(int(request.form.get('uid'))) if request.form: contact.name = request.form.get('name') contact.phone = request.form.get('phone') contact.email = request.form.get('email') contact.put() flash('¡Se actualizó el contacto!') return render_template('edit_contact.html', contact=contact)
def test_get(client): with mock.patch('contact_manager.session') as sm: sm.query.return_value = {'anna': Contact( username='******', first_name='Anna', last_name='Zander')} assert client.get('/api/get/contact/barry').status_code == 404 assert client.get('/api/get/contact/anna').status_code == 200 resp_data = client.get('/api/get/contact/anna').get_json() assert resp_data['first_name'] == 'Anna' assert resp_data['last_name'] == 'Zander'
def add_contact(): form = ContactForm(request.form) if request.method == 'POST' and form.validate(): #myContact = Contact(name=request.form.get('name'), # phone=request.form.get('phone'), # email=request.form.get('email')) myContact = Contact() form.populate_obj(myContact) db.session.add(myContact) try: db.session.commit() flash('Contacto creado satisfactoriamente', 'success') return redirect(url_for('contact_book')) except: db.session.rollback() flash('Error al generar contacto', 'danger') return render_template('add_contact.html')
def edit_contact(uid): contact = Contact.query.get(uid) form = ContactForm(request.form) if request.method == 'POST' and form.validate(): myContact = Contact() form.populate_obj(myContact) contact.name = myContact.name contact.phone = myContact.phone contact.email = myContact.email try: db.session.add(contact) db.session.commit() flash('Contacto actualizado satisfactoriamente', 'success') #return redirect(url_for('contact_book')) except: db.session.rollback() flash('Error al generar contacto', 'danger') return render_template('edit_contact.html', contact=contact)
def delete_contact(): contact = Contact.get_by_id(int(request.form.get('uid'))) contact.key.delete( ) # Elimina el contacto según la key que tiene el mismo en BD. return redirect('/contacts/{}'.format(contact.key.id()))
def contact_book(): contacts = Contact.query().fetch() return render_template('contact_book.html', contacts=contacts)
def delete_contact(): contact = Contact.get_by_id(int(request.form.get('uid'))) contact.key.delete() contacts = Contact.query().fetch() return redirect('/contacts/{}'.format(contact.key.id()))
def make_contact(req_json): return Contact(username=req_json['username'], first_name=req_json['first_name'], last_name=req_json['last_name'])
def hello_world(): with client.context(): contacts = Contact.query().fetch() return render_template('contact_book.html', contacts=contacts)
def contact_book(): # View Functions contacts = Contact.query().fetch() return render_template( 'contact_book.html', contacts=contacts ) # Los templates se deben definir en la carpeta 'templates'
def find_contact(): contact = Contact.get_by_id(int(request.form.get('uid'))) return render_template('edit_contact.html', contact=contact)