1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-07-04 12:12:14 +02:00

Add a lot of comments

This commit is contained in:
Yohann D'ANELLO
2020-10-30 19:46:46 +01:00
parent 971169fe2c
commit 8236a9fe14
16 changed files with 491 additions and 7 deletions

View File

@ -5,10 +5,17 @@ from .models import AdminRegistration, Registration
def set_username(instance, **_):
"""
Ensure that the user username is always equal to the user email address.
"""
instance.username = instance.email
def send_email_link(instance, **_):
"""
If the email address got changed, send a new validation link
and update the registration status in the team mailing list.
"""
if instance.pk:
old_instance = User.objects.get(pk=instance.pk)
if old_instance.email != instance.email:
@ -25,5 +32,9 @@ def send_email_link(instance, **_):
def create_admin_registration(instance, **_):
"""
When a super user got created through console,
ensure that an admin registration is created.
"""
if instance.is_superuser:
AdminRegistration.objects.get_or_create(user=instance)