本文整理汇总了Python中models.Contact.first_name方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.first_name方法的具体用法?Python Contact.first_name怎么用?Python Contact.first_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Contact
的用法示例。
在下文中一共展示了Contact.first_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_signal_processor
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import first_name [as 别名]
def test_signal_processor(self):
contact = Contact(
first_name='Igor_test',
last_name='Kucher_test',
birth_date='1990-01-10',
email='[email protected]',
jabber='[email protected]',
skype='skype_test',
other_contacts='other_test',
bio='bio_test'
)
contact.save()
contact_object_name = ContentType.objects.get_for_model(contact).model
log_entry = ModelsChangeLog.objects.latest()
self.assertEqual(log_entry.model, contact_object_name.title())
self.assertEqual(log_entry.action, ModelsChangeLog.CREATE)
self.assertEqual(log_entry.object_id, contact.pk)
contact.first_name = 'Igor_test_edit'
contact.save()
log_entry = ModelsChangeLog.objects.latest()
self.assertEqual(log_entry.model, contact_object_name.title())
self.assertEqual(log_entry.action, ModelsChangeLog.EDIT)
self.assertEqual(log_entry.object_id, contact.pk)
contact_pk = contact.pk
contact.delete()
log_entry = ModelsChangeLog.objects.latest('created')
self.assertEqual(log_entry.model, contact_object_name.title())
self.assertEqual(log_entry.action, ModelsChangeLog.DELETE)
self.assertEqual(log_entry.object_id, contact_pk)
示例2: addContact
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import first_name [as 别名]
def addContact():
form = AddContactForm()
customer_choices = [(a.id, a.name) for a in Customer.query.filter_by(customer_type=CUSTOMER_TYPES['TYPE_CUSTOMER']).all()]
customer_choices = [(0, '')] + customer_choices
form.customer.choices = customer_choices
if form.validate_on_submit():
contact = Contact()
contact.first_name = form.first_name.data
contact.surname = form.surname.data
contact.phone = form.phone.data
contact.email = form.email.data
if form.customer.data and form.customer.data != '' and form.customer.data != 0:
contact.customer_id = form.customer.data
else:
contact.customer_id = None
db.session.add(contact)
db.session.commit()
flash(gettext("New contact successfully added."))
return redirect(url_for("contacts"))
return render_template('settings/addContact.html',
title=gettext("Add New Contact"),
form=form)
示例3: get
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import first_name [as 别名]
def get(self, *args, **kwargs):
from models import Contact
if 'content_object' in kwargs:
content_object = kwargs['content_object']
del kwargs['content_object']
kwargs['content_type'] = ContentType.objects.get_for_model(type(content_object))
kwargs['object_id'] = content_object.pk
if content_object.__class__.__name__ == 'User':
try:
return super(ContactManager, self).get(*args, **kwargs)
except Exception:
c = Contact.objects.filter(email=content_object.email)[:1]
if c.count() > 0:
c[0].content_object = content_object
c[0].save()
return c[0]
c = Contact()
c.content_object =content_object
c.email = content_object.email
c.first_name = content_object.first_name
c.last_name = content_object.last_name
c.save()
return c
return super(ContactManager, self).get(*args, **kwargs)