Skip to content

Commit

Permalink
Upversion Django to the latest, Add deprecation warning for 1.0 to be…
Browse files Browse the repository at this point in the history
… removed in 3.0 (un33k#46)

* add deprecation warning, up version Django to latest, update travis.ci

* style fix

* drop 3.4 support for 2.1.3
  • Loading branch information
uneekvu authored and un33k committed Dec 1, 2018
1 parent a76d67c commit 90b4007
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 7 deletions.
14 changes: 8 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ python:
- "pypy3"

env:
- DJANGO="django==2.0.4"
- DJANGO="django==1.11.12"
- DJANGO="django==2.1.3"
- DJANGO="django==1.11.16"

install:
- pip install $DJANGO
Expand All @@ -27,10 +27,12 @@ before_script:

matrix:
exclude:
- python: "2.7"
env: DJANGO="django==2.0.4"
- python: "pypy"
env: DJANGO="django==2.0.4"
- python: "3.4"
env: DJANGO="django==2.1.3"
- python: "2.7"
env: DJANGO="django==2.1.3"
- python: "pypy"
env: DJANGO="django==2.1.3"

script: coverage run --source=ipware manage.py test

Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.linting.enabled": false
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.1.1

Enhancement:
- Added deprecation warnings preparing for version 3.0
- Update to latest Django

## 2.1.0

Enhancement:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,9 @@ X.Y.Z Version

[download-image]: https://img.shields.io/pypi/dm/django-ipware.svg
[download-link]: https://pypi.python.org/pypi/django-ipware


Sponsors
====================

[![Surge](https://www.surgeforward.com/wp-content/themes/understrap-master/images/logo.png)](https://github.com/surgeforward)
2 changes: 1 addition & 1 deletion ipware/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

__author__ = 'Val Neekman @ Neekware Inc. [@vneekman]'
__description__ = "A Django application to retrieve user's IP address"
__version__ = '2.1.0'
__version__ = '2.1.1'
7 changes: 7 additions & 0 deletions ipware/ip.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

from django.conf import settings

from .utils import is_valid_ip
Expand All @@ -6,13 +8,16 @@
NON_PUBLIC_IP_PREFIX = tuple([ip.lower() for ip in defs.IPWARE_NON_PUBLIC_IP_PREFIX])
TRUSTED_PROXY_LIST = tuple([ip.lower() for ip in getattr(settings, 'IPWARE_TRUSTED_PROXY_LIST', [])])

warnings.simplefilter('always', DeprecationWarning)


def get_ip(request, real_ip_only=False, right_most_proxy=False):
"""
Returns client's best-matched ip-address, or None
@deprecated - Do not edit
"""
best_matched_ip = None
warnings.warn('get_ip is deprecated and will be removed in 3.0.', DeprecationWarning)
for key in defs.IPWARE_META_PRECEDENCE_ORDER:
value = request.META.get(key, request.META.get(key.replace('_', '-'), '')).strip()
if value is not None and value != '':
Expand All @@ -37,6 +42,7 @@ def get_real_ip(request, right_most_proxy=False):
Returns client's best-matched `real` `externally-routable` ip-address, or None
@deprecated - Do not edit
"""
warnings.warn('get_real_ip is deprecated and will be removed in 3.0.', DeprecationWarning)
return get_ip(request, real_ip_only=True, right_most_proxy=right_most_proxy)


Expand All @@ -45,6 +51,7 @@ def get_trusted_ip(request, right_most_proxy=False, trusted_proxies=TRUSTED_PROX
Returns client's ip-address from `trusted` proxy server(s) or None
@deprecated - Do not edit
"""
warnings.warn('get_trusted_ip is deprecated and will be removed in 3.0.', DeprecationWarning)
if trusted_proxies:
meta_keys = ['HTTP_X_FORWARDED_FOR', 'X_FORWARDED_FOR']
for key in meta_keys:
Expand Down
2 changes: 2 additions & 0 deletions ipware/tests/tests_v1/tests_ipv4.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# -*- coding: utf-8 -*-

import warnings
from django.conf import settings
from django.http import HttpRequest
from django.test import TestCase
from ipware.ip import get_ip
from ipware.ip import get_real_ip
from ipware.ip import get_trusted_ip

warnings.simplefilter('ignore')

class IPv4TestCase(TestCase):
"""IP address Test"""
Expand Down
2 changes: 2 additions & 0 deletions ipware/tests/tests_v1/tests_ipv6.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

import warnings
from django.conf import settings
from django.http import HttpRequest
from django.test import TestCase
Expand All @@ -8,6 +9,7 @@
from ipware.ip import get_real_ip
from ipware.ip import get_trusted_ip

warnings.simplefilter('ignore')

class IPv6TestCase(TestCase):
"""IP address Test"""
Expand Down

0 comments on commit 90b4007

Please sign in to comment.