def get(self, their_usercode): self.init_session() if self.do_redirect(): return my_usercode = self.get_key('usercode') if my_usercode is None or their_usercode is None or len(their_usercode) == 0: self.restore_previous('Oops! Something went wrong there...') return their_userdata = UserData.get_by_code(their_usercode) if not Friend.already_present(my_usercode, their_usercode): self.restore_previous('You and %s are not friends.' % their_userdata.nickname) return FriendRequest.unmake_request(my_usercode, their_usercode) FriendRequest.unmake_request(their_usercode, my_usercode) Friend.unmake_friends(my_usercode, their_usercode) Friend.unmake_friends(their_usercode, my_usercode) self.restore_previous('You are no longer friends with %s' % their_userdata.nickname)