2020-02-18 20:30:26 +00:00
|
|
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
2019-08-11 14:22:52 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2020-02-27 14:36:12 +00:00
|
|
|
|
2020-03-07 21:28:59 +00:00
|
|
|
|
2020-02-27 15:25:18 +00:00
|
|
|
def save_user_profile(instance, created, raw, **_kwargs):
|
2020-02-27 14:36:12 +00:00
|
|
|
"""
|
|
|
|
Hook to create and save a profile when an user is updated if it is not registered with the signup form
|
|
|
|
"""
|
|
|
|
if raw:
|
|
|
|
# When provisionning data, do not try to autocreate
|
|
|
|
return
|
|
|
|
|
2020-04-05 06:01:51 +00:00
|
|
|
if created and instance.is_active:
|
2020-02-27 14:36:12 +00:00
|
|
|
from .models import Profile
|
2020-02-27 15:26:07 +00:00
|
|
|
Profile.objects.get_or_create(user=instance)
|
2020-04-05 06:01:51 +00:00
|
|
|
instance.profile.save()
|