Browse Source

Merge branch 'whois_api'

pull/6/merge
Vitor Choi 8 years ago
parent
commit
673f3adff8
  1. 1
      requirements/requirements.txt
  2. 3
      sigi/apps/whois/views.py

1
requirements/requirements.txt

@ -20,3 +20,4 @@ reportlab==2.7
requests==2.8.1 requests==2.8.1
six==1.10.0 six==1.10.0
djangorestframework==2.4.8 djangorestframework==2.4.8
django-ipware==1.1.6

3
sigi/apps/whois/views.py

@ -6,6 +6,7 @@ from django.views.decorators.csrf import csrf_exempt
from rest_framework import status, permissions from rest_framework import status, permissions
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.decorators import api_view, permission_classes from rest_framework.decorators import api_view, permission_classes
from ipware.ip import get_ip
import re import re
from urlparse import urlparse from urlparse import urlparse
@ -20,7 +21,7 @@ class WhitelistPermission(permissions.BasePermission):
""" """
def has_permission(self, request, view): def has_permission(self, request, view):
ip_addr = request.META['REMOTE_ADDR'] ip_addr = get_ip(request)
if ip_addr in WHOIS_WHITELIST: if ip_addr in WHOIS_WHITELIST:
return True return True
else: else:

Loading…
Cancel
Save