nk20/apps/member/signals.py

16 lines
630 B
Python
Raw Normal View History

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