models.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:balafon 作者: ljean 项目源码 文件源码
def save(self, *args, **kwargs):
        """save"""
        try:
            int(self.gender)
        except ValueError:
            self.gender = 0

        super(Contact, self).save(*args, **kwargs)
        if not self.uuid:
            ascii_name = unicodedata.normalize('NFKD', unicode(self.fullname)).encode("ascii", 'ignore')
            name = u'{0}-contact-{1}-{2}-{3}'.format(project_settings.SECRET_KEY, self.id, ascii_name, self.email)
            name = unicodedata.normalize('NFKD', unicode(name)).encode("ascii", 'ignore')
            self.uuid = unicode(uuid.uuid5(uuid.NAMESPACE_URL, name))
            return super(Contact, self).save()

        if self.entity.is_single_contact:
            #force the entity name for ordering
            self.entity.save()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号