本文整理汇总了Python中models.Contact.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.get_by_id方法的具体用法?Python Contact.get_by_id怎么用?Python Contact.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Contact
的用法示例。
在下文中一共展示了Contact.get_by_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_contact
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import get_by_id [as 别名]
def add_contact(data, instance_id=""):
if instance_id:
contact = Contact.get_by_id(int(instance_id))
else:
contact = Contact()
if data["name"]:
contact.name = data["name"]
if data["contacts"]:
if contact.contacts:
contact.contacts.append(data["contacts"])
else:
contact.contacts = data["contacts"]
if data["email"]:
contact.email = data["email"]
if data["facebook"]:
contact.facebook = data["facebook"]
if data["twitter"]:
contact.twitter = data["twitter"]
contact.put()
return contact
示例2: contact
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import get_by_id [as 别名]
def contact(contact_id):
if request.method == 'GET':
result = Contact.get_by_id (contact_id, parent=None)
json_results = []
d = {'id': result.key().id(),
'firstName': result.firstName,
'lastName': result.lastName,
'bday': result.bday,
'zodiac': result.zodiac}
json_results.append(d)
return jsonify(contacts=json_results)
示例3: render_template
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import get_by_id [as 别名]
listing = Listing.get_by_id(id)
return render_template('listing.html', listing=listing)
@login_required
<<<<<<< HEAD
def landlord_landlord(id=None):
'''Allows a user to landlord a landlord via email.'''
landlord = Landlord.get_by_id(id)
if landlord is None:
flash(u'You must select a landlord to landlord','error')
return redirect(url_for('all_listings'))
form = LandlordForm()
=======
def contact_landlord(id=None):
'''Allows a user to contact a landlord via email.'''
landlord = Contact.get_by_id(id)
if landlord is None:
flash(u'You must select a landlord to contact','error')
return redirect(url_for('all_listings'))
form = ContactForm()
>>>>>>> d76fc545aab7b1e1556c2efea62c18d4a20978f6
if form.validate_on_submit():
if send_email(form, landlord.email_address, landlord.name):
flash(u'Email sent!', 'success')
return redirect(url_for('all_listings'))
else:
flash(u'Sending failed', 'error')
return redirect(request.url)
else:
<<<<<<< HEAD