[Python-modules-commits] [python-django-ordered-model] 01/01: New upstream version 1.4.3

Michael Fladischer fladi at moszumanska.debian.org
Fri Sep 1 12:08:19 UTC 2017


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch upstream
in repository python-django-ordered-model.

commit c9d8160c5203ad5dcea9d3360959df78586e6dfb
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Fri Sep 1 13:35:39 2017 +0200

    New upstream version 1.4.3
---
 CHANGES.md                             | 12 ++++++++++++
 PKG-INFO                               |  3 +--
 README.md                              | 33 +++++++++++++++++----------------
 django_ordered_model.egg-info/PKG-INFO |  3 +--
 ordered_model/admin.py                 | 25 ++++++++++++++++++++-----
 ordered_model/models.py                |  4 +---
 ordered_model/tests/models.py          |  8 ++++----
 ordered_model/tests/urls.py            |  4 ++--
 requirements.txt                       |  1 -
 setup.cfg                              |  1 -
 setup.py                               |  2 +-
 11 files changed, 59 insertions(+), 37 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index b3db8f8..31f06e0 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,18 @@
 Change log
 ==========
 
+1.4.3 - 2017-08-29
+------------------
+
+- Fix a problem with links in the admin when using multiple threads.
+
+1.4.2 - 2017-08-18
+------------------
+
+- Use Django's version of `six`
+- Fix various deprecations
+- Fix missing up/down links with custom primary key
+
 1.4.1 - 2017-04-16
 ------------------
 
diff --git a/PKG-INFO b/PKG-INFO
index 5c1b45c..76851e3 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: django-ordered-model
-Version: 1.4.1
+Version: 1.4.3
 Summary: Allows Django models to be ordered and provides a simple admin interface for reordering them.
 Home-page: http://github.com/bfirsh/django-ordered-model
 Author: Ben Firshman
@@ -16,4 +16,3 @@ Classifier: Operating System :: OS Independent
 Classifier: Programming Language :: Python :: 2
 Classifier: Programming Language :: Python :: 3
 Requires: Django
-Requires: six
diff --git a/README.md b/README.md
index 43dc092..4cdda6c 100644
--- a/README.md
+++ b/README.md
@@ -134,7 +134,7 @@ A simple example might look like so:
 
 ```python
 class Contact(OrderedModel):
-    user = models.ForeignKey(User)
+    user = models.ForeignKey(User, on_delete=models.CASCADE)
     phone = models.CharField()
     order_with_respect_to = 'user'
 ```
@@ -162,8 +162,8 @@ class Pizza(models.Model):
     toppings = models.ManyToManyField(Topping, through='PizzaToppingsThroughModel')
 
 class PizzaToppingsThroughModel(OrderedModel):
-    pizza = models.ForeignKey(Pizza)
-    topping = models.ForeignKey(Topping)
+    pizza = models.ForeignKey(Pizza, on_delete=models.CASCADE)
+    topping = models.ForeignKey(Topping, on_delete=models.CASCADE)
     order_with_respect_to = 'pizza'
 
     class Meta:
@@ -172,21 +172,22 @@ class PizzaToppingsThroughModel(OrderedModel):
 
 When you want ordering on the baseclass instead of subclasses in an ordered list of objects of various classes, specify the full module path of the base class:
 
-    class BaseQuestion(OrderedModel):
-        order_class_path = __module__ '.BaseQuestion'
-        question = models.TextField(max_length=100)
-        class Meta:
-            ordering = ('order',)
-
-    class MultipleChoiceQuestion(BaseQuestion):
-        good_answer = models.TextField(max_length=100)
-        wrong_answer1 = models.TextField(max_length=100)
-        wrong_answer2 = models.TextField(max_length=100)
-        wrong_answer3 = models.TextField(max_length=100)
+```python
+class BaseQuestion(OrderedModel):
+    order_class_path = __module__ '.BaseQuestion'
+    question = models.TextField(max_length=100)
+    class Meta:
+        ordering = ('order',)
 
-    class OpenQuestion(BaseQuestion):
-        answer = models.TextField(max_length=100)
+class MultipleChoiceQuestion(BaseQuestion):
+    good_answer = models.TextField(max_length=100)
+    wrong_answer1 = models.TextField(max_length=100)
+    wrong_answer2 = models.TextField(max_length=100)
+    wrong_answer3 = models.TextField(max_length=100)
 
+class OpenQuestion(BaseQuestion):
+    answer = models.TextField(max_length=100)
+```
 
 
 
diff --git a/django_ordered_model.egg-info/PKG-INFO b/django_ordered_model.egg-info/PKG-INFO
index 5c1b45c..76851e3 100644
--- a/django_ordered_model.egg-info/PKG-INFO
+++ b/django_ordered_model.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: django-ordered-model
-Version: 1.4.1
+Version: 1.4.3
 Summary: Allows Django models to be ordered and provides a simple admin interface for reordering them.
 Home-page: http://github.com/bfirsh/django-ordered-model
 Author: Ben Firshman
@@ -16,4 +16,3 @@ Classifier: Operating System :: OS Independent
 Classifier: Programming Language :: Python :: 2
 Classifier: Programming Language :: Python :: 3
 Requires: Django
-Requires: six
diff --git a/ordered_model/admin.py b/ordered_model/admin.py
index b0a014e..cf01b7d 100644
--- a/ordered_model/admin.py
+++ b/ordered_model/admin.py
@@ -2,7 +2,6 @@ from functools import update_wrapper
 
 from django.conf.urls import url
 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.translation import ugettext_lazy as _
