Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. #Checks for remote friend status
  2.     if request.user.is_authenticated():
  3.         current_profile = Profile.objects.get(user_id = request.user.id)
  4.         follow_qs = Follow.objects.filter(from_profile_id=current_profile.id).filter(status='PENDING')
  5.  
  6.         for follow in follow_qs:
  7.             #check each follow to_profile to see if they are remote or local
  8.             to_profile_host = follow.to_profile_id.host
  9.  
  10.             host_port = to_profile_host.strip("http://").split(":")
  11.  
  12.             port = host_port[1]
  13.  
  14.             if port != "8000":
  15.                 host = Host.objects.filter( Q(host_url__icontains=port) ).first()
  16.                 friend_response = host.get_friend_response(str(current_profile.uuid), str(follow.to_profile_id.uuid))
  17.                 if friend_response['friends'].upper() == "YES" or friend_response['friends'] == True:
  18.                     current_profile.friends.add(follow.to_profile_id)
  19.                     current_profile.save()
  20.                    
  21.                     follow.delete()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement