Commit c294ceb9 authored by Samuel GAIST's avatar Samuel GAIST

Merge branch '496_notification_for_supervision_requests' into 'master'

Activity stream notification for supervision requests

Closes #496

See merge request !334
parents f27f4b3a 11d6cd45
Pipeline #40511 passed with stages
in 15 minutes and 21 seconds
......@@ -35,13 +35,28 @@ from django.conf import settings
from rest_framework.authtoken.models import Token
from actstream import action
from .models import AccountSettings
import django.dispatch
supervision_request = django.dispatch.Signal()
@receiver(post_save, sender=User)
def setup_user(sender, instance, created, **kwargs):
if created and not instance.pk == settings.ANONYMOUS_USER_ID:
default_group, created = Group.objects.get_or_create(name='Default')
default_group, created = Group.objects.get_or_create(name="Default")
instance.groups.add(default_group)
Token.objects.create(user=instance)
AccountSettings.objects.create(owner=instance)
@receiver(supervision_request)
def on_supervision_request(sender, **kwargs):
action.send(
sender.supervisee,
verb="has requested supervision from",
target=sender.supervisor,
)
......@@ -44,6 +44,7 @@ from django.utils.translation import ugettext_lazy as _
from ...accounts.models import SupervisionTrack
from ...accounts.models import Profile
from ...accounts.models import TemporaryUrl
from ...accounts.signals import supervision_request
from ...utils import mail
SHA1_RE = re.compile("^[a-f0-9]{40}$")
......@@ -162,6 +163,8 @@ class RegistrationManager(models.Manager):
[supervisor_user.email],
)
supervision_request.send(supervisiontrack)
return user
return False
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment