Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Convert some strings to ints.

  • Loading branch information...
commit 15831364a59f0ad076a045d172938d3e38856d51 1 parent 2a6b6e6
@alex alex authored
Showing with 10 additions and 5 deletions.
  1. +6 −1 friends/managers.py
  2. +4 −4 friends/models.py
View
7 friends/managers.py
@@ -28,4 +28,9 @@ def remove(self, user1, user2):
class FriendshipInvitationManager(models.Manager):
def invitations(self, *args, **kwargs):
return self.filter(*args, **kwargs).exclude(status__in=["6", "8"])
-
+
+ def create_frienship_request(self, from_user, to_user, msg=None):
+ inv = self.create(from_usre=from_user, to_user=to_user,
+ message=msg or None, status=1)
+ # TODO: Send notifications here.
+ return inv
View
8 friends/models.py
@@ -65,7 +65,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})
@@ -79,7 +79,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()
@@ -101,8 +101,8 @@ def delete_friendship(sender, instance, **kwargs):
from_user=instance.from_user
)
for friendship_invitation in friendship_invitations:
- if friendship_invitation.status != "8":
- friendship_invitation.status = "8"
+ if friendship_invitation.status != 7:
+ friendship_invitation.status = 7
friendship_invitation.save()
Please sign in to comment.
Something went wrong with that request. Please try again.