本文整理汇总了Python中models.Contact.phone方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.phone方法的具体用法?Python Contact.phone怎么用?Python Contact.phone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Contact
的用法示例。
在下文中一共展示了Contact.phone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addContact
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import phone [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)
示例2: import_csv
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import phone [as 别名]
def import_csv(self):
data = self._data()
contact_mgr = ContactManager(self.user.key)
index = data["file"].find('base64,') + 7
csv_string = data["file"][index:].decode('base64')
f = StringIO.StringIO(csv_string)
contacts = csv.DictReader(f)
for contact_data in contacts:
contact = Contact()
contact.name = contact_data['name']
contact.email = contact_data['email']
contact.phone = contact_data['phone']
contact_mgr.add_or_update_contact(contact)
return True
示例3: create
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import phone [as 别名]
def create(request):
list = []
success = True
message = ''
if not request.POST:
return
dataList = json.loads(request.POST.keys()[0])['data']
if type(dataList).__name__=='dict':
dataList = [dataList]
for data in dataList:
if existContact( data['name'] ):
# message = 'El registro ya existe'
data['_ptStatus'] = ERR_EXIST
list.append( data )
else:
contact = Contact()
contact.name = data['name']
contact.phone = data['phone']
contact.email = data['email']
if not contact.email.__contains__('@'):
contact.email += '@123.aa'
try:
contact.save()
data = model_to_dict(contact, fields=[field.name for field in contact._meta.fields])
list.append( data )
except:
data['_ptStatus'] = ERR_ADD
list.append( data )
# message = 'Error al crear registro'
context = {
'total': list.__len__(),
'data': list,
'success': success,
'message' : message
}
return HttpResponse(json.dumps(context), mimetype="application/json")
示例4: execute
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import phone [as 别名]
def execute(self):
contact = None
if self.unique_id:
contact = Contact.get_by_unique_id(self.unique_id)
else:
contact = Contact(
unique_id=guid()
)
contact.user = self.user
contact.name = self.name
contact.phone = self.phone
contact.email = self.email
contact.put()
return contact.unique_id
示例5: execute
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import phone [as 别名]
def execute(self):
invite_attendee = None
if self.invite_attendee_id:
invite_attendee = InviteAttendee.get_by_unique_id(self.invite_attendee_id)
else:
invite_attendee = InviteAttendee(
unique_id=guid()
)
invite_attendee.name = self.name
invite_attendee.email = self.email
invite_attendee.phone = self.phone
contact = None
if self.user and self.unique_id:
contact = Contact.get_by_unique_id(
self.unique_id
)
elif self.user:
contact = Contact(
unique_id=guid(),
user=self.user
)
# Here we update the contact with the appropiate Data
if contact:
invite_attendee.contact = contact.key
contact.name = self.name
contact.email = self.email
contact.phone = self.phone
contact.put()
invite = Invite.get_by_unique_id(self.invite_id)
invite_attendee.invite = invite.key
invite_attendee.put()
return invite_attendee.unique_id
示例6: import_contacts
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import phone [as 别名]
def import_contacts(self):
form = ContactImportForm()
if request.method == 'GET':
return self.render('contact_import.html', form=form)
else:
form = ContactImportForm()
if form.validate_on_submit():
data = form.filename.data.readlines()
imported = 0
for line in data:
line = line.split(',')
c = Contact()
c.phone = line[0]
c.name = line[1].decode('utf-8')
db.session.add(c)
imported += 1
db.session.commit()
flash(gettext('Imported %(num)s contacts.', num=imported))
return redirect(url_for('.index_view'))
else:
return self.render('contact_import.html', form=form)