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