Skip to content
Snippets Groups Projects
Select Git revision
  • 02a6dc2a8cee302272ce42d3bd052c445c8e44f2
  • sansdocker default
  • master
3 results

request2.py

Blame
  • signals.py 573 B
    """Profile signals."""
    
    from django.db.models.signals import post_save
    from django.dispatch import receiver
    from .models import Tutor
    
    
    @receiver(post_save, sender=Tutor)
    def add_created_tutor_to_staff(sender, instance, created, **kwargs):
        """When creating a tutor profile, automatically assign it as staff.
    
        This way they will be able to connect in the administration site.
        Note that they will not have any permission so their view of the admin
        site will be empty.
        """
        if created:
            instance.user.is_staff = True
            instance.user.save()