Skip to content

Commit f0ab3b6

Browse files
author
Ross Mechanic
authored
Merge pull request #360 from treyhunner/remove-support-for-django-1.8
Removed Django 1.8 support
2 parents afae6df + 0483a5f commit f0ab3b6

File tree

12 files changed

+34
-77
lines changed

12 files changed

+34
-77
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ python:
99
- 3.6
1010

1111
env:
12-
- DJANGO="Django>=1.8,<1.9"
1312
- DJANGO="Django>=1.9,<1.10"
1413
- DJANGO="Django>=1.10,<1.11"
1514
- DJANGO="Django>=1.11,<1.12"

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changes
44
Unreleased
55
----------
66
- Fix bug where history_view ignored user permissions
7+
- Dropped support for Django<=1.8
78

89
1.9.1 (2018-03-30)
910
------------------

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ django-simple-history
2020

2121
django-simple-history stores Django model state on every create/update/delete.
2222

23-
This app requires Django 1.8 or greater and Python 2.7, or 3.4 or greater.
23+
This app requires Django 1.9 or greater and Python 2.7, or 3.4 or greater.
2424

2525
Getting Help
2626
------------

runtests.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import django
88
from django.conf import settings
9+
from django.test.runner import DiscoverRunner
910

1011
sys.path.insert(0, abspath(dirname(__file__)))
1112

@@ -59,17 +60,9 @@ def main():
5960

6061
if not settings.configured:
6162
settings.configure(**DEFAULT_SETTINGS)
62-
if hasattr(django, 'setup'):
63-
django.setup()
64-
try:
65-
from django.test.runner import DiscoverRunner
66-
except ImportError:
67-
from django.test.simple import DjangoTestSuiteRunner
68-
failures = DjangoTestSuiteRunner(failfast=False).run_tests(['tests'])
69-
failures |= DjangoTestSuiteRunner(failfast=False).run_tests(['registry_tests'])
70-
else:
71-
failures = DiscoverRunner(failfast=False).run_tests(['simple_history.tests'])
72-
failures |= DiscoverRunner(failfast=False).run_tests(['simple_history.registry_tests'])
63+
django.setup()
64+
failures = DiscoverRunner(failfast=False).run_tests(['simple_history.tests'])
65+
failures |= DiscoverRunner(failfast=False).run_tests(['simple_history.registry_tests'])
7366
sys.exit(failures)
7467

7568

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import simple_history
33

44
tests_require = [
5-
'Django>=1.8', 'WebTest==2.0.24', 'django-webtest==1.8.0', 'mock==1.0.1']
5+
'Django>=1.9', 'WebTest==2.0.24', 'django-webtest==1.8.0', 'mock==1.0.1']
66

77
setup(
88
name='django-simple-history',
@@ -25,7 +25,6 @@
2525
"Environment :: Web Environment",
2626
"Intended Audience :: Developers",
2727
"Framework :: Django",
28-
"Framework :: Django :: 1.8",
2928
"Framework :: Django :: 1.9",
3029
"Framework :: Django :: 1.10",
3130
"Framework :: Django :: 1.11",

simple_history/admin.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
from __future__ import unicode_literals
22

33
from django import http
4-
from django.core.exceptions import PermissionDenied
4+
from django.conf import settings
55
from django.conf.urls import url
66
from django.contrib import admin
77
from django.contrib.admin import helpers
8+
from django.contrib.admin.utils import unquote
89
from django.contrib.contenttypes.models import ContentType
10+
from django.core.exceptions import PermissionDenied
911
from django.core.urlresolvers import reverse
1012
from django.shortcuts import get_object_or_404, render
11-
from django.utils.text import capfirst
13+
from django.utils.encoding import force_text
1214
from django.utils.html import mark_safe
15+
from django.utils.text import capfirst
1316
from django.utils.translation import ugettext as _
14-
from django.utils.encoding import force_text
15-
from django.conf import settings
16-
from django.contrib.admin.utils import unquote
17-
18-
try:
19-
from django.utils.version import get_complete_version
20-
except ImportError:
21-
from django import VERSION
22-
get_complete_version = lambda: VERSION
2317

2418
USER_NATURAL_KEY = tuple(
2519
key.lower() for key in settings.AUTH_USER_MODEL.split('.', 1))
@@ -84,8 +78,6 @@ def history_view(self, request, object_id, extra_context=None):
8478
}
8579
context.update(extra_context or {})
8680
extra_kwargs = {}
87-
if get_complete_version() < (1, 8):
88-
extra_kwargs['current_app'] = request.current_app
8981
return render(request, self.object_history_template, context, **extra_kwargs)
9082

9183
def response_change(self, request, obj):
@@ -189,8 +181,6 @@ def history_form_view(self, request, object_id, version_id):
189181
'root_path': getattr(self.admin_site, 'root_path', None),
190182
}
191183
extra_kwargs = {}
192-
if get_complete_version() < (1, 8):
193-
extra_kwargs['current_app'] = request.current_app
194184
return render(request, self.object_history_form_template, context, **extra_kwargs)
195185

196186
def save_model(self, request, obj, form, change):

simple_history/management/commands/populate_history.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
from optparse import make_option
2-
3-
from django.core.management.base import BaseCommand, CommandError
41
from django.apps import apps
2+
from django.core.management.base import BaseCommand, CommandError
53

