def _get_user_attempts(request):
 ip = get_ip(request)
 username = request.POST.get(USERNAME_FORM_FIELD, None)
 if USE_USER_AGENT:
  ua = request.META.get('HTTP_USER_AGENT', '<unknown>')[:255]
  attempts = AccessAttempt.objects.filter(user_agent=ua, ip_address=ip, username=username, trusted=True)
 else:
  attempts = AccessAttempt.objects.filter(ip_address=ip, username=username, trusted=True)
 if (not attempts):
  params = {'ip_address': ip, 'trusted': False}
  if USE_USER_AGENT:
   params['user_agent'] = ua
  if should_lock_out_by_combination_user_and_ip():
   params['username'] = username
  attempts = AccessAttempt.objects.filter(**params)
 return attempts

def _get_user_attempts ( request ) : ip = get_ip ( request ) username = request . POST . get ( USERNAME_FORM_FIELD , None ) if USE_USER_AGENT : ua = request . META . get ( 'HTTP_USER_AGENT' , '<unknown>' ) [ : 255 ] attempts = AccessAttempt . objects . filter ( user_agent = ua , ip_address = ip , username = username , trusted = True ) else : attempts = AccessAttempt . objects . filter ( ip_address = ip , username = username , trusted = True ) if ( not attempts ) : params = { 'ip_address' : ip , 'trusted' : False } if USE_USER_AGENT : params [ 'user_agent' ] = ua if should_lock_out_by_combination_user_and_ip ( ) : params [ 'username' ] = username attempts = AccessAttempt . objects . filter ( ** params ) return attempts
returns access attempt record if it exists .