|
@@ -15,7 +15,10 @@ from django.core.validators import RegexValidator
|
|
from django.core.exceptions import ValidationError
|
|
from django.core.exceptions import ValidationError
|
|
from django.utils import timezone
|
|
from django.utils import timezone
|
|
from django.utils.text import slugify
|
|
from django.utils.text import slugify
|
|
|
|
+from django.core.mail import send_mail
|
|
|
|
+from django.core.urlresolvers import reverse
|
|
from ldapdb.models.fields import CharField, IntegerField, ListField
|
|
from ldapdb.models.fields import CharField, IntegerField, ListField
|
|
|
|
+from registration.signals import user_registered
|
|
|
|
|
|
from coin.offers.models import Offer, OfferSubscription
|
|
from coin.offers.models import Offer, OfferSubscription
|
|
from coin.mixins import CoinLdapSyncMixin
|
|
from coin.mixins import CoinLdapSyncMixin
|
|
@@ -59,6 +62,22 @@ class MemberManager(UserManager):
|
|
offers = Offer.objects.manageable_by(user)
|
|
offers = Offer.objects.manageable_by(user)
|
|
return super(MemberManager, self).filter(offersubscription__offer__in=offers).distinct()
|
|
return super(MemberManager, self).filter(offersubscription__offer__in=offers).distinct()
|
|
|
|
|
|
|
|
+@receiver(user_registered)
|
|
|
|
+def send_registration_notification(sender, user, request=None, **kwargs):
|
|
|
|
+ """
|
|
|
|
+ Send a notification to the admin if a user subscribe
|
|
|
|
+ """
|
|
|
|
+ relative_link = reverse('admin:members_member_change', args=[user.id])
|
|
|
|
+ abs_link = request.build_absolute_uri(relative_link)
|
|
|
|
+
|
|
|
|
+ send_mail('[COIN] Nouvelle inscription',
|
|
|
|
+ 'Bonjour,\n' +
|
|
|
|
+ '%s s\'est enregistré(e) sur COIN.\n' % user.username +
|
|
|
|
+ 'Lien d\'édition: %s' % abs_link,
|
|
|
|
+ settings.DEFAULT_FROM_EMAIL,
|
|
|
|
+ settings.NOTIFICATION_EMAILS,
|
|
|
|
+ fail_silently=False)
|
|
|
|
+
|
|
|
|
|
|
class Member(CoinLdapSyncMixin, AbstractUser):
|
|
class Member(CoinLdapSyncMixin, AbstractUser):
|
|
|
|
|