Skip to content

Commit

Permalink
Fixed #386 - Change Invitation statuses that used integers to chars
Browse files Browse the repository at this point in the history
Signed-off-by: James Tauber <jtauber@jtauber.com>
  • Loading branch information
alibrahim authored and jtauber committed Aug 15, 2009
1 parent 523c739 commit 74ca61d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion friends/forms.py
Expand Up @@ -66,7 +66,7 @@ def clean(self):
def save(self):
to_user = User.objects.get(username=self.cleaned_data["to_user"])
message = self.cleaned_data["message"]
invitation = FriendshipInvitation(from_user=self.user, to_user=to_user, message=message, status=2)
invitation = FriendshipInvitation(from_user=self.user, to_user=to_user, message=message, status="2")
invitation.save()
if notification:
notification.send([to_user], "friends_invite", {"invitation": invitation})
Expand Down
18 changes: 9 additions & 9 deletions friends/models.py
Expand Up @@ -142,7 +142,7 @@ class JoinInvitation(models.Model):

def accept(self, new_user):
# mark invitation accepted
self.status = 5
self.status = "5"
self.save()
# auto-create friendship
friendship = Friendship(to_user=new_user, from_user=self.from_user)
Expand Down Expand Up @@ -172,7 +172,7 @@ def accept(self):
if not Friendship.objects.are_friends(self.to_user, self.from_user):
friendship = Friendship(to_user=self.to_user, from_user=self.from_user)
friendship.save()
self.status = 5
self.status = "5"
self.save()
if notification:
notification.send([self.from_user], "friends_accept", {"invitation": self})
Expand All @@ -183,7 +183,7 @@ def accept(self):

def decline(self):
if not Friendship.objects.are_friends(self.to_user, self.from_user):
self.status = 6
self.status = "6"
self.save()

class FriendshipInvitationHistory(models.Model):
Expand All @@ -201,8 +201,8 @@ class FriendshipInvitationHistory(models.Model):
def new_user(sender, instance, **kwargs):
if instance.verified:
for join_invitation in JoinInvitation.objects.filter(contact__email=instance.email):
if join_invitation.status not in [5, 7]: # if not accepted or already marked as joined independently
join_invitation.status = 7
if join_invitation.status not in ["5", "7"]: # if not accepted or already marked as joined independently
join_invitation.status = "7"
join_invitation.save()
# notification will be covered below
for contact in Contact.objects.filter(email=instance.email):
Expand All @@ -214,8 +214,8 @@ def new_user(sender, instance, **kwargs):
def new_user(sender, instance, **kwargs):
if instance.verified:
for join_invitation in JoinInvitation.objects.filter(contact__email=instance.email):
if join_invitation.status not in [5, 7]: # if not accepted or already marked as joined independently
join_invitation.status = 7
if join_invitation.status not in ["5", "7"]: # if not accepted or already marked as joined independently
join_invitation.status = "7"
join_invitation.save()
# notification will be covered below
for contact in Contact.objects.filter(email=instance.email):
Expand All @@ -228,8 +228,8 @@ def new_user(sender, instance, **kwargs):
def delete_friendship(sender, instance, **kwargs):
friendship_invitations = FriendshipInvitation.objects.filter(to_user=instance.to_user, from_user=instance.from_user)
for friendship_invitation in friendship_invitations:
if friendship_invitation.status != 8:
friendship_invitation.status = 8
if friendship_invitation.status != "8":
friendship_invitation.status = "8"
friendship_invitation.save()

signals.pre_delete.connect(delete_friendship, sender=Friendship)
Expand Down

0 comments on commit 74ca61d

Please sign in to comment.