@@ -11,6 +10,12 @@ from django.contrib import admin
 from django.contrib.admin.utils import unquote
 from django.contrib.admin.views.main import ChangeList
 
+try:
+    from django.urls import reverse
+except ImportError:
+    # Django < 1.10
+    from django.core.urlresolvers import reverse
+from django.utils.encoding import (escape_uri_path, iri_to_uri)
 
 class OrderedModelAdmin(admin.ModelAdmin):
     def get_urls(self):
@@ -51,7 +56,12 @@ class OrderedModelAdmin(admin.ModelAdmin):
         obj = get_object_or_404(self.model, pk=unquote(object_id))
         obj.move(direction, qs)
 
-        return HttpResponseRedirect('../../{0!s}'.format(self.request_query_string))
+        # guts from request.get_full_path(), calculating ../../ and restoring GET arguments
+        mangled = '/'.join(escape_uri_path(request.path).split('/')[0:-3])
+        redir_path = '%s%s%s' % (mangled, '/' if not mangled.endswith('/') else '',
+            ('?' + iri_to_uri(request.META.get('QUERY_STRING', ''))) if request.META.get('QUERY_STRING', '') else '')
+
+        return HttpResponseRedirect(redir_path)
 
     def move_up_down_links(self, obj):
         model_info = self._get_model_info()
@@ -226,7 +236,12 @@ class OrderedTabularInline(admin.TabularInline):
         obj = get_object_or_404(cls.model, pk=unquote(object_id))
         obj.move(direction, qs)
 
-        return HttpResponseRedirect('../../../{0!s}'.format(cls.request_query_string))
+        # guts from request.get_full_path(), calculating ../../ and restoring GET arguments
+        mangled = '/'.join(escape_uri_path(request.path).split('/')[0:-4] + ['change'])
+        redir_path = '%s%s%s' % (mangled, '/' if not mangled.endswith('/') else '',
+            ('?' + iri_to_uri(request.META.get('QUERY_STRING', ''))) if request.META.get('QUERY_STRING', '') else '')
+
+        return HttpResponseRedirect(redir_path)
 
     @classmethod
     def get_preserved_filters(cls, request):
@@ -256,8 +271,8 @@ class OrderedTabularInline(admin.TabularInline):
         order_with_respect_to = obj._get_order_with_respect_to() or []
         parent_model = self.parent_model._meta
         fields = [
-            str(value.id) for field_name, value in order_with_respect_to
-            if value.__class__ is self.parent_model and value is not None and value.id is not None]
+            str(value.pk) for field_name, value in order_with_respect_to
+            if value.__class__ is self.parent_model and value is not None and value.pk is not None]
         order_obj_name = fields[0] if len(fields) > 0 else None
 
         if order_obj_name:
diff --git a/ordered_model/models.py b/ordered_model/models.py
index 096720b..b0c7482 100644
--- a/ordered_model/models.py
+++ b/ordered_model/models.py
@@ -1,10 +1,8 @@
 import warnings
-from django.contrib.contenttypes.models import ContentType
-from django.core.urlresolvers import reverse
 from django.db import models
 from django.db.models import Max, Min, F
 from django.utils.translation import ugettext as _
-import six
+from django.utils import six
 
 
 """
diff --git a/ordered_model/tests/models.py b/ordered_model/tests/models.py
index d008c9b..fe551b0 100644
--- a/ordered_model/tests/models.py
+++ b/ordered_model/tests/models.py
@@ -15,8 +15,8 @@ class TestUser(models.Model):
 
 
 class Answer(OrderedModel):
-    question = models.ForeignKey(Question, related_name='answers')
-    user = models.ForeignKey(TestUser, related_name='answers')
+    question = models.ForeignKey(Question, on_delete=models.CASCADE, related_name='answers')
+    user = models.ForeignKey(TestUser, on_delete=models.CASCADE, related_name='answers')
     order_with_respect_to = ('question', 'user')
 
     class Meta:
@@ -51,8 +51,8 @@ class Pizza(models.Model):
 
 
 class PizzaToppingsThroughModel(OrderedModel):
-    pizza = models.ForeignKey(Pizza)
-    topping = models.ForeignKey(Topping)
+    pizza = models.ForeignKey(Pizza, on_delete=models.CASCADE)
+    topping = models.ForeignKey(Topping, on_delete=models.CASCADE)
     order_with_respect_to = 'pizza'
 
     class Meta:
diff --git a/ordered_model/tests/urls.py b/ordered_model/tests/urls.py
index 7191b32..d69c573 100644
--- a/ordered_model/tests/urls.py
+++ b/ordered_model/tests/urls.py
@@ -1,8 +1,8 @@
-from django.conf.urls import include, url
+from django.conf.urls import url
 from django.contrib import admin
 
 admin.autodiscover()
 
 urlpatterns = [
-    url(r'^admin/', include(admin.site.urls)),
+    url(r'^admin/', admin.site.urls),
 ]
diff --git a/requirements.txt b/requirements.txt
index 1329207..94a0e83 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1 @@
 Django
-six
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..8bfd5a1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,4 @@
 [egg_info]
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0
 
diff --git a/setup.py b/setup.py
index b99e2a0..8e731b6 100644
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ with open('requirements.txt') as f:
 
 setup(
     name='django-ordered-model',
-    version='1.4.1',
+    version='1.4.3',
     description='Allows Django models to be ordered and provides a simple admin interface for reordering them.',
     author='Ben Firshman',
     author_email='ben at firshman.co.uk',

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django-ordered-model.git



More information about the Python-modules-commits mailing list