Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Django 1.9 leftovers #363

Merged
merged 5 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Authors
- Marty Alchin
- Mauricio de Abreu Antunes
- Micah Denbraver
- Phillip Marshall
- Rajesh Pappula
- Roberto Aguilar
- Rod Xavier Bondoc
Expand Down
2 changes: 1 addition & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
'ENGINE': 'django.db.backends.sqlite3',
}
},
MIDDLEWARE_CLASSES=[
MIDDLEWARE=[
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
Expand Down
2 changes: 1 addition & 1 deletion simple_history/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from django.contrib.admin.utils import unquote
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from django.utils.encoding import force_text
from django.utils.html import mark_safe
from django.utils.text import capfirst
Expand Down
4 changes: 2 additions & 2 deletions simple_history/middleware.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.utils.deprecation import MiddlewareMixin as MiddlewareBase
from django.utils.deprecation import MiddlewareMixin

from .models import HistoricalRecords


class HistoryRequestMiddleware(MiddlewareBase):
class HistoryRequestMiddleware(MiddlewareMixin):
"""Expose request to HistoricalRecords.

This middleware sets request as a local thread variable, making it
Expand Down
6 changes: 3 additions & 3 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.contrib import admin
from django.db import models, router
from django.db.models.fields.proxy import OrderWrt
from django.urls import reverse
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible, smart_text
from django.utils.timezone import now
Expand Down Expand Up @@ -206,14 +207,13 @@ def get_extra_fields(self, model, fields):

user_model = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')

@models.permalink
def revert_url(self):
"""URL for this change in the default admin site."""
opts = model._meta
app_label, model_name = opts.app_label, opts.model_name
return ('%s:%s_%s_simple_history' %
return reverse('%s:%s_%s_simple_history' %
(admin.site.name, app_label, model_name),
[getattr(self, opts.pk.attname), self.history_id])
args=[getattr(self, opts.pk.attname), self.history_id])

def get_instance(self):
return model(**{
Expand Down
18 changes: 9 additions & 9 deletions simple_history/tests/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from django.contrib.admin.utils import quote
from django.contrib.auth import get_user_model
from django.contrib.messages.storage.fallback import FallbackStorage
from django.core.urlresolvers import reverse
from django.test.client import RequestFactory
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.encoding import force_text
from django_webtest import WebTest
from mock import ANY, patch
Expand Down Expand Up @@ -198,8 +198,8 @@ def test_history_user_not_saved(self):

def test_middleware_saves_user(self):
overridden_settings = {
'MIDDLEWARE_CLASSES':
settings.MIDDLEWARE_CLASSES +
'MIDDLEWARE':
settings.MIDDLEWARE +
['simple_history.middleware.HistoryRequestMiddleware'],
}
with override_settings(**overridden_settings):
Expand All @@ -216,8 +216,8 @@ def test_middleware_saves_user(self):

def test_middleware_unsets_request(self):
overridden_settings = {
'MIDDLEWARE_CLASSES':
settings.MIDDLEWARE_CLASSES +
'MIDDLEWARE':
settings.MIDDLEWARE +
['simple_history.middleware.HistoryRequestMiddleware'],
}
with override_settings(**overridden_settings):
Expand All @@ -231,8 +231,8 @@ def test_rolled_back_user_does_not_lead_to_foreign_key_error(self):
# creating a new entry does not fail with a foreign key error.

overridden_settings = {
'MIDDLEWARE_CLASSES':
settings.MIDDLEWARE_CLASSES +
'MIDDLEWARE':
settings.MIDDLEWARE +
['simple_history.middleware.HistoryRequestMiddleware'],
}
with override_settings(**overridden_settings):
Expand All @@ -253,8 +253,8 @@ def test_rolled_back_user_does_not_lead_to_foreign_key_error(self):

def test_middleware_anonymous_user(self):
overridden_settings = {
'MIDDLEWARE_CLASSES':
settings.MIDDLEWARE_CLASSES +
'MIDDLEWARE':
settings.MIDDLEWARE +
['simple_history.middleware.HistoryRequestMiddleware'],
}
with override_settings(**overridden_settings):
Expand Down