Пример #1
0
 def save(self,user):
     if self.cleaned_data["to_user"]:
         # existing user, send friend request
         return friends_InviteFriendForm.save(self)
     else:
         # no user, send invite
         return friends_JoinRequestForm.save(self,user)
Пример #2
0
 def clean(self):
     users=User.objects.filter(email=self.cleaned_data["email"])
     if users:
         self.cleaned_data["to_user"]=users[0].username
         # existing user, check for friend link
         return friends_InviteFriendForm.clean(self)
     else:
         # new user, check for pending invite
         return friends_JoinRequestForm.clean(self)