Upgrade django-ipware (#24827)

This commit is contained in:
M. Zulqarnain
2021-02-23 18:14:17 +05:00
committed by GitHub
parent 40ece9ea9b
commit 42fc6aef03
15 changed files with 29 additions and 49 deletions

View File

@@ -21,7 +21,7 @@ from django.utils.translation import get_language, to_locale
from django.utils.translation import ugettext as _
from django.views.generic.base import View
from edx_django_utils.monitoring.utils import increment
from ipware.ip import get_ip
from ipware.ip import get_client_ip
from opaque_keys.edx.keys import CourseKey
from six import text_type
@@ -90,7 +90,7 @@ class ChooseModeView(View):
embargo_redirect = embargo_api.redirect_if_blocked(
course_key,
user=request.user,
ip_address=get_ip(request),
ip_address=get_client_ip(request)[0],
url=request.path
)
if embargo_redirect:

View File

@@ -29,7 +29,7 @@ from edx_ace import ace
from edx_ace.recipient import Recipient
from edx_django_utils import monitoring as monitoring_utils
from eventtracking import tracker
from ipware.ip import get_ip
from ipware.ip import get_client_ip
# Note that this lives in LMS, so this dependency should be refactored.
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
@@ -340,7 +340,7 @@ def change_enrollment(request, check_access=True):
# or if the user is enrolling in a country in which the course
# is not available.
redirect_url = embargo_api.redirect_if_blocked(
course_id, user=user, ip_address=get_ip(request),
course_id, user=user, ip_address=get_client_ip(request)[0],
url=request.path
)
if redirect_url:

View File

@@ -16,7 +16,7 @@ import six
from django.conf import settings
from django.utils.deprecation import MiddlewareMixin
from eventtracking import tracker
from ipware.ip import get_ip
from ipware.ip import get_client_ip
from common.djangoapps.track import contexts, views
@@ -229,7 +229,7 @@ class TrackMiddleware(MiddlewareMixin):
def get_request_ip_address(self, request):
"""Gets the IP address of the request"""
ip_address = get_ip(request)
ip_address = get_client_ip(request)[0]
if ip_address is not None:
return ip_address
else:

View File

@@ -6,7 +6,7 @@ import six
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.http import HttpResponse
from eventtracking import tracker as eventtracker
from ipware.ip import get_ip
from ipware.ip import get_client_ip
from common.djangoapps.track import contexts, shim, tracker
@@ -22,7 +22,7 @@ def _get_request_header(request, header_name, default=''):
def _get_request_ip(request, default=''):
"""Helper method to get IP from a request's META dict, if present."""
if request is not None and hasattr(request, 'META'):
return get_ip(request)
return get_client_ip(request)[0]
else:
return default