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)
评论列表
文章目录