本文整理汇总了Python中models.Contact.get方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.get方法的具体用法?Python Contact.get怎么用?Python Contact.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Contact
的用法示例。
在下文中一共展示了Contact.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recipient_is
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import get [as 别名]
def recipient_is(name, TRAIN=0.9):
#: TRAIN = percent of the data to have in training set
train = {}
test = {}
person = Contact.get(name=name)
recipient = set(SMS.select().where(contact=person).where(from_me=False))
not_recipient = set(SMS.select().where(contact__ne=person).where(from_me=False))
train[person.name], test[person.name] = split_set(recipient, TRAIN)
train["not_" + person.name], test["not_" + person.name] = split_set(not_recipient, TRAIN)
return train, test
示例2: popup
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import get [as 别名]
def popup(self, pos):
row = self.selectionModel().selection().indexes()[0].row()
if (len(self.data) - 1) < row:
return False
self.contact = Contact.get(Contact.number == int(self.data[row][2]))
menu = QMenu()
menu.addAction(QIcon("{}transfer.png".format(Config.img_media)),
u"Faire un envoi", lambda: self.send_money(self.contact))
menu.addAction(QIcon("{}edit_contact.png".format(Config.img_media)),
u"modifier le contact", lambda: self.edit_contacts(self.contact))
addgroup = menu.addMenu(u"Ajouter au groupe")
delgroup = menu.addMenu(u"Enlever du groupe")
# # Enlever du groupe
no_select = ContactGroup.filter(contact__number=int(self.data[row][2]))
[delgroup.addAction(u"{}".format(grp_ct.group.name), lambda grp_ct=grp_ct: self.del_grp(
grp_ct)) for grp_ct in no_select]
# # Ajout au groupe
lt_grp_select = [(i.group.name) for i in no_select]
[addgroup.addAction(u"{}".format(grp.name), lambda grp=grp: self.add_grp(grp))
for grp in Group.select() if not grp.name in lt_grp_select]
self.action = menu.exec_(self.mapToGlobal(pos))
self.refresh()
示例3: addressbook_add_contact_to_group
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import get [as 别名]
def addressbook_add_contact_to_group(group_id, contact_id):
contact = Contact.get(id=int(contact_id))
group = Group.get(id=int(group_id))
data = {'contact': contact.to_dict(),
'group': group.to_dict()}
subst = {'contact': contact.display_name(),
'group': group.display_name()}
if ContactGroup.filter(contact=contact, group=group).count():
dict_return(data, INFO,
u"%(contact)s fait déjà parti du groupe %(group)s." % subst,
message_html=u"<strong>%(contact)s</strong> fait déjà "
u"parti du groupe "
u"<strong>%(group)s</strong>." % subst)
else:
cg = ContactGroup(contact=contact, group=group)
try:
cg.save()
dict_return(data, SUCCESS,
u"%(contact)s a été ajouté au groupe %(group)s." % subst,
message_html=u"<strong>%(contact)s</strong> a été "
u"ajouté au groupe "
u"<strong>%(group)s</strong>." % subst)
except Exception as e:
subst.update({'err': e.message})
dict_return(data, ERROR,
u"Impossible d'ajouter %(contact)s au groupe "
u"%(group)s: %(err)r" % subst,
message_html=u"Impossible d'ajouter "
u"<strong>%(contact)s</strong> au "
u"groupe <strong>%(group)s</strong>:<br />"
u"<em>%(err)r</em>" % subst)
return json.dumps(data)
示例4: addressbook_transfer
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import get [as 别名]
def addressbook_transfer(contact_id):
numbers = PhoneNumber.filter(contact=Contact.get(id=int(contact_id)))
data = {'transfers': [tr.to_dict() \
for tr in Transfer.filter(number__in=numbers)]}
return json.dumps(data)
示例5: addressbook_contact
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import get [as 别名]
def addressbook_contact(contact_id):
data = {'contact': Contact.get(id=int(contact_id)).to_dict(True)}
return json.dumps(data)