Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify people when their contacts sign up #12

Open
patrys opened this issue Nov 6, 2009 · 0 comments
Open

Notify people when their contacts sign up #12

patrys opened this issue Nov 6, 2009 · 0 comments

Comments

@patrys
Copy link

patrys commented Nov 6, 2009

The patch follows. What is left is to create the notification template.

diff --git a/friends/management.py b/friends/management.py
index 387a69c..76e8241 100644
--- a/friends/management.py
+++ b/friends/management.py
@@ -7,6 +7,7 @@ if "notification" in settings.INSTALLED_APPS:
     from notification import models as notification
     
     def create_notice_types(app, created_models, verbosity, **kwargs):
+        notification.create_notice_type("contact_joined", _("Contact Joined"), _("one of your contacts has joined the site"), default=2)
         notification.create_notice_type("friends_invite", _("Invitation Received"), _("you have received an invitation"), default=2)
         notification.create_notice_type("friends_invite_sent", _("Invitation Sent"), _("you have sent an invitation"), default=1)
         notification.create_notice_type("friends_accept", _("Acceptance Received"), _("an invitation you sent has been accepted"), default=2)
diff --git a/friends/models.py b/friends/models.py
index 03afcd5..9ebcc9b 100644
--- a/friends/models.py
+++ b/friends/models.py
@@ -226,8 +226,10 @@ if EmailAddress:
                     join_invitation.save()
                     # notification will be covered below
             for contact in Contact.objects.filter(email=instance.email):
-                contact.users.add(instance.user)
-                # @@@ send notification
+                if not instance.user in contact.users.all():
+                    contact.users.add(instance.user)
+                    if notification:
+                        notification.send([contact.user], "contact_joined", {"new_user": instance.user})
     
     # only if django-email-notification is installed
     signals.post_save.connect(new_user, sender=EmailAddress)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant