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.save() if notification: notification.send([to_user], "friends_invite", {"invitation": invitation}) #self.user.message_set.create(message="Friendship requested with %s" % to_user.username) # @@@ make link like notification return invitation
def create_friend(fromc, toc): from_user = fromc.parents[0] to_user = toc.parents[0] friendship_inv = FriendshipInvitation(from_child=fromc, from_user=from_user, to_child=toc, to_user=to_user) friendship_inv.save() friendship_inv.accept()
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, ) invitation.save() return invitation
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.save() if notification: notification.send([to_user], "friends_invite", {"invitation": invitation}) notification.send([self.user], "friends_invite_sent", {"invitation": invitation}) self.user.message_set.create(message="Friendship requested with %s" % to_user.username) # @@@ make link like notification return invitation
def save(self): to_user = get_user_model().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, ) invitation.save() return invitation
def save(self): """ Overrides save so that we can use our custom clean method. """ 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, ) invitation.save() return invitation
def invite(from_user, to_user): if from_user == to_user: raise ValueError(_to_user(u"You can't request friendship with yourself.")) if Friendship.objects.are_friends(from_user, to_user): raise ValueError(_(u"You are already friends with %(username)s.") % {'username': to_user.username}) blocking = Blocking.objects.filter(from_user=to_user, to_user=from_user) if blocking.count() > 0: raise ValueError(_(u"You can't invite %(username)s to friends.") % {'username': to_user.username}) if FriendshipInvitation.objects.is_invited(from_user, to_user): raise ValueError(_(u"Already requested friendship with %(username)s.") % {'username': to_user.username}) invitation = FriendshipInvitation(from_user=from_user, to_user=to_user) invitation.save() return True
def create_friend(fromc, toc): from_user = fromc.parents[0] to_user = toc.parents[0] friendship_inv = FriendshipInvitation(from_child = fromc, from_user=from_user, to_child = toc, to_user=to_user) friendship_inv.save() friendship_inv.accept()