Skip to content

Commit

Permalink
Remove support for unsupported Django versions (<1.8).
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Feb 9, 2016
1 parent 09463d4 commit fa96ab5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 46 deletions.
16 changes: 0 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
language: python
python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"

env:
- DJANGO="Django>=1.5,<1.6"
- DJANGO="Django>=1.6,<1.7"
- DJANGO="Django>=1.7,<1.8"
- DJANGO="Django>=1.8,<1.9"

matrix:
exclude:
- python: "2.6"
env: DJANGO="Django>=1.7,<1.8"
- python: "2.6"
env: DJANGO="Django>=1.8,<1.9"
- python: "3.5"
env: DJANGO="Django>=1.5,<1.6"
- python: "3.5"
env: DJANGO="Django>=1.6,<1.7"
- python: "3.5"
env: DJANGO="Django>=1.7,<1.8"
allow_failures:
- python: "3.2"

Expand All @@ -33,4 +18,3 @@ install: pip install $DJANGO

# command to run tests
script: script/test-command

4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change log
==========

1.2.0 – TBA

- Remove support for Django < 1.8.

1.1.0 – 2016-01-15
------------------

Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ https://djangosnippets.org/snippets/259/

Requires:

* Django >=1.5
* Python >=2.6 or >=3.3
* Django >=1.8
* Python 2.7 or >=3.3

Installation
------------
Expand Down Expand Up @@ -164,14 +164,13 @@ For a many-to-many relationship you need the following in the admin.py file:
for inline in self.inlines:
if hasattr(inline, 'get_urls'):
urls = inline.get_urls(self) + urls
return urls
return urls

admin.site.register(Pizza, PizzaAdmin)

Test suite
----------

Requires Docker.

$ script/test

26 changes: 4 additions & 22 deletions ordered_model/admin.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
from functools import update_wrapper

# from django.conf import settings
from django.core.paginator import Paginator
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
# from django.utils.html import strip_spaces_between_tags as short
from django.utils.translation import ugettext_lazy as _
from django.template.loader import render_to_string
from django.contrib import admin
try:
from django.contrib.admin.utils import unquote
except ImportError:
from django.contrib.admin.util import unquote
from django.contrib.admin.utils import unquote
from django.contrib.admin.views.main import ChangeList


Expand Down Expand Up @@ -52,11 +47,7 @@ def changelist_view(self, request, extra_context=None):
return super(OrderedModelAdmin, self).changelist_view(request, extra_context)

def move_view(self, request, object_id, direction):
cl = self._get_changelist(request)

# support get_query_set for backward compatibility
get_queryset = getattr(cl, 'get_queryset', None) or getattr(cl, 'get_query_set')
qs = get_queryset(request)
qs = self._get_changelist(request).get_queryset(request)

obj = get_object_or_404(self.model, pk=unquote(object_id))
obj.move(direction, qs)
Expand All @@ -79,14 +70,9 @@ def move_up_down_links(self, obj):
move_up_down_links.short_description = _(u'Move')

def _get_model_info(self):
# module_name was renamed to model_name in Django 1.7
if hasattr(self.model._meta, 'model_name'):
model = self.model._meta.model_name
else:
model = self.model._meta.module_name
return {
'app': self.model._meta.app_label,
'model': model
'model': self.model._meta.model_name,
}


Expand Down Expand Up @@ -236,10 +222,7 @@ def construct_search(field_name):

@classmethod
def move_view(cls, request, admin_id, object_id, direction):
cl = cls._get_changelist(request)
# support get_query_set for backward compatibility
get_queryset = getattr(cl, 'get_queryset', None) or getattr(cl, 'get_query_set')
qs = get_queryset(request)
qs = cls._get_changelist(request).get_queryset(request)

obj = get_object_or_404(cls.model, pk=unquote(object_id))
obj.move(direction, qs)
Expand Down Expand Up @@ -281,4 +264,3 @@ def move_up_down_links(self, obj):
return ''
move_up_down_links.allow_tags = True
move_up_down_links.short_description = _(u'Move')

3 changes: 0 additions & 3 deletions ordered_model/tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Django < 1.3
DATABASE_ENGINE = 'sqlite3'
# Django >= 1.3
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3'
Expand Down

0 comments on commit fa96ab5

Please sign in to comment.