submissions.py 文件源码

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

项目:ecs 作者: ecs-org 项目源码 文件源码
def save(self, **kwargs):
        if not self.presenter_id:
            self.presenter = get_current_user()
        if not self.submission.is_transient:
            for x, org in (('submitter', 'submitter_organisation'), ('sponsor', 'sponsor_name')):
                email = getattr(self, '{0}_email'.format(x))
                if email:
                    try:
                        user = get_user(email)
                    except User.DoesNotExist:
                        user = create_phantom_user(email, role=x)
                        user.first_name = getattr(self, '{0}_contact_first_name'.format(x))
                        user.last_name = getattr(self, '{0}_contact_last_name'.format(x))
                        user.save()
                        profile = user.profile
                        profile.title = getattr(self, '{0}_contact_title'.format(x))
                        profile.gender = getattr(self, '{0}_contact_gender'.format(x)) or 'f'
                        profile.organisation = getattr(self, org)
                        profile.save()
                    setattr(self, x, user)
        return super().save(**kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号