6-
get_model = apps.get_model
7-
8-
from ... import models
94
from . import _populate_utils as utils
5+
from ... import models
6+
7+
get_model = apps.get_model
108

119

1210
class Command(BaseCommand):
@@ -23,12 +21,6 @@ class Command(BaseCommand):
2321
EXISTING_HISTORY_FOUND = "Existing history found, skipping model"
2422
INVALID_MODEL_ARG = "An invalid model was specified"
2523

26-
if hasattr(BaseCommand, 'option_list'): # Django < 1.8
27-
option_list = BaseCommand.option_list + (
28-
make_option('--auto', action='store_true', dest='auto', default=False),
29-
make_option('--batchsize', action='store', dest='batchsize', default=200, type=int),
30-
)
31-
3224
def add_arguments(self, parser):
3325
super(Command, self).add_arguments(parser)
3426
parser.add_argument('models', nargs='*', type=str)

simple_history/manager.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def get_queryset(self):
3333
key_name = self.instance._meta.pk.name
3434
return self.get_super_queryset().filter(**{key_name: self.instance.pk})
3535

36-
get_query_set = get_queryset
37-
3836
def most_recent(self):
3937
"""
4038
Returns the most recent copy of the instance available in the history.

simple_history/tests/models.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
from __future__ import unicode_literals
22

3+
from django.apps import apps
34
from django.db import models
4-
from django import VERSION
55

6-
from simple_history.models import HistoricalRecords
76
from simple_history import register
8-
7+
from simple_history.models import HistoricalRecords
98
from .custom_user.models import CustomUser as User
10-
11-
from django.apps import apps
9+
from .external.models.model1 import AbstractExternal
1210

1311
get_model = apps.get_model
1412

15-
from .external.models.model1 import AbstractExternal
16-
1713

1814
class Poll(models.Model):
1915
question = models.CharField(max_length=200)
@@ -85,6 +81,7 @@ def verbose_str(self):
8581
extra_fields['__str__'] = verbose_str
8682
return extra_fields
8783

84+
8885
register(Voter, records_class=HistoricalRecordsVerbose)
8986

9087

simple_history/tests/tests/test_admin.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
from datetime import datetime, timedelta
22

3-
from mock import patch, ANY
4-
from django_webtest import WebTest
3+
from django.conf import settings
54
from django.contrib.admin import AdminSite
65
from django.contrib.admin.utils import quote
6+
from django.contrib.auth import get_user_model
77
from django.contrib.messages.storage.fallback import FallbackStorage
8-
from django.test.utils import override_settings
9-
from django.test.client import RequestFactory
108
from django.core.urlresolvers import reverse
11-
from django.conf import settings
12-
from django.contrib.auth import get_user_model
9+
from django.test.client import RequestFactory
10+
from django.test.utils import override_settings
1311
from django.utils.encoding import force_text
12+
from django_webtest import WebTest
13+
from mock import ANY, patch
1414

15+
from simple_history.admin import SimpleHistoryAdmin
1516
from simple_history.models import HistoricalRecords
16-
from simple_history.admin import SimpleHistoryAdmin, get_complete_version
17-
from ..models import Book, Person, Poll, State, Employee, Choice, ConcreteExternal
17+
from ..models import Book, Choice, ConcreteExternal, Employee, Person, Poll, State
1818

1919
User = get_user_model()
2020
today = datetime(2021, 1, 1, 10, 0)
2121
tomorrow = today + timedelta(days=1)
2222

23-
extra_kwargs = {}
24-
if get_complete_version() < (1, 8):
25-
extra_kwargs = {'current_app': 'admin'}
26-
2723

2824
def get_history_url(obj, history_index=None, site="admin"):
2925
app, model = obj._meta.app_label, obj._meta.model_name
@@ -442,7 +438,7 @@ def test_history_form_view_without_getting_history(self):
442438
'root_path': getattr(admin_site, 'root_path', None),
443439
}
444440
mock_render.assert_called_once_with(
445-
request, admin.object_history_form_template, context, **extra_kwargs)
441+
request, admin.object_history_form_template, context)
446442

447443
def test_history_form_view_getting_history(self):
448444
request = RequestFactory().post('/')
@@ -497,7 +493,7 @@ def test_history_form_view_getting_history(self):
497493
'root_path': getattr(admin_site, 'root_path', None),
498494
}
499495
mock_render.assert_called_once_with(
500-
request, admin.object_history_form_template, context, **extra_kwargs)
496+
request, admin.object_history_form_template, context)
501497

502498
def test_history_form_view_getting_history_with_setting_off(self):
503499
request = RequestFactory().post('/')
@@ -551,7 +547,7 @@ def test_history_form_view_getting_history_with_setting_off(self):
551547
'root_path': getattr(admin_site, 'root_path', None),
552548
}
553549
mock_render.assert_called_once_with(
554-
request, admin.object_history_form_template, context, **extra_kwargs)
550+
request, admin.object_history_form_template, context)
555551

556552
def test_history_form_view_getting_history_abstract_external(self):
557553
request = RequestFactory().post('/')
@@ -606,4 +602,4 @@ def test_history_form_view_getting_history_abstract_external(self):
606602
'root_path': getattr(admin_site, 'root_path', None),
607603
}
608604
mock_render.assert_called_once_with(
609-
request, admin.object_history_form_template, context, **extra_kwargs)
605+
request, admin.object_history_form_template, context)

0 commit comments

Comments
 (0)