本文整理汇总了Python中people.models.Person.add_or_update方法的典型用法代码示例。如果您正苦于以下问题:Python Person.add_or_update方法的具体用法?Python Person.add_or_update怎么用?Python Person.add_or_update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类people.models.Person
的用法示例。
在下文中一共展示了Person.add_or_update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_addorupdate_same
# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import add_or_update [as 别名]
def test_addorupdate_same(self):
""" Testing duplicate detection """
newone = copy.copy(self.people1)
newone.pk = None
newone.lastname = u"BARBIéR"
addupdres = Person.add_or_update(newone)
self.assertEqual(self.people1.pk, addupdres.pk)
示例2: getline
# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import add_or_update [as 别名]
def getline(self, row, fields):
person = Person(
lastname=self.getfield(fields, "nom", row),
firstname=self.getfield(fields, "prenom", row),
ptype="stu"
)
birthday = self.getfield(fields, "datenaissance", row)
if birthday != "":
person.birthday = birthday
person.normalize()
if "prenoms" in fields:
person.prenoms = self.getfield(fields, "prenoms", row)
if "uniquid" in fields:
person.uniquid = self.getfield(fields, "uniquid", row)
person = Person.add_or_update(person, self.importation.log.log)
print "Cleaning old groups"
self.cleanup_groups(Person)
print "Getting groups"
for fname in fields:
if fname not in KNOWN_FIELDS:
group = self.getfield(fields, fname, row)
if group == "":
continue
self.put_people_in_group(group, fname, person)
示例3: test_addorupdate_married
# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import add_or_update [as 别名]
def test_addorupdate_married(self):
""" Testing duplicate married detection """
newone = copy.copy(self.people1)
newone.pk = None
newone.birthname = newone.lastname
newone.lastname = u"MACHIN"
addupdres = Person.add_or_update(newone)
self.assertEqual(self.people1.pk, addupdres.pk)
示例4: form_valid
# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import add_or_update [as 别名]
def form_valid(self, form):
user = form.save(commit=False)
user.normalize()
self.object = Person.add_or_update(user)
return HttpResponseRedirect(self.get_success_url())