Skip to content

Commit

Permalink
added field on Contact for which user(s) the contact correspond to if…
Browse files Browse the repository at this point in the history
… any

git-svn-id: http://django-friends.googlecode.com/svn/trunk@33 f9456ae0-1038-0410-abc2-2f1ed958ef3d
  • Loading branch information
jtauber committed Jun 18, 2008
1 parent 717f0cb commit 61021d9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions friendsdev/friends/models.py
Expand Up @@ -36,11 +36,15 @@ class Contact(models.Model):
"""

# the user who created the contact
user = models.ForeignKey(User)
user = models.ForeignKey(User, related_name="contacts")

name = models.CharField(max_length=100, null=True, blank=True)
email = models.EmailField()
added = models.DateField(default=datetime.date.today)

# the user(s) this contact correspond to
users = models.ManyToManyField(User)

def __unicode__(self):
return "%s (%s's contact)" % (self.email, self.user)

Expand Down Expand Up @@ -189,5 +193,8 @@ def new_user(sender, instance):
if join_invitation.status not in [5, 7]: # if not accepted or already marked as joined independently
join_invitation.status = 7
join_invitation.save()
# @@@ send notification
# notification will be covered below
for contact in Contact.objects.filter(email=instance.email):
contact.users.add(instance.user)
# @@@ send notification
dispatcher.connect(new_user, signal=signals.post_save, sender=EmailAddress)

0 comments on commit 61021d9

Please sign in to comment.