aboutsummaryrefslogtreecommitdiff
path: root/apps/accounts/signals.py
blob: 7c7f7c954e34fedf5150e3aff7649dabf43f5a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from django.db.models.signals import post_save
from django.dispatch import receiver

from .models import User, UserProfile
from notes.models import Notebook


@receiver(post_save, sender=User)
def create_profile(sender, update_fields, created, instance, **kwargs):
    """ creates a blank profile when a new user signs up """
    if created:
        user_profile = UserProfile.objects.create(user=instance)
        user_profile.save()
        user_trash_notebook = Notebook.objects.create(owner=instance, name="Trash")
        user_trash_notebook.save()