From 4d01ec19b55653cbef0d217d5ccf7d5276a8c730 Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Thu, 1 Dec 2016 21:52:11 -0500 Subject: [PATCH 01/49] Update README.md Added note about ordering field name. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1f5e775..3e55bbe 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ To add "sortability" to a model, you need to inherit `SortableMixin` and at mini - `BigIntegerField` - `Meta.ordering` **must only contain one value**, otherwise, your objects will not be sorted correctly. +- **IMPORTANT**: You must name the field you use for ordering something other than "order_field" as this name is reserved by the `SortableMixin` class. - It is recommended that you set `editable=False` and `db_index=True` on the field defined in `Meta.ordering` for a seamless Django admin experience and faster lookups on the objects. Sample Model: From b2ea957c4ab456c94b191c6b85d981ad4c93d1ed Mon Sep 17 00:00:00 2001 From: Benjamin Banduhn Date: Wed, 1 Feb 2017 10:48:39 +0100 Subject: [PATCH 02/49] add more notes in readme for different versions --- README.md | 28 ++++++++++++++++++++++++++++ README.rst | 29 ++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e55bbe..038e8d4 100644 --- a/README.md +++ b/README.md @@ -485,6 +485,34 @@ with: ``` +### Notes +From ``django-cms 3.x`` the path of change_form.html has changed. Replace the follwing line: + +```html + {% extends "admin/cms/page/plugin_change_form.html" %} +``` + +with + +```html + {% extends "admin/cms/page/plugin/change_form.html" %} +``` + +From ``django-admin-sortable 2.0.13`` the ``jquery.django-csrf.js`` was removed and you have to include the snippet-template. +Change the following line: + +```html + +``` + +to + +```html + {% include 'adminsortable/csrf/jquery.django-csrf.html' with csrf_cookie_name='csrftoken' %} +``` + +Please note, if you change the ``CSRF_COOKIE_NAME`` you have to adjust ``csrf_cookie_name='YOUR_CSRF_COOKIE_NAME'`` + ### Rationale Other projects have added drag-and-drop ordering to the ChangeList view, however this introduces a couple of problems... diff --git a/README.rst b/README.rst index 87ff9ee..d8bd45f 100644 --- a/README.rst +++ b/README.rst @@ -53,7 +53,7 @@ Download django-admin-sortable from `source `__ 1. Unzip the directory and cd into the uncompressed project directory -2. +2. - Optional: Enable your virtualenv @@ -597,6 +597,33 @@ with: +Notes +~~~~~ + +From ``django-cms 3.x`` the path of change_form.html has changed. Replace the follwing line: + +.. code:: html + {% extends "admin/cms/page/plugin_change_form.html" %} + +with + +.. code:: html + {% extends "admin/cms/page/plugin/change_form.html" %} + +From ``django-admin-sortable 2.0.13`` the ``jquery.django-csrf.js`` was removed and you have to include the snippet-template. +Change the following line: + +.. code:: html + + +to + +.. code:: html + + {% include 'adminsortable/csrf/jquery.django-csrf.html' with csrf_cookie_name='csrftoken' %} + +Please note, if you change the ``CSRF_COOKIE_NAME`` you have to adjust ``csrf_cookie_name='YOUR_CSRF_COOKIE_NAME'`` + Rationale ~~~~~~~~~ From 11ef0e51d8ed6df52b402a93087d11c3e27c77b8 Mon Sep 17 00:00:00 2001 From: David D Lowe Date: Tue, 7 Mar 2017 11:10:00 +0100 Subject: [PATCH 03/49] Add two PyPI badges --- README.md | 4 ++-- README.rst | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 038e8d4..486e5f1 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Django Admin Sortable +[![PyPI version](https://img.shields.io/pypi/v/django-admin-sortable.svg)](https://pypi.python.org/pypi/django-admin-sortable) +[![Python versions](https://img.shields.io/pypi/pyversions/django-admin-sortable.svg)](https://pypi.python.org/pypi/django-admin-sortable) [![Build Status](https://travis-ci.org/iambrandontaylor/django-admin-sortable.svg?branch=master)](https://travis-ci.org/iambrandontaylor/django-admin-sortable) -Current version: 2.0.21 - This project makes it easy to add drag-and-drop ordering to any model in Django admin. Inlines for a sortable model may also be made sortable, enabling individual items or groups of items to be sortable. diff --git a/README.rst b/README.rst index d8bd45f..eb6cdeb 100644 --- a/README.rst +++ b/README.rst @@ -1,10 +1,10 @@ Django Admin Sortable ===================== +|PyPI version| +|Python versions| |Build Status| -Current version: 2.0.21 - This project makes it easy to add drag-and-drop ordering to any model in Django admin. Inlines for a sortable model may also be made sortable, enabling individual items or groups of items to be sortable. @@ -664,5 +664,9 @@ License django-admin-sortable is released under the Apache Public License v2. +.. |PyPI version| image:: https://img.shields.io/pypi/v/django-admin-sortable.svg + :target: https://pypi.python.org/pypi/django-admin-sortable +.. |Python versions| image:: https://img.shields.io/pypi/pyversions/django-admin-sortable.svg + :target: https://pypi.python.org/pypi/django-admin-sortable .. |Build Status| image:: https://travis-ci.org/iambrandontaylor/django-admin-sortable.svg?branch=master :target: https://travis-ci.org/iambrandontaylor/django-admin-sortable From d0813e7a56ac28f85e63af26544c3796e48dd260 Mon Sep 17 00:00:00 2001 From: David D Lowe Date: Tue, 7 Mar 2017 13:51:43 +0100 Subject: [PATCH 04/49] Update instructions about context processor static --- README.md | 3 ++- README.rst | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 038e8d4..951241a 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,8 @@ Download django-admin-sortable from [source](https://github.com/iambrandontaylor ## Configuration 1. Add `adminsortable` to your `INSTALLED_APPS`. -2. Ensure `django.core.context_processors.static` is in your `TEMPLATE_CONTEXT_PROCESSORS`. +2. Ensure `django.template.context_processors.static` is in your `TEMPLATES["OPTIONS"]["context_processors"]`. + - (In older versions of Django, ensure `django.core.context_processors.static` is in `TEMPLATE_CONTEXT_PROCESSORS` instead.) 3. Ensure that `CSRF_COOKIE_HTTPONLY` has not been set to `True`, as django-admin-sortable is currently incompatible with that setting. diff --git a/README.rst b/README.rst index d8bd45f..3bde8dd 100644 --- a/README.rst +++ b/README.rst @@ -64,8 +64,12 @@ Configuration ------------- 1. Add ``adminsortable`` to your ``INSTALLED_APPS``. -2. Ensure ``django.core.context_processors.static`` is in your - ``TEMPLATE_CONTEXT_PROCESSORS``. +2. Ensure ``django.template.context_processors.static`` is in your + ``TEMPLATES["OPTIONS"]["context_processors"]``. + + - (In older versions of Django, ensure ``django.core.context_processors.static`` is in + ``TEMPLATE_CONTEXT_PROCESSORS`` instead.) + 3. Ensure that ``CSRF_COOKIE_HTTPONLY`` has not been set to ``True``, as django-admin-sortable is currently incompatible with that setting. From f2f5daf83133ff8c5d8f770b6acbfe21e2b3d555 Mon Sep 17 00:00:00 2001 From: Anton Shevchenko Date: Wed, 8 Mar 2017 22:14:48 -0500 Subject: [PATCH 05/49] Use 'update_fields' to limit the object's save() method to just the order field, so that other fields are not accidentally overwritten with stale data. --- adminsortable/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index f67505a..ee92501 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -298,7 +298,8 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): for index in indexes: obj = objects_dict.get(index) setattr(obj, order_field_name, start_index) - obj.save() + # only update the object's order field + obj.save(update_fields=(order_field_name,)) start_index += step response = {'objects_sorted': True} except (KeyError, IndexError, klass.DoesNotExist, From eb5a9e0a8a921df7cbe8c8e2d900101e5e5f20ef Mon Sep 17 00:00:00 2001 From: Anton Shevchenko Date: Wed, 8 Mar 2017 23:28:40 -0500 Subject: [PATCH 06/49] Avoid unnecessary db queries: perform the update iff the order field has changed. --- adminsortable/admin.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index ee92501..2991f5c 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -297,9 +297,11 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): for index in indexes: obj = objects_dict.get(index) - setattr(obj, order_field_name, start_index) - # only update the object's order field - obj.save(update_fields=(order_field_name,)) + # perform the update iff the order field has changed + if getattr(obj, order_field_name) != start_index: + setattr(obj, order_field_name, start_index) + # only update the object's order field + obj.save(update_fields=(order_field_name,)) start_index += step response = {'objects_sorted': True} except (KeyError, IndexError, klass.DoesNotExist, From eb5f14fe2272c841cad6557ef99c585dcad57bed Mon Sep 17 00:00:00 2001 From: Anton Shevchenko Date: Sat, 11 Mar 2017 11:20:16 -0500 Subject: [PATCH 07/49] Clarify comment. --- adminsortable/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index 2991f5c..ae24dd1 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -297,7 +297,7 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): for index in indexes: obj = objects_dict.get(index) - # perform the update iff the order field has changed + # perform the update only if the order field has changed if getattr(obj, order_field_name) != start_index: setattr(obj, order_field_name, start_index) # only update the object's order field From 9b51e835376a1e257d4948e90c6ecd2d54d0f30f Mon Sep 17 00:00:00 2001 From: Camilo Nova Date: Mon, 13 Mar 2017 11:57:38 -0500 Subject: [PATCH 08/49] Update to django 1.11 Fixes `TypeError, context must be a dict rather than RequestContext.` As seen in https://docs.djangoproject.com/en/1.11/ref/templates/upgrading/#django-template-loader --- adminsortable/templatetags/adminsortable_tags.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/adminsortable/templatetags/adminsortable_tags.py b/adminsortable/templatetags/adminsortable_tags.py index bbed9a0..174b8b1 100644 --- a/adminsortable/templatetags/adminsortable_tags.py +++ b/adminsortable/templatetags/adminsortable_tags.py @@ -1,5 +1,6 @@ -from django import template +from django.template.loader import render_to_string +from django import template register = template.Library() @@ -7,29 +8,25 @@ register = template.Library() def render_sortable_objects(context, objects, sortable_objects_template='adminsortable/shared/objects.html'): context.update({'objects': objects}) - tmpl = template.loader.get_template(sortable_objects_template) - return tmpl.render(context) + return render_to_string(sortable_objects_template, context.flatten()) @register.simple_tag(takes_context=True) def render_nested_sortable_objects(context, objects, group_expression, sortable_nested_objects_template='adminsortable/shared/nested_objects.html'): context.update({'objects': objects, 'group_expression': group_expression}) - tmpl = template.loader.get_template(sortable_nested_objects_template) - return tmpl.render(context) + return render_to_string(sortable_nested_objects_template, context.flatten()) @register.simple_tag(takes_context=True) def render_list_items(context, list_objects, sortable_list_items_template='adminsortable/shared/list_items.html'): context.update({'list_objects': list_objects}) - tmpl = template.loader.get_template(sortable_list_items_template) - return tmpl.render(context) + return render_to_string(sortable_list_items_template, context.flatten()) @register.simple_tag(takes_context=True) def render_object_rep(context, obj, forloop, sortable_object_rep_template='adminsortable/shared/object_rep.html'): context.update({'object': obj, 'forloop': forloop}) - tmpl = template.loader.get_template(sortable_object_rep_template) - return tmpl.render(context) + return render_to_string(sortable_object_rep_template, context.flatten()) From 1990e6653e62149be1a23e29a1194b9a01820cf1 Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Tue, 14 Mar 2017 22:04:23 -0400 Subject: [PATCH 09/49] [bt] Version 2.0.22 Release Notes Updated readme files with new version information and credits. Version bump to 2.0.22. --- README.md | 7 ++++--- README.rst | 42 ++++++++++++++++++++++++--------------- adminsortable/__init__.py | 2 +- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index a1b278a..0f93a2f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Sorting inlines: ## Supported Django Versions For Django 1.5.x to 1.9.x, use version 2.0.18. -For Django 1.10.x, use 2.0.19 or higher. +For Django 1.10.x or higher, use the latest version. ### Other notes of interest regarding versions django-admin-sortable 1.5.2 introduced backward-incompatible changes for Django 1.4.x @@ -530,8 +530,9 @@ ordering on top of that just seemed a little much in my opinion. ### Status django-admin-sortable is currently used in production. -### What's new in 2.0.21? -- Fixed a regression introduced by [ Pull Request 143](https://github.com/iambrandontaylor/django-admin-sortable/pull/143) which caused models sortable by a foriegn key to not persist the sort order correctly. +### What's new in 2.0.22? +- Improved saving [Pull Request 166](https://github.com/iambrandontaylor/django-admin-sortable/pull/166) thanks [@sushifan](https://github.com/sushifan) +- Django 1.11.x compatibility [Pull Request 167](https://github.com/iambrandontaylor/django-admin-sortable/pull/16) thanks [@camilonova](https://github.com/camilonova) ### Future - Better template support for foreign keys that are self referential. If someone would like to take on rendering recursive sortables, that would be super. diff --git a/README.rst b/README.rst index 995dbd9..de0aa7a 100644 --- a/README.rst +++ b/README.rst @@ -1,9 +1,7 @@ Django Admin Sortable ===================== -|PyPI version| -|Python versions| -|Build Status| +|PyPI version| |Python versions| |Build Status| This project makes it easy to add drag-and-drop ordering to any model in Django admin. Inlines for a sortable model may also be made sortable, @@ -28,7 +26,7 @@ Supported Django Versions For Django 1.5.x to 1.9.x, use version 2.0.18. -For Django 1.10.x, use 2.0.19 or higher. +For Django 1.10.x or higher, use the latest version. Other notes of interest regarding versions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -53,7 +51,7 @@ Download django-admin-sortable from `source `__ 1. Unzip the directory and cd into the uncompressed project directory -2. +2. - Optional: Enable your virtualenv @@ -67,8 +65,9 @@ Configuration 2. Ensure ``django.template.context_processors.static`` is in your ``TEMPLATES["OPTIONS"]["context_processors"]``. - - (In older versions of Django, ensure ``django.core.context_processors.static`` is in - ``TEMPLATE_CONTEXT_PROCESSORS`` instead.) + - (In older versions of Django, ensure + ``django.core.context_processors.static`` is in + ``TEMPLATE_CONTEXT_PROCESSORS`` instead.) 3. Ensure that ``CSRF_COOKIE_HTTPONLY`` has not been set to ``True``, as django-admin-sortable is currently incompatible with that setting. @@ -114,6 +113,9 @@ and at minimum, define: - ``Meta.ordering`` **must only contain one value**, otherwise, your objects will not be sorted correctly. +- **IMPORTANT**: You must name the field you use for ordering something + other than "order\_field" as this name is reserved by the + ``SortableMixin`` class. - It is recommended that you set ``editable=False`` and ``db_index=True`` on the field defined in ``Meta.ordering`` for a seamless Django admin experience and faster lookups on the objects. @@ -604,20 +606,25 @@ with: Notes ~~~~~ -From ``django-cms 3.x`` the path of change_form.html has changed. Replace the follwing line: +From ``django-cms 3.x`` the path of change\_form.html has changed. +Replace the follwing line: .. code:: html + {% extends "admin/cms/page/plugin_change_form.html" %} with .. code:: html + {% extends "admin/cms/page/plugin/change_form.html" %} -From ``django-admin-sortable 2.0.13`` the ``jquery.django-csrf.js`` was removed and you have to include the snippet-template. -Change the following line: +From ``django-admin-sortable 2.0.13`` the ``jquery.django-csrf.js`` was +removed and you have to include the snippet-template. Change the +following line: .. code:: html + to @@ -626,7 +633,8 @@ to {% include 'adminsortable/csrf/jquery.django-csrf.html' with csrf_cookie_name='csrftoken' %} -Please note, if you change the ``CSRF_COOKIE_NAME`` you have to adjust ``csrf_cookie_name='YOUR_CSRF_COOKIE_NAME'`` +Please note, if you change the ``CSRF_COOKIE_NAME`` you have to adjust +``csrf_cookie_name='YOUR_CSRF_COOKIE_NAME'`` Rationale ~~~~~~~~~ @@ -648,13 +656,15 @@ Status django-admin-sortable is currently used in production. -What's new in 2.0.21? +What's new in 2.0.22? ~~~~~~~~~~~~~~~~~~~~~ -- Fixed a regression introduced by `Pull Request - 143 `__ - which caused models sortable by a foriegn key to not persist the sort - order correctly. +- Improved saving `Pull Request + 166 `__ + thanks [@sushifan](https://github.com/sushifan) +- Django 1.11.x compatibility `Pull Request + 167 `__ + thanks [@camilonova](https://github.com/camilonova) Future ~~~~~~ diff --git a/adminsortable/__init__.py b/adminsortable/__init__.py index eda5d99..f3e0116 100644 --- a/adminsortable/__init__.py +++ b/adminsortable/__init__.py @@ -1,4 +1,4 @@ -VERSION = (2, 0, 21) +VERSION = (2, 0, 22) DEV_N = None From cc5fc81da94faadea7ae0d5e1a117d0a9fcceb1c Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 14:13:12 +0100 Subject: [PATCH 10/49] Add tox.ini to test and collect combined coverage data of multiple Python and Django versions --- tox.ini | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tox.ini diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..2f8f44f --- /dev/null +++ b/tox.ini @@ -0,0 +1,36 @@ +[tox] +envlist = django{1.8,1.9,1.10,1.11}-{py27,py34,py35},coverage + +[testenv] +deps = + coverage + django1.8: Django>=1.8,<1.9 + django1.9: Django>=1.9,<1.10 + django1.10: Django>=1.10,<1.11 + django1.11: Django>=1.11a1,<1.12 +whitelist_externals = cd +setenv = + PYTHONPATH = {toxinidir}/sample_project + PYTHONWARNINGS = module + PYTHONDONTWRITEBYTECODE = 1 +commands = + coverage run -p sample_project/manage.py test app + +[testenv:coverage] +deps = coverage +skip_install = true +commands = + coverage combine + coverage report + coverage html + +[coverage:run] +branch = True +parallel = True +source = + adminsortable + sample_project + +[coverage:report] +exclude_lines = + if __name__ == .__main__.: From e0a85c554b88c9cf2b7b45014bc9e85358bb5bb3 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 14:14:47 +0100 Subject: [PATCH 11/49] Remove django.conf.urls import fallback --- adminsortable/admin.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index ae24dd1..9bf089a 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -3,13 +3,7 @@ import json from django import VERSION from django.conf import settings - -try: - from django.conf.urls import url -except ImportError: - # Django < 1.4 - from django.conf.urls.defaults import url - +from django.conf.urls import url from django.contrib.admin import ModelAdmin, TabularInline, StackedInline from django.contrib.admin.options import InlineModelAdmin From 74e0c924558baa9f19d59b94cf89168cfc606085 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 14:22:27 +0100 Subject: [PATCH 12/49] Remove contenttypes.generic import fallbacks --- adminsortable/admin.py | 11 ++--------- sample_project/app/models.py | 8 +------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index 9bf089a..d233f58 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -6,15 +6,8 @@ from django.conf import settings from django.conf.urls import url from django.contrib.admin import ModelAdmin, TabularInline, StackedInline from django.contrib.admin.options import InlineModelAdmin - -try: - from django.contrib.contenttypes.admin import (GenericStackedInline, - GenericTabularInline) -except: - # Django < 1.7 - from django.contrib.contenttypes.generic import (GenericStackedInline, - GenericTabularInline) - +from django.contrib.contenttypes.admin import (GenericStackedInline, + GenericTabularInline) from django.contrib.contenttypes.models import ContentType from django.core.exceptions import PermissionDenied from django.http import HttpResponse, Http404 diff --git a/sample_project/app/models.py b/sample_project/app/models.py index 6f1186f..81e6606 100644 --- a/sample_project/app/models.py +++ b/sample_project/app/models.py @@ -1,10 +1,4 @@ -from django import VERSION - -if VERSION < (1, 9): - from django.contrib.contenttypes.generic import GenericForeignKey -else: - from django.contrib.contenttypes.fields import GenericForeignKey - +from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models from django.utils.encoding import python_2_unicode_compatible From f17db2293878832ac001654582d79aa96b339087 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 14:38:12 +0100 Subject: [PATCH 13/49] Remove inline admin fallback templates --- adminsortable/admin.py | 8 -- .../edit_inline/stacked-1.5.x.html | 92 ------------ .../edit_inline/tabular-1.5.x.html | 136 ------------------ 3 files changed, 236 deletions(-) delete mode 100644 adminsortable/templates/adminsortable/edit_inline/stacked-1.5.x.html delete mode 100644 adminsortable/templates/adminsortable/edit_inline/tabular-1.5.x.html diff --git a/adminsortable/admin.py b/adminsortable/admin.py index d233f58..7f55ba6 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -334,8 +334,6 @@ class SortableTabularInline(TabularInline, SortableInlineBase): """Custom template that enables sorting for tabular inlines""" if VERSION >= (1, 10): template = 'adminsortable/edit_inline/tabular-1.10.x.html' - elif VERSION < (1, 6): - template = 'adminsortable/edit_inline/tabular-1.5.x.html' else: template = 'adminsortable/edit_inline/tabular.html' @@ -344,8 +342,6 @@ class SortableStackedInline(StackedInline, SortableInlineBase): """Custom template that enables sorting for stacked inlines""" if VERSION >= (1, 10): template = 'adminsortable/edit_inline/stacked-1.10.x.html' - elif VERSION < (1, 6): - template = 'adminsortable/edit_inline/stacked-1.5.x.html' else: template = 'adminsortable/edit_inline/stacked.html' @@ -354,8 +350,6 @@ class SortableGenericTabularInline(GenericTabularInline, SortableInlineBase): """Custom template that enables sorting for tabular inlines""" if VERSION >= (1, 10): template = 'adminsortable/edit_inline/tabular-1.10.x.html' - elif VERSION < (1, 6): - template = 'adminsortable/edit_inline/tabular-1.5.x.html' else: template = 'adminsortable/edit_inline/tabular.html' @@ -364,7 +358,5 @@ class SortableGenericStackedInline(GenericStackedInline, SortableInlineBase): """Custom template that enables sorting for stacked inlines""" if VERSION >= (1, 10): template = 'adminsortable/edit_inline/stacked-1.10.x.html' - elif VERSION < (1, 6): - template = 'adminsortable/edit_inline/stacked-1.5.x.html' else: template = 'adminsortable/edit_inline/stacked.html' diff --git a/adminsortable/templates/adminsortable/edit_inline/stacked-1.5.x.html b/adminsortable/templates/adminsortable/edit_inline/stacked-1.5.x.html deleted file mode 100644 index c34182d..0000000 --- a/adminsortable/templates/adminsortable/edit_inline/stacked-1.5.x.html +++ /dev/null @@ -1,92 +0,0 @@ -{% load i18n admin_modify adminsortable_tags admin_urls %} -{% load static from staticfiles %} -
-

{{ inline_admin_formset.opts.verbose_name_plural|title }} {% if inline_admin_formset.formset.initial_form_count > 1 %} - {% trans "drag and drop to change order" %}{% endif %}

-{{ inline_admin_formset.formset.management_form }} -{{ inline_admin_formset.formset.non_form_errors }} - -{% for inline_admin_form in inline_admin_formset %}
-

- {% if inline_admin_form.original %} - {% with initial_forms_count=inline_admin_formset.formset.management_form.INITIAL_FORMS.value %} - - {% endwith %} - {% endif %} - {{ inline_admin_formset.opts.verbose_name|title }}: {% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %}#{{ forloop.counter }}{% endif %} - {% if inline_admin_form.show_url %}{% trans "View on site" %}{% endif %} - {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}{% endif %} -

- {% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %} - {% for fieldset in inline_admin_form %} - {% include "admin/includes/fieldset.html" %} - {% endfor %} - {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %} - {{ inline_admin_form.fk_field.field }} - {% if inline_admin_form.original %} - - {% endif %} -
{% endfor %} -
- - diff --git a/adminsortable/templates/adminsortable/edit_inline/tabular-1.5.x.html b/adminsortable/templates/adminsortable/edit_inline/tabular-1.5.x.html deleted file mode 100644 index bdc8348..0000000 --- a/adminsortable/templates/adminsortable/edit_inline/tabular-1.5.x.html +++ /dev/null @@ -1,136 +0,0 @@ -{% load i18n admin_modify adminsortable_tags admin_urls %} -{% load static from staticfiles %} -
- -
- - From ac507e448425fd5a8449d47a0063fb4403258de6 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 14:44:51 +0100 Subject: [PATCH 14/49] Remove get_queryset fallback --- adminsortable/admin.py | 23 +++-------------------- sample_project/app/admin.py | 8 ++++---- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index 7f55ba6..cd868b7 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -38,13 +38,7 @@ class SortableAdminBase(object): its sort order can be changed. This view adds a link to the object_tools block to take people to the view to change the sorting. """ - - try: - qs_method = getattr(self, 'get_queryset', self.queryset) - except AttributeError: - qs_method = self.get_queryset - - if get_is_sortable(qs_method(request)): + if get_is_sortable(self.get_queryset(request)): self.change_list_template = \ self.sortable_change_list_with_sort_link_template self.is_sortable = True @@ -137,11 +131,7 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): pass # Apply any sort filters to create a subset of sortable objects - try: - qs_method = getattr(self, 'get_queryset', self.queryset) - except AttributeError: - qs_method = self.get_queryset - objects = qs_method(request).filter(**filters) + objects = self.get_queryset(request).filter(**filters) # Determine if we need to regroup objects relative to a # foreign key specified on the model class that is extending Sortable. @@ -315,20 +305,13 @@ class SortableInlineBase(SortableAdminBase, InlineModelAdmin): ' (or Sortable for legacy implementations)') def get_queryset(self, request): - if VERSION < (1, 6): - qs = super(SortableInlineBase, self).queryset(request) - else: - qs = super(SortableInlineBase, self).get_queryset(request) - + qs = super(SortableInlineBase, self).get_queryset(request) if get_is_sortable(qs): self.model.is_sortable = True else: self.model.is_sortable = False return qs - if VERSION < (1, 6): - queryset = get_queryset - class SortableTabularInline(TabularInline, SortableInlineBase): """Custom template that enables sorting for tabular inlines""" diff --git a/sample_project/app/admin.py b/sample_project/app/admin.py index cba42f8..9da0c19 100644 --- a/sample_project/app/admin.py +++ b/sample_project/app/admin.py @@ -26,8 +26,8 @@ class ComponentInline(SortableStackedInline): # ) model = Component - def queryset(self, request): - qs = super(ComponentInline, self).queryset( + def get_queryset(self, request): + qs = super(ComponentInline, self).get_queryset( request).exclude(title__icontains='2') if get_is_sortable(qs): self.model.is_sortable = True @@ -37,14 +37,14 @@ class ComponentInline(SortableStackedInline): class WidgetAdmin(SortableAdmin): - def queryset(self, request): + def get_queryset(self, request): """ A simple example demonstrating that adminsortable works even in situations where you need to filter the queryset in admin. Here, we are just filtering out `widget` instances with an pk higher than 3 """ - qs = super(WidgetAdmin, self).queryset(request) + qs = super(WidgetAdmin, self).get_queryset(request) return qs.filter(id__lte=3) inlines = [ComponentInline] From 356d88dfde42b1da67297213e1250ef47dbb4690 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:09:17 +0100 Subject: [PATCH 15/49] Remove ordering field lookup fallback --- adminsortable/admin.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index cd868b7..4594467 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -183,9 +183,6 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): try: order_field_name = opts.model._meta.ordering[0] - except (AttributeError, IndexError): - # for Django 1.5.x - order_field_name = opts.ordering[0] except (AttributeError, IndexError): order_field_name = 'order' From 8b88dfa9cdd714264f7836e84d79951b70e22835 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:13:13 +0100 Subject: [PATCH 16/49] Remove pointless fallback code (it just repeats the previously failed statement) --- adminsortable/admin.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index 4594467..dd12f8c 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -82,12 +82,7 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): def get_urls(self): urls = super(SortableAdmin, self).get_urls() - opts = self.model._meta - try: - info = opts.app_label, opts.model_name - except AttributeError: - # Django < 1.7 - info = opts.app_label, opts.model_name + info = self.model._meta.app_label, self.model._meta.model_name # this ajax view changes the order of instances of the model type admin_do_sorting_url = url( From b0df1ff70123dd80138deb4bcbe1a7ba2647b87e Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:19:26 +0100 Subject: [PATCH 17/49] Remove south_field_triple method as South does not support Django >= 1.7 --- adminsortable/fields.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/adminsortable/fields.py b/adminsortable/fields.py index 380f555..3376f12 100644 --- a/adminsortable/fields.py +++ b/adminsortable/fields.py @@ -7,14 +7,4 @@ class SortableForeignKey(ForeignKey): This field replaces previous functionality where `sortable_by` was defined as a model property that specified another model class. """ - - def south_field_triple(self): - try: - from south.modelsinspector import introspector - cls_name = '{0}.{1}'.format( - self.__class__.__module__, - self.__class__.__name__) - args, kwargs = introspector(self) - return cls_name, args, kwargs - except ImportError: - pass + pass From 209a280ce8567502f6b1a3da7eea075c3d3122bf Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:25:21 +0100 Subject: [PATCH 18/49] Remove (seemingly broken) TemplateSyntaxError import fallback --- .../templatetags/django_template_additions.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/adminsortable/templatetags/django_template_additions.py b/adminsortable/templatetags/django_template_additions.py index c05f349..1866b68 100644 --- a/adminsortable/templatetags/django_template_additions.py +++ b/adminsortable/templatetags/django_template_additions.py @@ -2,11 +2,6 @@ from itertools import groupby import django from django import template -try: - from django import TemplateSyntaxError -except ImportError: - #support for django 1.3 - from django.template.base import TemplateSyntaxError register = template.Library() @@ -64,14 +59,15 @@ def dynamic_regroup(parser, token): """ firstbits = token.contents.split(None, 3) if len(firstbits) != 4: - raise TemplateSyntaxError("'regroup' tag takes five arguments") + raise template.TemplateSyntaxError("'regroup' tag takes five arguments") target = parser.compile_filter(firstbits[1]) if firstbits[2] != 'by': - raise TemplateSyntaxError("second argument to 'regroup' tag must be 'by'") + raise template.TemplateSyntaxError( + "second argument to 'regroup' tag must be 'by'") lastbits_reversed = firstbits[3][::-1].split(None, 2) if lastbits_reversed[1][::-1] != 'as': - raise TemplateSyntaxError("next-to-last argument to 'regroup' tag must" - " be 'as'") + raise template.TemplateSyntaxError( + "next-to-last argument to 'regroup' tag must be 'as'") expression = lastbits_reversed[2][::-1] var_name = lastbits_reversed[0][::-1] From 9997644929f15a875cdc7410ed5d70069357ec36 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:33:48 +0100 Subject: [PATCH 19/49] Run uuid field tests unconditional --- sample_project/app/tests.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sample_project/app/tests.py b/sample_project/app/tests.py index e573ebb..ab23c0f 100644 --- a/sample_project/app/tests.py +++ b/sample_project/app/tests.py @@ -3,12 +3,8 @@ try: except ImportError: import http.client as httplib -from django import VERSION - -if VERSION > (1, 8): - import uuid - import json +import uuid from django import VERSION from django.contrib.auth.models import User @@ -33,13 +29,12 @@ class TestSortableModel(SortableMixin): return self.title -if VERSION > (1, 8): - class TestNonAutoFieldModel(SortableMixin): - id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) - order = models.PositiveIntegerField(editable=False, db_index=True) +class TestNonAutoFieldModel(SortableMixin): + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) + order = models.PositiveIntegerField(editable=False, db_index=True) - class Meta: - ordering = ['order'] + class Meta: + ordering = ['order'] class SortableTestCase(TestCase): From 28fe5d14608c0b3bb2de813bc1d32c6610dd92e8 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:37:37 +0100 Subject: [PATCH 20/49] Run non auto field model test unconditional --- sample_project/app/tests.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sample_project/app/tests.py b/sample_project/app/tests.py index ab23c0f..b640a90 100644 --- a/sample_project/app/tests.py +++ b/sample_project/app/tests.py @@ -6,7 +6,6 @@ except ImportError: import json import uuid -from django import VERSION from django.contrib.auth.models import User from django.db import models from django.test import TestCase @@ -312,8 +311,5 @@ class SortableTestCase(TestCase): self.assertEqual(notes, expected_notes) def test_save_non_auto_field_model(self): - if VERSION > (1, 8): - model = TestNonAutoFieldModel() - model.save() - else: - pass + model = TestNonAutoFieldModel() + model.save() From 7262cb656415aea2d754de2a5346231bd62a4a7c Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:39:59 +0100 Subject: [PATCH 21/49] Remove unused utils module --- sample_project/sample_project/utils.py | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 sample_project/sample_project/utils.py diff --git a/sample_project/sample_project/utils.py b/sample_project/sample_project/utils.py deleted file mode 100644 index 4178ad9..0000000 --- a/sample_project/sample_project/utils.py +++ /dev/null @@ -1,6 +0,0 @@ -import os - - -def map_path(directory_name): - return os.path.join(os.path.dirname(__file__), - '../' + directory_name).replace('\\', '/') From 9d3c958365379dd4f1b3cc1b9470ac69b83cc615 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:43:17 +0100 Subject: [PATCH 22/49] Remove deprecated template settings --- sample_project/sample_project/settings.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/sample_project/sample_project/settings.py b/sample_project/sample_project/settings.py index ceb7009..9fabb27 100644 --- a/sample_project/sample_project/settings.py +++ b/sample_project/sample_project/settings.py @@ -8,7 +8,6 @@ def map_path(directory_name): DEBUG = True -TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), @@ -91,12 +90,6 @@ STATICFILES_FINDERS = ( # Make this unique, and don't share it with anybody. SECRET_KEY = '8**a!c8$1x)p@j2pj0yq!*v+dzp24g*$918ws#x@k+gf%0%rct' -# List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -) - MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', @@ -112,14 +105,12 @@ ROOT_URLCONF = 'sample_project.urls' # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = 'sample_project.wsgi.application' -TEMPLATE_DIRS = ( - map_path('templates'), -) - TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': TEMPLATE_DIRS, + 'DIRS': [ + map_path('templates') + ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ From b8bfbe0c9a414a30107fb86c2cd850319e7d1458 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:48:10 +0100 Subject: [PATCH 23/49] Explicitly set on_delete=models.CASCADE on ForeignKey as it will be required in Django 2.0 --- sample_project/app/models.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sample_project/app/models.py b/sample_project/app/models.py index 81e6606..4036064 100644 --- a/sample_project/app/models.py +++ b/sample_project/app/models.py @@ -45,7 +45,7 @@ class Project(SimpleModel, SortableMixin): class Meta: ordering = ['order'] - category = SortableForeignKey(Category) + category = SortableForeignKey(Category, on_delete=models.CASCADE) description = models.TextField() order = models.PositiveIntegerField(default=0, editable=False) @@ -57,7 +57,7 @@ class Credit(SortableMixin): class Meta: ordering = ['order'] - project = models.ForeignKey(Project) + project = models.ForeignKey(Project, on_delete=models.CASCADE) first_name = models.CharField(max_length=30, help_text="Given name") last_name = models.CharField(max_length=30, help_text="Family name") @@ -73,7 +73,7 @@ class Note(SortableMixin): class Meta: ordering = ['order'] - project = models.ForeignKey(Project) + project = models.ForeignKey(Project, on_delete=models.CASCADE) text = models.CharField(max_length=100) order = models.PositiveIntegerField(default=0, editable=False) @@ -85,7 +85,7 @@ class Note(SortableMixin): # Registered as a tabular inline on `Project` which can't be sorted @python_2_unicode_compatible class NonSortableCredit(models.Model): - project = models.ForeignKey(Project) + project = models.ForeignKey(Project, on_delete=models.CASCADE) first_name = models.CharField(max_length=30, help_text="Given name") last_name = models.CharField(max_length=30, help_text="Family name") @@ -96,7 +96,7 @@ class NonSortableCredit(models.Model): # Registered as a stacked inline on `Project` which can't be sorted @python_2_unicode_compatible class NonSortableNote(models.Model): - project = models.ForeignKey(Project) + project = models.ForeignKey(Project, on_delete=models.CASCADE) text = models.CharField(max_length=100) def __str__(self): @@ -106,7 +106,7 @@ class NonSortableNote(models.Model): # A generic bound model @python_2_unicode_compatible class GenericNote(SimpleModel, SortableMixin): - content_type = models.ForeignKey(ContentType, + content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, verbose_name=u"Content type", related_name="generic_notes") object_id = models.PositiveIntegerField(u"Content id") content_object = GenericForeignKey(ct_field='content_type', @@ -127,7 +127,7 @@ class Component(SimpleModel, SortableMixin): class Meta: ordering = ['order'] - widget = SortableForeignKey(Widget) + widget = SortableForeignKey(Widget, on_delete=models.CASCADE) order = models.PositiveIntegerField(default=0, editable=False) @@ -177,7 +177,8 @@ class SortableCategoryWidget(SimpleModel, SortableMixin): verbose_name = 'Sortable Category Widget' verbose_name_plural = 'Sortable Category Widgets' - non_sortable_category = SortableForeignKey(NonSortableCategory) + non_sortable_category = SortableForeignKey( + NonSortableCategory, on_delete=models.CASCADE) order = models.PositiveIntegerField(default=0, editable=False) @@ -191,7 +192,8 @@ class SortableNonInlineCategory(SimpleModel, SortableMixin): that is *not* sortable, and is also not defined as an inline of the SortableForeignKey field.""" - non_sortable_category = SortableForeignKey(NonSortableCategory) + non_sortable_category = SortableForeignKey( + NonSortableCategory, on_delete=models.CASCADE) order = models.PositiveIntegerField(default=0, editable=False) @@ -223,7 +225,7 @@ class CustomWidget(SortableMixin, SimpleModel): @python_2_unicode_compatible class CustomWidgetComponent(SortableMixin, SimpleModel): - custom_widget = models.ForeignKey(CustomWidget) + custom_widget = models.ForeignKey(CustomWidget, on_delete=models.CASCADE) # custom field for ordering widget_order = models.PositiveIntegerField(default=0, db_index=True, From defaf45e9a7729da94b63a85e3d9a0f290c7e21c Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:57:28 +0100 Subject: [PATCH 24/49] Make it clear why the httplib import is guarded by a try except and has a fallback --- sample_project/app/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sample_project/app/tests.py b/sample_project/app/tests.py index b640a90..87d74c1 100644 --- a/sample_project/app/tests.py +++ b/sample_project/app/tests.py @@ -1,7 +1,7 @@ try: - import httplib + import httplib # Python 2 except ImportError: - import http.client as httplib + import http.client as httplib # Python 3 import json import uuid From e5adadaefcd5d30a69d343f7404bb21410ae8414 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:58:01 +0100 Subject: [PATCH 25/49] Use the newer MIDDLEWARE setting but fall back to MIDDLEWARE_CLASSES on Django < 1.10 --- sample_project/sample_project/settings.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sample_project/sample_project/settings.py b/sample_project/sample_project/settings.py index 9fabb27..7327e75 100644 --- a/sample_project/sample_project/settings.py +++ b/sample_project/sample_project/settings.py @@ -1,6 +1,8 @@ # Django settings for test_project project. import os +import django + def map_path(directory_name): return os.path.join(os.path.dirname(__file__), @@ -90,15 +92,19 @@ STATICFILES_FINDERS = ( # Make this unique, and don't share it with anybody. SECRET_KEY = '8**a!c8$1x)p@j2pj0yq!*v+dzp24g*$918ws#x@k+gf%0%rct' -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = [ 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: 'django.middleware.clickjacking.XFrameOptionsMiddleware', -) +] + +if django.VERSION < (1, 10): + MIDDLEWARE_CLASSES = MIDDLEWARE ROOT_URLCONF = 'sample_project.urls' From a5eca5ea4dc9b17c73229c40daca363b8a89619b Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:58:20 +0100 Subject: [PATCH 26/49] assertEquals is deprecated in Python 3 --- sample_project/app/tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sample_project/app/tests.py b/sample_project/app/tests.py index 87d74c1..3dd3b7c 100644 --- a/sample_project/app/tests.py +++ b/sample_project/app/tests.py @@ -108,7 +108,7 @@ class SortableTestCase(TestCase): self.client.login(username=self.user.username, password=self.user_raw_password) response = self.client.get('/admin/app/category/sort/') - self.assertEquals(response.status_code, httplib.OK, + self.assertEqual(response.status_code, httplib.OK, 'Unable to reach sort view.') def make_test_categories(self): @@ -251,7 +251,7 @@ class SortableTestCase(TestCase): self.client.login(username=self.user.username, password=self.user_raw_password) response = self.client.get('/admin/app/project/sort/') - self.assertEquals(response.status_code, httplib.OK, + self.assertEqual(response.status_code, httplib.OK, 'Unable to reach sort view.') def test_adminsortable_change_list_view_permission_denied(self): @@ -261,8 +261,8 @@ class SortableTestCase(TestCase): self.client.login(username=self.staff.username, password=self.staff_raw_password) response = self.client.get('/admin/app/project/sort/') - self.assertEquals(response.status_code, httplib.FORBIDDEN, - 'Sort view must be forbidden.') + self.assertEqual(response.status_code, httplib.FORBIDDEN, + 'Sort view must be forbidden.') def test_adminsortable_inline_changelist_success(self): self.client.login(username=self.user.username, From aa9c4a60631cfe3994e2fa909b1e891dc8dbe260 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 16:03:43 +0100 Subject: [PATCH 27/49] User.is_authenticated is a property from Django 1.10 and onward --- sample_project/app/tests.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sample_project/app/tests.py b/sample_project/app/tests.py index 3dd3b7c..0278331 100644 --- a/sample_project/app/tests.py +++ b/sample_project/app/tests.py @@ -6,6 +6,8 @@ except ImportError: import json import uuid +import django + from django.contrib.auth.models import User from django.db import models from django.test import TestCase @@ -73,8 +75,12 @@ class SortableTestCase(TestCase): return category def test_new_user_is_authenticated(self): - self.assertEqual(self.user.is_authenticated(), True, - 'User is not authenticated') + if django.VERSION < (1, 10): + self.assertEqual(self.user.is_authenticated(), True, + 'User is not authenticated') + else: + self.assertEqual(self.user.is_authenticated, True, + 'User is not authenticated') def test_new_user_is_staff(self): self.assertEqual(self.user.is_staff, True, 'User is not staff') From de6a768cebf1af523e75544fdf2abadc1586c9cb Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 16:07:13 +0100 Subject: [PATCH 28/49] =?UTF-8?q?No=20need=20to=20use=20include=20for=20ad?= =?UTF-8?q?min.site.urls=20(it=E2=80=99s=20deprecated)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample_project/sample_project/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample_project/sample_project/urls.py b/sample_project/sample_project/urls.py index 5abb2fc..3e2dcfe 100644 --- a/sample_project/sample_project/urls.py +++ b/sample_project/sample_project/urls.py @@ -14,5 +14,5 @@ urlpatterns = [ url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: - url(r'^admin/', include(admin.site.urls)), + url(r'^admin/', admin.site.urls), ] From 49a7c41896b7fffc4f9c6d0be64614c96f49387a Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 16:13:34 +0100 Subject: [PATCH 29/49] Use remote_field.model in favor of rel.to when possible --- adminsortable/admin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index dd12f8c..539d2b1 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -141,7 +141,11 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): for field in self.model._meta.fields: if isinstance(field, SortableForeignKey): - sortable_by_fk = field.rel.to + try: + sortable_by_fk = field.remote_field.model + except AttributeError: + # Django < 1.9 + sortable_by_fk = field.rel.to sortable_by_field_name = field.name.lower() sortable_by_class_is_sortable = sortable_by_fk.objects.count() >= 2 From 9fa1fb13a50100e89748c549217789bcb73ddc2b Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Tue, 21 Mar 2017 06:10:58 -0400 Subject: [PATCH 30/49] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2f34301..7d075e0 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages try: - README = open('README').read() + README = open('README.rst').read() except: README = None From a9855808d02002ad0f3dbc183ab30b4462465164 Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Tue, 21 Mar 2017 06:42:24 -0400 Subject: [PATCH 31/49] [bt/master] Version bump to 2.1 --- README.md | 5 ++--- README.rst | 14 ++++++-------- adminsortable/__init__.py | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0f93a2f..26a7793 100644 --- a/README.md +++ b/README.md @@ -530,9 +530,8 @@ ordering on top of that just seemed a little much in my opinion. ### Status django-admin-sortable is currently used in production. -### What's new in 2.0.22? -- Improved saving [Pull Request 166](https://github.com/iambrandontaylor/django-admin-sortable/pull/166) thanks [@sushifan](https://github.com/sushifan) -- Django 1.11.x compatibility [Pull Request 167](https://github.com/iambrandontaylor/django-admin-sortable/pull/16) thanks [@camilonova](https://github.com/camilonova) +### What's new in 2.1? +- Removed fallbacks for Django 1.8, Tox testing and many performance improvements [Pull Request 168](https://github.com/iambrandontaylor/django-admin-sortable/pull/168) thanks [@sushifan](https://github.com/jaap3) ### Future - Better template support for foreign keys that are self referential. If someone would like to take on rendering recursive sortables, that would be super. diff --git a/README.rst b/README.rst index de0aa7a..44844f6 100644 --- a/README.rst +++ b/README.rst @@ -656,15 +656,13 @@ Status django-admin-sortable is currently used in production. -What's new in 2.0.22? -~~~~~~~~~~~~~~~~~~~~~ +What's new in 2.1? +~~~~~~~~~~~~~~~~~~ -- Improved saving `Pull Request - 166 `__ - thanks [@sushifan](https://github.com/sushifan) -- Django 1.11.x compatibility `Pull Request - 167 `__ - thanks [@camilonova](https://github.com/camilonova) +- Removed fallbacks for Django 1.8, Tox testing and many performance + improvements `Pull Request + 168 `__ + thanks [@sushifan](https://github.com/jaap3) Future ~~~~~~ diff --git a/adminsortable/__init__.py b/adminsortable/__init__.py index f3e0116..5b42c1f 100644 --- a/adminsortable/__init__.py +++ b/adminsortable/__init__.py @@ -1,4 +1,4 @@ -VERSION = (2, 0, 22) +VERSION = (2, 1, 0) DEV_N = None From 171257c9c5ba5ea515a4f80cd0014552894ddafa Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Tue, 21 Mar 2017 06:44:26 -0400 Subject: [PATCH 32/49] [bt/master] Updated information on version compatibility --- README.md | 4 ++-- README.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 26a7793..ccfe141 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ Sorting inlines: ![sortable-inlines](http://res.cloudinary.com/alsoicode/image/upload/v1451237555/django-admin-sortable/sortable-inlines.jpg) ## Supported Django Versions -For Django 1.5.x to 1.9.x, use version 2.0.18. +For Django 1.5.x to 1.7.x, use version 2.0.18. -For Django 1.10.x or higher, use the latest version. +For Django 1.8.x or higher, use the latest version. ### Other notes of interest regarding versions django-admin-sortable 1.5.2 introduced backward-incompatible changes for Django 1.4.x diff --git a/README.rst b/README.rst index 44844f6..be69a9b 100644 --- a/README.rst +++ b/README.rst @@ -24,9 +24,9 @@ Sorting inlines: Supported Django Versions ------------------------- -For Django 1.5.x to 1.9.x, use version 2.0.18. +For Django 1.5.x to 1.7.x, use version 2.0.18. -For Django 1.10.x or higher, use the latest version. +For Django 1.8.x or higher, use the latest version. Other notes of interest regarding versions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 115aad641dc633a2de6e94d02f355abbb7403898 Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Tue, 21 Mar 2017 15:09:33 -0400 Subject: [PATCH 33/49] Update README.md Updated Travis urls --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ccfe141..3642d8b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![PyPI version](https://img.shields.io/pypi/v/django-admin-sortable.svg)](https://pypi.python.org/pypi/django-admin-sortable) [![Python versions](https://img.shields.io/pypi/pyversions/django-admin-sortable.svg)](https://pypi.python.org/pypi/django-admin-sortable) -[![Build Status](https://travis-ci.org/iambrandontaylor/django-admin-sortable.svg?branch=master)](https://travis-ci.org/iambrandontaylor/django-admin-sortable) +[![Build Status](https://travis-ci.org/alsoicode/django-admin-sortable.svg?branch=master)](https://travis-ci.org/alsoicode/django-admin-sortable) This project makes it easy to add drag-and-drop ordering to any model in Django admin. Inlines for a sortable model may also be made sortable, From bb70d5a3adc0c450802017e82dc6b6eb8c53c125 Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Wed, 11 Oct 2017 07:15:42 -0400 Subject: [PATCH 34/49] Added jQuery UI Touch Support --- .../adminsortable/js/jquery.ui.touch-punch.min.js | 11 +++++++++++ .../templates/adminsortable/change_form.html | 1 + .../templates/adminsortable/change_list.html | 1 + 3 files changed, 13 insertions(+) create mode 100644 adminsortable/static/adminsortable/js/jquery.ui.touch-punch.min.js diff --git a/adminsortable/static/adminsortable/js/jquery.ui.touch-punch.min.js b/adminsortable/static/adminsortable/js/jquery.ui.touch-punch.min.js new file mode 100644 index 0000000..31272ce --- /dev/null +++ b/adminsortable/static/adminsortable/js/jquery.ui.touch-punch.min.js @@ -0,0 +1,11 @@ +/*! + * jQuery UI Touch Punch 0.2.3 + * + * Copyright 2011–2014, Dave Furfero + * Dual licensed under the MIT or GPL Version 2 licenses. + * + * Depends: + * jquery.ui.widget.js + * jquery.ui.mouse.js + */ +!function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery); \ No newline at end of file diff --git a/adminsortable/templates/adminsortable/change_form.html b/adminsortable/templates/adminsortable/change_form.html index f1c190d..65763cb 100644 --- a/adminsortable/templates/adminsortable/change_form.html +++ b/adminsortable/templates/adminsortable/change_form.html @@ -8,6 +8,7 @@ {% if has_sortable_tabular_inlines or has_sortable_stacked_inlines %} + {% include 'adminsortable/csrf/jquery.django-csrf.html' with csrf_cookie_name=csrf_cookie_name %} {% endif %} diff --git a/adminsortable/templates/adminsortable/change_list.html b/adminsortable/templates/adminsortable/change_list.html index 65cd3f2..749d830 100644 --- a/adminsortable/templates/adminsortable/change_list.html +++ b/adminsortable/templates/adminsortable/change_list.html @@ -26,6 +26,7 @@ + {% include 'adminsortable/csrf/jquery.django-csrf.html' with csrf_cookie_name=csrf_cookie_name %} {% endblock %} From 0a594928ef67fe9340ca08510aede75f2648d708 Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Wed, 11 Oct 2017 16:13:12 -0400 Subject: [PATCH 35/49] Increase margin between sortable elements in the change list. --- adminsortable/static/adminsortable/css/admin.sortable.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/adminsortable/static/adminsortable/css/admin.sortable.css b/adminsortable/static/adminsortable/css/admin.sortable.css index e03ef81..e1c857c 100644 --- a/adminsortable/static/adminsortable/css/admin.sortable.css +++ b/adminsortable/static/adminsortable/css/admin.sortable.css @@ -19,10 +19,15 @@ #sortable ul li { overflow: auto; + margin-bottom: 8px; margin-left: 0; display: block; } +#sortable ul li:last-child { + margin-bottom: 0; +} + #sortable .sortable { list-style: none; From 4e0c23a1e5bddaaa1bfe46655961d2967b1ad264 Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Fri, 13 Oct 2017 06:40:35 -0400 Subject: [PATCH 36/49] Version bump to 2.1.1. Updated readme files. --- README.md | 11 ++++++----- README.rst | 16 +++++++--------- adminsortable/__init__.py | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index ccfe141..d98a8e3 100644 --- a/README.md +++ b/README.md @@ -466,9 +466,10 @@ the extrahead block with: {% block extrahead %} {{ block.super }} - - - + + + + {% endblock extrahead %} @@ -530,8 +531,8 @@ ordering on top of that just seemed a little much in my opinion. ### Status django-admin-sortable is currently used in production. -### What's new in 2.1? -- Removed fallbacks for Django 1.8, Tox testing and many performance improvements [Pull Request 168](https://github.com/iambrandontaylor/django-admin-sortable/pull/168) thanks [@sushifan](https://github.com/jaap3) +### What's new in 2.1.1? +- Touch support ### Future - Better template support for foreign keys that are self referential. If someone would like to take on rendering recursive sortables, that would be super. diff --git a/README.rst b/README.rst index be69a9b..e120259 100644 --- a/README.rst +++ b/README.rst @@ -582,9 +582,10 @@ minimum need to extend the extrahead block with: {% block extrahead %} {{ block.super }} - - - + + + + {% endblock extrahead %} @@ -656,13 +657,10 @@ Status django-admin-sortable is currently used in production. -What's new in 2.1? -~~~~~~~~~~~~~~~~~~ +What's new in 2.1.1? +~~~~~~~~~~~~~~~~~~~~ -- Removed fallbacks for Django 1.8, Tox testing and many performance - improvements `Pull Request - 168 `__ - thanks [@sushifan](https://github.com/jaap3) +- Touch support Future ~~~~~~ diff --git a/adminsortable/__init__.py b/adminsortable/__init__.py index 5b42c1f..1a5d0c1 100644 --- a/adminsortable/__init__.py +++ b/adminsortable/__init__.py @@ -1,4 +1,4 @@ -VERSION = (2, 1, 0) +VERSION = (2, 1, 1) DEV_N = None From f4daaeb232110efa30bedf514838972929d78f1b Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Mon, 4 Dec 2017 21:29:55 -0500 Subject: [PATCH 37/49] Restructured sample project for Django 2. Refactored database and changed "app" to "samples" so name didn't conflict with "AppConfig". Replaced deprecated assignment_tag with simple_tag. Updated unit tests. --- README.md | 4 +-- README.rst | 6 ++-- adminsortable/__init__.py | 2 +- .../templatetags/django_template_additions.py | 2 +- sample_project/database/test_project.sqlite | Bin 89088 -> 90112 bytes sample_project/sample_project/settings.py | 34 ++++++++++++------ sample_project/sample_project/urls.py | 29 ++++++++------- sample_project/sample_project/wsgi.py | 29 ++++----------- sample_project/{app => samples}/__init__.py | 0 sample_project/{app => samples}/admin.py | 2 +- sample_project/samples/apps.py | 5 +++ sample_project/{app => samples}/models.py | 0 sample_project/{app => samples}/tests.py | 21 +++++------ 13 files changed, 68 insertions(+), 66 deletions(-) rename sample_project/{app => samples}/__init__.py (100%) rename sample_project/{app => samples}/admin.py (97%) create mode 100644 sample_project/samples/apps.py rename sample_project/{app => samples}/models.py (100%) rename sample_project/{app => samples}/tests.py (96%) diff --git a/README.md b/README.md index 00e2c00..777e14f 100644 --- a/README.md +++ b/README.md @@ -531,8 +531,8 @@ ordering on top of that just seemed a little much in my opinion. ### Status django-admin-sortable is currently used in production. -### What's new in 2.1.1? -- Touch support +### What's new in 2.1.2? +- Django 2 compatibility ### Future - Better template support for foreign keys that are self referential. If someone would like to take on rendering recursive sortables, that would be super. diff --git a/README.rst b/README.rst index e120259..204ff68 100644 --- a/README.rst +++ b/README.rst @@ -51,7 +51,7 @@ Download django-admin-sortable from `source `__ 1. Unzip the directory and cd into the uncompressed project directory -2. +2. - Optional: Enable your virtualenv @@ -657,10 +657,10 @@ Status django-admin-sortable is currently used in production. -What's new in 2.1.1? +What's new in 2.1.2? ~~~~~~~~~~~~~~~~~~~~ -- Touch support +- Django 2 compatibility Future ~~~~~~ diff --git a/adminsortable/__init__.py b/adminsortable/__init__.py index 1a5d0c1..22f864f 100644 --- a/adminsortable/__init__.py +++ b/adminsortable/__init__.py @@ -1,4 +1,4 @@ -VERSION = (2, 1, 1) +VERSION = (2, 1, 2) DEV_N = None diff --git a/adminsortable/templatetags/django_template_additions.py b/adminsortable/templatetags/django_template_additions.py index 1866b68..0729bb3 100644 --- a/adminsortable/templatetags/django_template_additions.py +++ b/adminsortable/templatetags/django_template_additions.py @@ -76,7 +76,7 @@ def dynamic_regroup(parser, token): return DynamicRegroupNode(target, parser, expression, var_name) -@register.assignment_tag +@register.simple_tag def get_django_version(): version = django.VERSION return {'major': version[0], 'minor': version[1]} diff --git a/sample_project/database/test_project.sqlite b/sample_project/database/test_project.sqlite index b09cb9cd68c90c9398061e43e1f1c18f1669c402..ebb7162f0cdfe2e10641aebe5985349b72901631 100644 GIT binary patch delta 5212 zcmbtYdu&_P89(P9J2y_^Hm~~T(I(DoO`7ImyUwFoNFC=fLv82T!~y1a6Q_QWn7pKt zUMJcZe*o(liiS!l+ca$;tz8Uc1EF>d1OtZHnAkeTwocPJ!GsD-3I% zaFwHb&iD9z=R4o`o$vJ2Pt>O_sqZZ>cpd;SN&dv&$!{JswLA}+{xhd0OS{oy9AOfD zgx*K*pnssN=neELdKvu={Q^CME~3AnC(vW5g1iH$>npX-%Vub=^;aBI~fig zBtv~Y8CpzaD6Jzy)lljxDpwt(fDYcRp{}6&(Obv^Uqk(P{*I z@1~m3Z{WpLbG8SrmNTde&U+*AaB$uojYa2Ua|y369E`>iL8`C_HAqDNTrdzysP>eh zmdsi#5|2fL(S)Wr4>e_$y@}v-Y;GA9my^}NtT#Fxb9)1kP}CicO;=HMARl_;ara`V zDKH&OAS%BY)k)GEw3>PdXn3Bw666#~_}Wm}s=Ba1W>q{mHy?|t_vuiN$R*!~U^HU( zAd^I%4n~7>AwLI$s1HC64-+jaM2!+ld@eQ{^e5=b-N-5}3f{rbS+$VDS8|v_^fizL zz18{1Ch~0Db{H~Rb=593C@x`rF0-G}BC|&Hvj6t^L@crx;2!d?hoRJJ}iPIIF(yfTv#geL0VPn@3|Fuxh8;Wsb5q1zyxqXNp&yVsiK*N z2AFK(&s8)+kWtRm){%b8SigSE(tEUDUo8^xJ)SOnq3npQLQOM`jc{#Vp(*Vvkvl!j z+F6%C#X}?GI9c96r-ks3%0~v+9z-)uO)zOtsQ0I1Nz^aSRXYRV=HZ)hMOhVYFCE3V zl)S#VH%pcM6rg?&uYjj;LEib6WK}lJ^z^{BVFivX_JyDkZ7Zs&lI(1+iA&!P*BrZn zU7%^Et`4rXY}1tpiuQ70mUA6jD~+A_t5q2{++RI9P?NaRG8!zX4yMy<%z_@ zZ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Y7bbU#$!1feaxiA-Bj7`$*DHIk<-ZI4k`DpC8iW-{PVqA}EB>0t%rJ z`G6!zQj#{Gugb?wgx&V>m?Sme@6XE3$@jQlb0s*hhzA#fyKn`53CAG<-vZaHWQ3%v z63?qKxq`@*S?L1FOSI}#n~$pkbpERC`~wFTun|wo!99oIReTfApmR7PNvG(8V{fUO zwyA|aryLnm@=*~sb22iQnh}S|TQyj1;&vd|A^%UY9eB}!3y|nahPtpY)X?bhc&b7p z`;UyTeg4^o0|$qy{PoZFyf8AbzCX5S@^GMU|Muw1^?U04^@n|vb=}*x40sQ|+}+pP pxyk=RUt5F6+wAsu-3@-5w`pCIZ=Kh_rm4~2)Yy3bMi*XV`ad_*3IzZF diff --git a/sample_project/sample_project/settings.py b/sample_project/sample_project/settings.py index 7327e75..151d35e 100644 --- a/sample_project/sample_project/settings.py +++ b/sample_project/sample_project/settings.py @@ -93,13 +93,12 @@ STATICFILES_FINDERS = ( SECRET_KEY = '8**a!c8$1x)p@j2pj0yq!*v+dzp24g*$918ws#x@k+gf%0%rct' MIDDLEWARE = [ - 'django.middleware.common.CommonMiddleware', + 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', - # Uncomment the next line for simple clickjacking protection: 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] @@ -115,17 +114,14 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ - map_path('templates') + map_path('templates'), ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ - 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.debug', - 'django.template.context_processors.i18n', - 'django.template.context_processors.media', - 'django.template.context_processors.static', - 'django.template.context_processors.tz', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, @@ -143,7 +139,7 @@ INSTALLED_APPS = ( 'django.contrib.admindocs', 'adminsortable', - 'app', + 'samples', ) # A sample logging configuration. The only tangible logging @@ -174,3 +170,21 @@ LOGGING = { }, } } + +# Password validation +# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] diff --git a/sample_project/sample_project/urls.py b/sample_project/sample_project/urls.py index 3e2dcfe..2071700 100644 --- a/sample_project/sample_project/urls.py +++ b/sample_project/sample_project/urls.py @@ -1,18 +1,21 @@ -from django.conf.urls import include, url +"""django2_app URL Configuration -# Uncomment the next two lines to enable the admin: +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" from django.contrib import admin -admin.autodiscover() - +from django.urls import path urlpatterns = [ - # Examples: - # url(r'^$', 'test_project.views.home', name='home'), - # url(r'^test_project/', include('test_project.foo.urls')), - - # Uncomment the admin/doc line below to enable admin documentation: - url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - - # Uncomment the next line to enable the admin: - url(r'^admin/', admin.site.urls), + path('admin/', admin.site.urls), ] diff --git a/sample_project/sample_project/wsgi.py b/sample_project/sample_project/wsgi.py index 43ff066..c54b86f 100644 --- a/sample_project/sample_project/wsgi.py +++ b/sample_project/sample_project/wsgi.py @@ -1,32 +1,15 @@ """ -WSGI config for test_project project. +WSGI config for django2_app project. -This module contains the WSGI application used by Django's development server -and any production WSGI deployments. It should expose a module-level variable -named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover -this application via the ``WSGI_APPLICATION`` setting. - -Usually you will have the standard Django WSGI application here, but it also -might make sense to replace the whole Django WSGI application with a custom one -that later delegates to the Django one. For example, you could introduce WSGI -middleware here, or combine a Django application with an application of another -framework. +It exposes the WSGI callable as a module-level variable named ``application``. +For more information on this file, see +https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ """ import os -# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks -# if running multiple sites in the same mod_wsgi process. To fix this, use -# mod_wsgi daemon mode with each site in its own daemon process, or use -# os.environ["DJANGO_SETTINGS_MODULE"] = "test_project.settings" -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project.settings") - -# This application object is used by any WSGI server configured to use this -# file. This includes Django's development server, if the WSGI_APPLICATION -# setting points here. from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project.settings") application = get_wsgi_application() -# Apply WSGI middleware here. -# from helloworld.wsgi import HelloWorldApplication -# application = HelloWorldApplication(application) diff --git a/sample_project/app/__init__.py b/sample_project/samples/__init__.py similarity index 100% rename from sample_project/app/__init__.py rename to sample_project/samples/__init__.py diff --git a/sample_project/app/admin.py b/sample_project/samples/admin.py similarity index 97% rename from sample_project/app/admin.py rename to sample_project/samples/admin.py index 9da0c19..ec18418 100644 --- a/sample_project/app/admin.py +++ b/sample_project/samples/admin.py @@ -4,7 +4,7 @@ from adminsortable.admin import (SortableAdmin, SortableTabularInline, SortableStackedInline, SortableGenericStackedInline, NonSortableParentAdmin) from adminsortable.utils import get_is_sortable -from app.models import (Category, Widget, Project, Credit, Note, GenericNote, +from .models import (Category, Widget, Project, Credit, Note, GenericNote, Component, Person, NonSortableCategory, SortableCategoryWidget, SortableNonInlineCategory, NonSortableCredit, NonSortableNote, CustomWidget, CustomWidgetComponent, BackwardCompatibleWidget) diff --git a/sample_project/samples/apps.py b/sample_project/samples/apps.py new file mode 100644 index 0000000..ea7abac --- /dev/null +++ b/sample_project/samples/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class SamplesConfig(AppConfig): + name = 'samples' diff --git a/sample_project/app/models.py b/sample_project/samples/models.py similarity index 100% rename from sample_project/app/models.py rename to sample_project/samples/models.py diff --git a/sample_project/app/tests.py b/sample_project/samples/tests.py similarity index 96% rename from sample_project/app/tests.py rename to sample_project/samples/tests.py index 0278331..60715f5 100644 --- a/sample_project/app/tests.py +++ b/sample_project/samples/tests.py @@ -15,7 +15,7 @@ from django.test.client import Client from adminsortable.models import SortableMixin from adminsortable.utils import get_is_sortable -from app.models import Category, Person, Project +from .models import Category, Person, Project class TestSortableModel(SortableMixin): @@ -113,7 +113,7 @@ class SortableTestCase(TestCase): def test_adminsortable_change_list_view(self): self.client.login(username=self.user.username, password=self.user_raw_password) - response = self.client.get('/admin/app/category/sort/') + response = self.client.get('/admin/samples/category/sort/') self.assertEqual(response.status_code, httplib.OK, 'Unable to reach sort view.') @@ -124,7 +124,7 @@ class SortableTestCase(TestCase): return category1, category2, category3 def get_sorting_url(self, model): - return '/admin/app/project/sort/do-sorting/{0}/'.format( + return '/admin/samples/project/sort/do-sorting/{0}/'.format( model.model_type_id()) def get_category_indexes(self, *categories): @@ -135,7 +135,7 @@ class SortableTestCase(TestCase): password=self.user_raw_password) self.assertTrue(logged_in, 'User is not logged in') - response = self.client.get('/admin/app/category/sort/') + response = self.client.get('/admin/samples/category/sort/') self.assertEqual(response.status_code, httplib.OK, 'Admin sort request failed.') @@ -185,8 +185,7 @@ class SortableTestCase(TestCase): # make a normal POST response = self.client.post(self.get_sorting_url(Category), data=self.get_category_indexes(category1, category2, category3)) - content = json.loads(response.content.decode(encoding='UTF-8'), - 'latin-1') + content = json.loads(response.content.decode(encoding='UTF-8')) self.assertFalse(content.get('objects_sorted'), 'Objects should not have been sorted. An ajax post is required.') @@ -202,8 +201,7 @@ class SortableTestCase(TestCase): response = self.client.post(self.get_sorting_url(Category), data=self.get_category_indexes(category3, category2, category1), HTTP_X_REQUESTED_WITH='XMLHttpRequest') - content = json.loads(response.content.decode(encoding='UTF-8'), - 'latin-1') + content = json.loads(response.content.decode(encoding='UTF-8')) self.assertTrue(content.get('objects_sorted'), 'Objects should have been sorted.') @@ -256,7 +254,7 @@ class SortableTestCase(TestCase): self.client.login(username=self.user.username, password=self.user_raw_password) - response = self.client.get('/admin/app/project/sort/') + response = self.client.get('/admin/samples/project/sort/') self.assertEqual(response.status_code, httplib.OK, 'Unable to reach sort view.') @@ -266,7 +264,7 @@ class SortableTestCase(TestCase): self.client.login(username=self.staff.username, password=self.staff_raw_password) - response = self.client.get('/admin/app/project/sort/') + response = self.client.get('/admin/samples/project/sort/') self.assertEqual(response.status_code, httplib.FORBIDDEN, 'Sort view must be forbidden.') @@ -291,8 +289,7 @@ class SortableTestCase(TestCase): response.status_code, httplib.OK, 'Note inline must be sortable in ProjectAdmin') - content = json.loads(response.content.decode(encoding='UTF-8'), - 'latin-1') + content = json.loads(response.content.decode(encoding='UTF-8')) self.assertTrue(content.get('objects_sorted'), 'Objects should have been sorted.') From d4f577fdf905aa1cdef7fe2bce490197b68cbaa5 Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Mon, 4 Dec 2017 22:05:37 -0500 Subject: [PATCH 38/49] Update csrf value to use value if present in context, then fall back to cookie. Updated database samples. Added migrations for sample project models. Updated Category model to make order not editable. --- .../csrf/jquery.django-csrf.html | 2 +- sample_project/database/test_project.sqlite | Bin 90112 -> 266240 bytes .../samples/migrations/0001_initial.py | 235 ++++++++++++++++++ sample_project/samples/migrations/__init__.py | 0 sample_project/samples/models.py | 2 +- 5 files changed, 237 insertions(+), 2 deletions(-) create mode 100644 sample_project/samples/migrations/0001_initial.py create mode 100644 sample_project/samples/migrations/__init__.py diff --git a/adminsortable/templates/adminsortable/csrf/jquery.django-csrf.html b/adminsortable/templates/adminsortable/csrf/jquery.django-csrf.html index 24fb6c3..b9488a8 100644 --- a/adminsortable/templates/adminsortable/csrf/jquery.django-csrf.html +++ b/adminsortable/templates/adminsortable/csrf/jquery.django-csrf.html @@ -16,7 +16,7 @@ return cookieValue; } - var csrftoken = getCookie('{{ csrf_cookie_name }}'); + var csrftoken = '{{ csrf_token }}' || getCookie('{{ csrf_cookie_name }}'); function csrfSafeMethod(method) { // these HTTP methods do not require CSRF protection diff --git a/sample_project/database/test_project.sqlite b/sample_project/database/test_project.sqlite index ebb7162f0cdfe2e10641aebe5985349b72901631..4efba758bf0d59a933fba9dd73468ca00d35622b 100644 GIT binary patch literal 266240 zcmeI53ve9Ad7yXpfyDyYX*@X+A&P?qA#nu)*w^f0K|v%4EFn;u|ekc4a}UXW29l}oNt7gw$>aU5SR@8>0zOQK8J$>kE=UCK^!_SuOO+Z8)@5X=gH2OeV_2Y z?)&MsKlBvbKkE7im&l>NvnpDlKS1a3F zHTioXFCS*`mt-s|gmR%=X1iQ?p;^3db~!b(lH#wX7cO5-@eAp>)OEgDXdj#WQkoAm z>je0d0qRyEA2`JasB_qxK(H~@Q#}DMLDcDRXmybq-Y)J1nErhyldrym~-XHg=O{h%X`&md=|eDkm3L#0X` zL4J;uE>o8l(hDmKGZ!zeDw(OdmM+-pQ;T(-#lh+b?uI(O+}Id%x338;JrfK-<>M|p zjB@dzf~TF!2jE6!4~Xo}6Fx6@{5bQ{uo;=w`8sSM-4mTHu~xfPsp1}aQ>^AT#Old# zWHP9AOWa9{Vy&JjR@MvU0G}7@QoT@;jOB$|rnZec2I-^$K3l02jin@)3;??QXh=7& z{A%M`)(TZzjlHDm$et2XNh}ogni7Iu6V@k=*2T58Rwr?Zn5!3VVlSKhClP0!$5$#6 zM${61Fx=6`rH(TWIvCboDB=sY3~ng-%7%PXE^Wfv*UsH^yO&EQnY#(SedWHSpI!2a z(UR-4X!#bQd+G+Vm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A0bUp2 zO9gnL*BAClqIkju0*#7ZBk6Q=QPTc?0bU;|-GmtE6zLJ*WxXE?EOT!t`@`dTjO|f5qm777y z9~K9WlC<0{kXF##hHycel-h8>qEWK!6INzQ{qTAQg8qQtH*iE34ipIotcCskQV5oH zhJ2!LpiLK+ii9N#VP8L478>m3gMNQl7&xp8`-_DA<%9)j@BDtj9~fxWg`rI`wws(- zD$IxbrEou~29hX*0t1J1VWCJ^C@0K^di~I53gJB4Qbpbku$)`9+EiY3y5%|yZ7RGY zLv*{e7&PmdY%W6f)#v8Z8J$^cwUjnkdE~I%mOeEofgef$?Y0=^C86gal%P$imx@mc zC%W~9f_};TK3M(R8w!h|Am8KB*#(tdC}oEy6Y`6^AoU#3*?EV( z9|utLjfeAfT`o_1JIXIpcO8220d=G;{OVD)m>N8DVVLVE5O%c@p!xKMka179D--$a zFL!yOlW42Pw7N?}2edYOh?T{$gtOBGrM^AX&MBMMgq7u2R*5OFDxOdJ>MC{7-i4RB nJP(hdEo51=In_7ndAuJbg({P#b&1T(I~V7+Scmsgt+xID35SLv diff --git a/sample_project/samples/migrations/0001_initial.py b/sample_project/samples/migrations/0001_initial.py new file mode 100644 index 0000000..94ea157 --- /dev/null +++ b/sample_project/samples/migrations/0001_initial.py @@ -0,0 +1,235 @@ +# Generated by Django 2.0 on 2017-12-05 02:55 + +import adminsortable.fields +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('contenttypes', '0002_remove_content_type_name'), + ] + + operations = [ + migrations.CreateModel( + name='BackwardCompatibleWidget', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('order', models.PositiveIntegerField(db_index=True, default=0, editable=False)), + ('title', models.CharField(max_length=50)), + ], + options={ + 'verbose_name': 'Backward Compatible Widget', + 'verbose_name_plural': 'Backward Compatible Widgets', + 'ordering': ['order'], + 'abstract': False, + }, + ), + migrations.CreateModel( + name='Category', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=50)), + ('order', models.PositiveIntegerField(default=0)), + ], + options={ + 'verbose_name_plural': 'Categories', + 'ordering': ['order'], + }, + ), + migrations.CreateModel( + name='Component', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=50)), + ('order', models.PositiveIntegerField(default=0, editable=False)), + ], + options={ + 'ordering': ['order'], + }, + ), + migrations.CreateModel( + name='Credit', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(help_text='Given name', max_length=30)), + ('last_name', models.CharField(help_text='Family name', max_length=30)), + ('order', models.PositiveIntegerField(default=0, editable=False)), + ], + options={ + 'ordering': ['order'], + }, + ), + migrations.CreateModel( + name='CustomWidget', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=50)), + ('custom_order_field', models.PositiveIntegerField(db_index=True, default=0, editable=False)), + ], + options={ + 'verbose_name': 'Custom Widget', + 'verbose_name_plural': 'Custom Widgets', + 'ordering': ['custom_order_field'], + }, + ), + migrations.CreateModel( + name='CustomWidgetComponent', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=50)), + ('widget_order', models.PositiveIntegerField(db_index=True, default=0, editable=False)), + ('custom_widget', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='samples.CustomWidget')), + ], + options={ + 'verbose_name': 'Custom Widget Component', + 'verbose_name_plural': 'Custom Widget Components', + 'ordering': ['widget_order'], + }, + ), + migrations.CreateModel( + name='GenericNote', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=50)), + ('object_id', models.PositiveIntegerField(verbose_name='Content id')), + ('order', models.PositiveIntegerField(default=0, editable=False)), + ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='generic_notes', to='contenttypes.ContentType', verbose_name='Content type')), + ], + options={ + 'ordering': ['order'], + }, + ), + migrations.CreateModel( + name='NonSortableCategory', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=50)), + ], + options={ + 'verbose_name': 'Non-Sortable Category', + 'verbose_name_plural': 'Non-Sortable Categories', + 'abstract': False, + }, + ), + migrations.CreateModel( + name='NonSortableCredit', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(help_text='Given name', max_length=30)), + ('last_name', models.CharField(help_text='Family name', max_length=30)), + ], + ), + migrations.CreateModel( + name='NonSortableNote', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.CharField(max_length=100)), + ], + ), + migrations.CreateModel( + name='Note', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.CharField(max_length=100)), + ('order', models.PositiveIntegerField(default=0, editable=False)), + ], + options={ + 'ordering': ['order'], + }, + ), + migrations.CreateModel( + name='Person', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=50)), + ('last_name', models.CharField(max_length=50)), + ('is_board_member', models.BooleanField(default=False, verbose_name='Board Member')), + ('order', models.PositiveIntegerField(default=0, editable=False)), + ], + options={ + 'verbose_name_plural': 'People', + 'ordering': ['order'], + }, + ), + migrations.CreateModel( + name='Project', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=50)), + ('description', models.TextField()), + ('order', models.PositiveIntegerField(default=0, editable=False)), + ('category', adminsortable.fields.SortableForeignKey(on_delete=django.db.models.deletion.CASCADE, to='samples.Category')), + ], + options={ + 'ordering': ['order'], + }, + ), + migrations.CreateModel( + name='SortableCategoryWidget', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=50)), + ('order', models.PositiveIntegerField(default=0, editable=False)), + ('non_sortable_category', adminsortable.fields.SortableForeignKey(on_delete=django.db.models.deletion.CASCADE, to='samples.NonSortableCategory')), + ], + options={ + 'verbose_name': 'Sortable Category Widget', + 'verbose_name_plural': 'Sortable Category Widgets', + 'ordering': ['order'], + }, + ), + migrations.CreateModel( + name='SortableNonInlineCategory', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=50)), + ('order', models.PositiveIntegerField(default=0, editable=False)), + ('non_sortable_category', adminsortable.fields.SortableForeignKey(on_delete=django.db.models.deletion.CASCADE, to='samples.NonSortableCategory')), + ], + options={ + 'verbose_name': 'Sortable Non-Inline Category', + 'verbose_name_plural': 'Sortable Non-Inline Categories', + 'ordering': ['order'], + }, + ), + migrations.CreateModel( + name='Widget', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=50)), + ('order', models.PositiveIntegerField(default=0, editable=False)), + ], + options={ + 'ordering': ['order'], + }, + ), + migrations.AddField( + model_name='note', + name='project', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='samples.Project'), + ), + migrations.AddField( + model_name='nonsortablenote', + name='project', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='samples.Project'), + ), + migrations.AddField( + model_name='nonsortablecredit', + name='project', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='samples.Project'), + ), + migrations.AddField( + model_name='credit', + name='project', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='samples.Project'), + ), + migrations.AddField( + model_name='component', + name='widget', + field=adminsortable.fields.SortableForeignKey(on_delete=django.db.models.deletion.CASCADE, to='samples.Widget'), + ), + ] diff --git a/sample_project/samples/migrations/__init__.py b/sample_project/samples/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sample_project/samples/models.py b/sample_project/samples/models.py index 4036064..81a56d4 100644 --- a/sample_project/samples/models.py +++ b/sample_project/samples/models.py @@ -24,7 +24,7 @@ class Category(SimpleModel, SortableMixin): verbose_name_plural = 'Categories' ordering = ['order'] - order = models.PositiveIntegerField(default=0) + order = models.PositiveIntegerField(default=0, editable=False) # A model with an override of its queryset for admin From 604bfd035a3b1ccdeef6c65bb236787368c8916a Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Mon, 4 Dec 2017 22:10:12 -0500 Subject: [PATCH 39/49] Updated tox --- tox.ini | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 2f8f44f..b67add1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = django{1.8,1.9,1.10,1.11}-{py27,py34,py35},coverage +envlist = django{1.8,1.9,1.10,1.11,2}-{py27,py34,py35,py36},coverage [testenv] deps = @@ -8,12 +8,13 @@ deps = django1.9: Django>=1.9,<1.10 django1.10: Django>=1.10,<1.11 django1.11: Django>=1.11a1,<1.12 + django2.0: Django>=2.0 whitelist_externals = cd setenv = PYTHONPATH = {toxinidir}/sample_project PYTHONWARNINGS = module PYTHONDONTWRITEBYTECODE = 1 -commands = +commands = coverage run -p sample_project/manage.py test app [testenv:coverage] From 8d4c5b141774d00dae1170418e4337e5d0cd9410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Mon, 5 Feb 2018 17:25:14 +0100 Subject: [PATCH 40/49] =?UTF-8?q?Add=20Norwegian=20Bokm=C3=A5l=20translati?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adminsortable/locale/nb/LC_MESSAGES/django.mo | Bin 0 -> 1118 bytes adminsortable/locale/nb/LC_MESSAGES/django.po | 51 ++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 adminsortable/locale/nb/LC_MESSAGES/django.mo create mode 100644 adminsortable/locale/nb/LC_MESSAGES/django.po diff --git a/adminsortable/locale/nb/LC_MESSAGES/django.mo b/adminsortable/locale/nb/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..092453a1898137896b9e5aea8df82a60de466950 GIT binary patch literal 1118 zcma))&ubGw6vtPsRaOzSc=PZsft zgEz1K554!I|A5}Sc=E5%?>0@F(25=S@?m%1d*AnF-_I*EpCX*|&^724bOHJdmFFvT z5&8zrL*JnaG9X)?;3?bG!eh0Qp>=_y$1 zj^Z-y`?(yFJz;#d*c9(gu744f%jI!K8&?SKk&C3A1l z`}7c{i|pjw?hM=ATzcQ$AEIq!QCc5PH)Xit>>KU|v6_h&?7X%nC7Bi4j0?t1?xVI? z^Gavp;XrxOvMI$I>!QhTb(tYnWZ;x)NwqGLnn)I?x|r7P+)k=V60fbUH4aNxD@nX; zO<)s53wM%I;CEpjx2?_H^7@_UaPN8Rk*FWWIcfYBJJB#*n`xs`s&{mVpGuD+<;PqG z>r#5A3pVtGm0}-ucZNAF`SR5^s|Tu(I{cwCV|&we7$oG5WJ zfv~si_jYU2@c7l5vOliM(Lq`|@5mlg(D}r|tqiCq4GcY|!NMI_GlItZ@y~_(ZySFB DWiV2B literal 0 HcmV?d00001 diff --git a/adminsortable/locale/nb/LC_MESSAGES/django.po b/adminsortable/locale/nb/LC_MESSAGES/django.po new file mode 100644 index 0000000..4f6366c --- /dev/null +++ b/adminsortable/locale/nb/LC_MESSAGES/django.po @@ -0,0 +1,51 @@ +msgid "" +msgstr "" +"Project-Id-Version: adminsortable\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-09-22 15:42+0200\n" +"PO-Revision-Date: 2018-02-05 17:24+0100\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Last-Translator: Simen Heggestøyl \n" +"Language-Team: \n" +"Language: nb\n" +"X-Generator: Poedit 2.0.5\n" + +#: templates/adminsortable/change_list.html:15 +#, python-format +msgid "Drag and drop %(model)s to change display order" +msgstr "Dra og slipp %(model)s for å endre visningsrekkefølgen" + +#: templates/adminsortable/change_list.html:25 +#, python-format +msgid "Reorder" +msgstr "Endre rekkefølge" + +#: templates/adminsortable/change_list.html:32 +#, python-format +msgid "Drag and drop %(sort_type)s %(model)s to change their order." +msgstr "Dra og slipp %(sort_type)s %(model)s for å endre rekkefølgen deres." + +#: templates/adminsortable/change_list.html:34 +#, python-format +msgid "Drag and drop %(model)s to change their order." +msgstr "Dra og slipp %(model)s for å endre rekkefølgen deres." + +#: templates/adminsortable/change_list.html:39 +#, python-format +msgid "" +"You may also drag and drop %(sortable_by_class_display_name)s to change " +"their order." +msgstr "" +"Du kan også dra og slippe %(sortable_by_class_display_name)s for å endre " +"rekkefølgen deres." + +#: templates/adminsortable/change_list.html:50 +#, python-format +msgid "Return to %(model)s" +msgstr "Tilbake til %(model)s" + +#: templates/adminsortable/change_list_with_sort_link.html:6 +msgid "Change Order" +msgstr "Endre rekkefølge" From f992fc72b400b2571a51b0559d9817cecc70adef Mon Sep 17 00:00:00 2001 From: Peteris Bruns Date: Thu, 8 Feb 2018 22:48:57 +0200 Subject: [PATCH 41/49] Added Latvian translation. --- adminsortable/locale/lv/LC_MESSAGES/django.po | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 adminsortable/locale/lv/LC_MESSAGES/django.po diff --git a/adminsortable/locale/lv/LC_MESSAGES/django.po b/adminsortable/locale/lv/LC_MESSAGES/django.po new file mode 100644 index 0000000..4ed9940 --- /dev/null +++ b/adminsortable/locale/lv/LC_MESSAGES/django.po @@ -0,0 +1,51 @@ +msgid "" +msgstr "" +"Project-Id-Version: adminsortable\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-09-22 15:42+0200\n" +"PO-Revision-Date: 2018-02-08 22:47+0200\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Last-Translator: Pēteris \n" +"Language-Team: \n" +"Language: lv\n" +"X-Generator: Poedit 1.8.7.1\n" + +#: templates/adminsortable/change_list.html:15 +#, python-format +msgid "Drag and drop %(model)s to change display order" +msgstr "Velc un novieto %(model)s, lai mainītu attēlošanas secību" + +#: templates/adminsortable/change_list.html:25 +#, python-format +msgid "Reorder" +msgstr "Pārkārtot" + +#: templates/adminsortable/change_list.html:32 +#, python-format +msgid "Drag and drop %(sort_type)s %(model)s to change their order." +msgstr "Velc un novieto %(sort_type)s %(model)s, lai mainītu to secību." + +#: templates/adminsortable/change_list.html:34 +#, python-format +msgid "Drag and drop %(model)s to change their order." +msgstr "Velc un novieto %(model)s, lai mainītu attēlošanas secību." + +#: templates/adminsortable/change_list.html:39 +#, python-format +msgid "" +"You may also drag and drop %(sortable_by_class_display_name)s to change " +"their order." +msgstr "" +"Tu vari arī vilt un pārvieetot %(sortable_by_class_display_name)s, lai " +"mainītu secību." + +#: templates/adminsortable/change_list.html:50 +#, python-format +msgid "Return to %(model)s" +msgstr "Atgriezties pie %(model)s" + +#: templates/adminsortable/change_list_with_sort_link.html:6 +msgid "Change Order" +msgstr "Mainīt secību" From 40affcaea3cc9d09e625111e2920fb187810c428 Mon Sep 17 00:00:00 2001 From: Basil Shubin Date: Fri, 16 Feb 2018 18:25:11 +0700 Subject: [PATCH 42/49] let there be (correct) colour + corrected indentation level as a bonus --- README.md | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 777e14f..377a179 100644 --- a/README.md +++ b/README.md @@ -199,17 +199,17 @@ If you previously used Django Admin Sortable, **DON'T PANIC** - everything will Please note however that the `Sortable` class still contains the hard-coded `order` field, and meta inheritance requirements: ```python - # legacy model definition +# legacy model definition - from adminsortable.models import Sortable +from adminsortable.models import Sortable - class Project(Sortable): - class Meta(Sortable.Meta): - pass - title = models.CharField(max_length=50) +class Project(Sortable): + class Meta(Sortable.Meta): + pass + title = models.CharField(max_length=50) - def __unicode__(self): - return self.title + def __unicode__(self): + return self.title ``` #### Model Instance Methods @@ -409,8 +409,8 @@ change_list_template_extends These attributes have default values of: ```python - change_form_template_extends = 'admin/change_form.html' - change_list_template_extends = 'admin/change_list.html' +change_form_template_extends = 'admin/change_form.html' +change_list_template_extends = 'admin/change_list.html' ``` If you need to extend the inline change form templates, you'll need to select the right one, depending on your version of Django. For Django 1.5.x or below, you'll need to extend one of the following: @@ -460,7 +460,7 @@ plugin_pool.register_plugin(CMSCarouselPlugin) The contents of `sortable-stacked-inline-change-form.html` at a minimum need to extend the extrahead block with: -```html +```html+django {% extends "admin/cms/page/plugin_change_form.html" %} {% load static from staticfiles %} @@ -477,40 +477,40 @@ the extrahead block with: Sorting within Django-CMS is really only feasible for inline models of a plugin as Django-CMS already includes sorting for plugin instances. For tabular inlines, just substitute: -```html - +```html+django + ``` with: -```html - +```html+django + ``` ### Notes From ``django-cms 3.x`` the path of change_form.html has changed. Replace the follwing line: -```html - {% extends "admin/cms/page/plugin_change_form.html" %} +```html+django +{% extends "admin/cms/page/plugin_change_form.html" %} ``` with -```html - {% extends "admin/cms/page/plugin/change_form.html" %} +```html+django +{% extends "admin/cms/page/plugin/change_form.html" %} ``` From ``django-admin-sortable 2.0.13`` the ``jquery.django-csrf.js`` was removed and you have to include the snippet-template. Change the following line: -```html - +```html+django + ``` to -```html - {% include 'adminsortable/csrf/jquery.django-csrf.html' with csrf_cookie_name='csrftoken' %} +```html+django +{% include 'adminsortable/csrf/jquery.django-csrf.html' with csrf_cookie_name='csrftoken' %} ``` Please note, if you change the ``CSRF_COOKIE_NAME`` you have to adjust ``csrf_cookie_name='YOUR_CSRF_COOKIE_NAME'`` From f515f93d22375fc348c3020608670f3bfd74cc7b Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Sun, 25 Feb 2018 11:49:38 -0500 Subject: [PATCH 43/49] Version bump to 2.1.3 Updated readme with credits for translations. --- README.md | 4 +- README.rst | 132 +++++++++++++++++++------------------- adminsortable/__init__.py | 2 +- 3 files changed, 70 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index 377a179..60f22f3 100644 --- a/README.md +++ b/README.md @@ -531,8 +531,8 @@ ordering on top of that just seemed a little much in my opinion. ### Status django-admin-sortable is currently used in production. -### What's new in 2.1.2? -- Django 2 compatibility +### What's new in 2.1.3? +- Norwegian and Latvian translations. Credit to [simenheg](https://github.com/simenheg) and [peterisb](https://github.com/peterisb) respectively. ### Future - Better template support for foreign keys that are self referential. If someone would like to take on rendering recursive sortables, that would be super. diff --git a/README.rst b/README.rst index 204ff68..c48ee31 100644 --- a/README.rst +++ b/README.rst @@ -36,7 +36,7 @@ Django 1.4.x django-admin-sortable 1.6.6 introduced a backward-incompatible change for the ``sorting_filters`` attribute. Please convert your attributes to -the new tuple-based format if you haven't already. +the new tuple-based format if you haven’t already. django-admin-sortable 1.7.1 and higher are compatible with Python 3. @@ -45,13 +45,13 @@ Installation 1. ``$ pip install django-admin-sortable`` ---or-- +–or– Download django-admin-sortable from `source `__ 1. Unzip the directory and cd into the uncompressed project directory -2. +2. - Optional: Enable your virtualenv @@ -84,11 +84,11 @@ to the location you serve static files from. Testing ~~~~~~~ -Have a look at the included sample\_project to see working examples. The +Have a look at the included sample_project to see working examples. The login credentials for admin are: admin/admin When a model is sortable, a tool-area link will be added that says -"Change Order". Click this link, and you will be taken to the custom +“Change Order”. Click this link, and you will be taken to the custom view where you can drag-and-drop the records into order. Inlines may be drag-and-dropped into any order directly from the change @@ -100,11 +100,11 @@ Usage Models ~~~~~~ -To add "sortability" to a model, you need to inherit ``SortableMixin`` +To add “sortability” to a model, you need to inherit ``SortableMixin`` and at minimum, define: - The field which should be used for ``Meta.ordering``, which must - resolve to one of the integer fields defined in Django's ORM: + resolve to one of the integer fields defined in Django’s ORM: - ``PositiveIntegerField`` - ``IntegerField`` - ``PositiveSmallIntegerField`` @@ -114,7 +114,7 @@ and at minimum, define: - ``Meta.ordering`` **must only contain one value**, otherwise, your objects will not be sorted correctly. - **IMPORTANT**: You must name the field you use for ordering something - other than "order\_field" as this name is reserved by the + other than “order_field” as this name is reserved by the ``SortableMixin`` class. - It is recommended that you set ``editable=False`` and ``db_index=True`` on the field defined in ``Meta.ordering`` for a @@ -143,14 +143,14 @@ Sample Model: def __unicode__(self): return self.title -Support for models that don't use an ``AutoField`` for their primary key +Support for models that don’t use an ``AutoField`` for their primary key are also supported in version 2.0.20 or higher. Common Use Case ^^^^^^^^^^^^^^^ A common use case is to have child objects that are sortable relative to -a parent. If your parent object is also sortable, here's how you would +a parent. If your parent object is also sortable, here’s how you would set up your models and admin options: .. code:: python @@ -241,7 +241,7 @@ will be grouped by the non-sortable foreign key when sorting. Backwards Compatibility ~~~~~~~~~~~~~~~~~~~~~~~ -If you previously used Django Admin Sortable, **DON'T PANIC** - +If you previously used Django Admin Sortable, **DON’T PANIC** - everything will still work exactly as before ***without any changes to your code***. Going forward, it is recommended that you use the new ``SortableMixin`` on your models, as pre-2.0 compatibility might not be @@ -252,17 +252,17 @@ hard-coded ``order`` field, and meta inheritance requirements: .. code:: python - # legacy model definition + # legacy model definition - from adminsortable.models import Sortable + from adminsortable.models import Sortable - class Project(Sortable): - class Meta(Sortable.Meta): - pass - title = models.CharField(max_length=50) + class Project(Sortable): + class Meta(Sortable.Meta): + pass + title = models.CharField(max_length=50) - def __unicode__(self): - return self.title + def __unicode__(self): + return self.title Model Instance Methods ^^^^^^^^^^^^^^^^^^^^^^ @@ -289,7 +289,7 @@ following data: | | Child Model 4 | | | Child Model 5 | -"Child Model 2" ``get_next()`` would return ``None`` "Child Model 3" +“Child Model 2” ``get_next()`` would return ``None`` “Child Model 3” ``get_previous`` would return ``None`` If you wish to override this behavior, pass in: @@ -299,7 +299,7 @@ If you wish to override this behavior, pass in: your_instance.get_next(filter_on_sortable_fk=False) -You may also pass in additional ORM "extra\_filters" as a dictionary, +You may also pass in additional ORM “extra_filters” as a dictionary, should you need to: .. code:: python @@ -312,13 +312,13 @@ Adding Sorting to an existing model Django 1.5.x to 1.6.x ^^^^^^^^^^^^^^^^^^^^^ -If you're adding Sorting to an existing model, it is recommended that +If you’re adding Sorting to an existing model, it is recommended that you use `django-south `__ to create a schema -migration to add the "order" field to your model. You will also need to +migration to add the “order” field to your model. You will also need to create a data migration in order to add the appropriate values for the -"order" column. +“order” column. -Example assuming a model named "Category": +Example assuming a model named “Category”: .. code:: python @@ -334,7 +334,7 @@ more information on South Data Migrations. Django 1.7.x or higher ^^^^^^^^^^^^^^^^^^^^^^ -Since schema migrations are built into Django 1.7, you don't have to use +Since schema migrations are built into Django 1.7, you don’t have to use south, but the process of adding and running migrations is nearly identical. Take a look at the `Migrations `__ @@ -405,8 +405,8 @@ Overriding ``queryset()`` django-admin-sortable supports custom queryset overrides on admin models and inline models in Django admin! -If you're providing an override of a SortableAdmin or Sortable inline -model, you don't need to do anything extra. django-admin-sortable will +If you’re providing an override of a SortableAdmin or Sortable inline +model, you don’t need to do anything extra. django-admin-sortable will automatically honor your queryset. Have a look at the WidgetAdmin class in the sample project for an @@ -441,7 +441,7 @@ properly determine the sortability of your model. Example: return qs If you override the queryset of an inline, the number of objects present -may change, and adminsortable won't be able to automatically determine +may change, and adminsortable won’t be able to automatically determine if the inline model is sortable from here, which is why we have to set the ``is_sortable`` property of the model in this method. @@ -453,28 +453,28 @@ a ``sorting_filters`` tuple. This works exactly the same as ``.filter()`` on a QuerySet, and is applied *after* ``get_queryset()`` on the admin class, allowing you to override the queryset as you would normally in admin but apply additional filters for sorting. The text -"Change Order of" will appear before each filter in the Change List +“Change Order of” will appear before each filter in the Change List template, and the filter groups are displayed from left to right in the -order listed. If no ``sorting_filters`` are specified, the text "Change -Order" will be displayed for the link. +order listed. If no ``sorting_filters`` are specified, the text “Change +Order” will be displayed for the link. Self-Referential SortableForeignKey ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You can specify a self-referential SortableForeignKey field, however the admin interface will currently show a model that is a grandchild at the -same level as a child. I'm working to resolve this issue. +same level as a child. I’m working to resolve this issue. Important! '''''''''' django-admin-sortable 1.6.6 introduced a backwards-incompatible change for ``sorting_filters``. Previously this attribute was defined as a -dictionary, so you'll need to change your values over to the new +dictionary, so you’ll need to change your values over to the new tuple-based format. -An example of sorting subsets would be a "Board of Directors". In this -use case, you have a list of "People" objects. Some of these people are +An example of sorting subsets would be a “Board of Directors”. In this +use case, you have a list of “People” objects. Some of these people are on the Board of Directors and some not, and you need to sort them independently. @@ -499,9 +499,9 @@ independently. Extending custom templates ^^^^^^^^^^^^^^^^^^^^^^^^^^ -By default, adminsortable's change form and change list views inherit -from Django admin's standard templates. Sometimes you need to have a -custom change form or change list, but also need adminsortable's CSS and +By default, adminsortable’s change form and change list views inherit +from Django admin’s standard templates. Sometimes you need to have a +custom change form or change list, but also need adminsortable’s CSS and JavaScript for inline models that are sortable for example. SortableAdmin has two attributes you can override for this use case: @@ -515,12 +515,12 @@ These attributes have default values of: .. code:: python - change_form_template_extends = 'admin/change_form.html' - change_list_template_extends = 'admin/change_list.html' + change_form_template_extends = 'admin/change_form.html' + change_list_template_extends = 'admin/change_list.html' -If you need to extend the inline change form templates, you'll need to +If you need to extend the inline change form templates, you’ll need to select the right one, depending on your version of Django. For Django -1.5.x or below, you'll need to extend one of the following: +1.5.x or below, you’ll need to extend one of the following: :: @@ -534,8 +534,8 @@ For Django 1.6.x, extend: templates/adminsortable/edit_inline/stacked.html templates/adminsortable/edit_inline/tabular.html -A Special Note About Stacked Inlines... -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +A Special Note About Stacked Inlines… +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The height of a stacked inline model can dynamically increase, which can make them difficult to sort. If you anticipate the height of a stacked @@ -545,7 +545,7 @@ SortableTabularInline instead. Django-CMS integration ~~~~~~~~~~~~~~~~~~~~~~ -Django-CMS plugins use their own change form, and thus won't +Django-CMS plugins use their own change form, and thus won’t automatically include the necessary JavaScript for django-admin-sortable to work. Fortunately, this is easy to resolve, as the ``CMSPlugin`` class allows a change form template to be specified: @@ -575,7 +575,7 @@ class allows a change form template to be specified: The contents of ``sortable-stacked-inline-change-form.html`` at a minimum need to extend the extrahead block with: -.. code:: html +.. code:: html+django {% extends "admin/cms/page/plugin_change_form.html" %} {% load static from staticfiles %} @@ -594,45 +594,45 @@ Sorting within Django-CMS is really only feasible for inline models of a plugin as Django-CMS already includes sorting for plugin instances. For tabular inlines, just substitute: -.. code:: html +.. code:: html+django - + with: -.. code:: html +.. code:: html+django - + Notes ~~~~~ -From ``django-cms 3.x`` the path of change\_form.html has changed. +From ``django-cms 3.x`` the path of change_form.html has changed. Replace the follwing line: -.. code:: html +.. code:: html+django - {% extends "admin/cms/page/plugin_change_form.html" %} + {% extends "admin/cms/page/plugin_change_form.html" %} with -.. code:: html +.. code:: html+django - {% extends "admin/cms/page/plugin/change_form.html" %} + {% extends "admin/cms/page/plugin/change_form.html" %} From ``django-admin-sortable 2.0.13`` the ``jquery.django-csrf.js`` was removed and you have to include the snippet-template. Change the following line: -.. code:: html +.. code:: html+django - + to -.. code:: html +.. code:: html+django - {% include 'adminsortable/csrf/jquery.django-csrf.html' with csrf_cookie_name='csrftoken' %} + {% include 'adminsortable/csrf/jquery.django-csrf.html' with csrf_cookie_name='csrftoken' %} Please note, if you change the ``CSRF_COOKIE_NAME`` you have to adjust ``csrf_cookie_name='YOUR_CSRF_COOKIE_NAME'`` @@ -641,7 +641,7 @@ Rationale ~~~~~~~~~ Other projects have added drag-and-drop ordering to the ChangeList view, -however this introduces a couple of problems... +however this introduces a couple of problems… - The ChangeList view supports pagination, which makes drag-and-drop ordering across pages impossible. @@ -657,10 +657,12 @@ Status django-admin-sortable is currently used in production. -What's new in 2.1.2? +What’s new in 2.1.3? ~~~~~~~~~~~~~~~~~~~~ -- Django 2 compatibility +- Norwegian and Latvian translations. Credit to + `simenheg `__ and + `peterisb `__ respectively. Future ~~~~~~ @@ -678,5 +680,5 @@ django-admin-sortable is released under the Apache Public License v2. :target: https://pypi.python.org/pypi/django-admin-sortable .. |Python versions| image:: https://img.shields.io/pypi/pyversions/django-admin-sortable.svg :target: https://pypi.python.org/pypi/django-admin-sortable -.. |Build Status| image:: https://travis-ci.org/iambrandontaylor/django-admin-sortable.svg?branch=master - :target: https://travis-ci.org/iambrandontaylor/django-admin-sortable +.. |Build Status| image:: https://travis-ci.org/alsoicode/django-admin-sortable.svg?branch=master + :target: https://travis-ci.org/alsoicode/django-admin-sortable diff --git a/adminsortable/__init__.py b/adminsortable/__init__.py index 22f864f..488e144 100644 --- a/adminsortable/__init__.py +++ b/adminsortable/__init__.py @@ -1,4 +1,4 @@ -VERSION = (2, 1, 2) +VERSION = (2, 1, 3) DEV_N = None From 108ef6dd18c32860b2bce4d8e559fa75ace35dd3 Mon Sep 17 00:00:00 2001 From: Tai Lee Date: Tue, 13 Mar 2018 23:05:35 +1100 Subject: [PATCH 44/49] Improve performance of sort view for moods and elements. * Use `{% include "..." with ... %}` instead of template tags that do nothing but pass through or rename context variables and render a template. This appears to yield a 2x increase in performance. As a side effect, this change also appears to fix some glitches with the rendering of `fa-sort`, `fa-sort-asc` and `fa-sort-desc` icons. * Move queryset filtering from `sort_view()` to new `get_sort_view_queryset()` method, so subclasses can override to apply different or additional filtering (based on `request` and `sortable_by_expression`) to reduce the number of objects being reordered. `django-admin-sortable` already provides a mechanism to reorder a subset of objects via `sorting_filters`, but this is restricted to a small number of hard coded filters, and we found it not very useful. We have tens of thousands of nested objects grouped under hundreds or thousands of parent objects, and we needed a way to reorder child objects just within their own group. We also needed a way to reorder a subset of flat (not grouped by parent) sortable objects with much more flexibility. Here's an example of additional filtering that allows us to reorder a contiguous sequence of objects (nested or flat) that bounded by the min and max (by ordering) selected objects: ```python class MyBaseSortableAdmin(SortableAdmin): def get_sort_view_queryset(self, request, sortable_by_expression): """ Filter the sort view queryset to include only a contiguous sequence of objects between the first and last of given parent objects, according to the current ordering. This should avoid inconsistent or ambiguous behaviour that might occur when re-ordering a non-contiguous sequence. """ sortable_by_expression = sortable_by_expression or 'pk' queryset = super(MyBaseSortableAdmin, self) \ .get_sort_view_queryset(request, sortable_by_expression) pks = [ int(pk) for pk in request.GET.get('pks', '').split(',') if pk ] if pks: queryset = queryset.filter(**{ '%s__in' % sortable_by_expression: pks, }) return queryset def reorder_children(self, qs, child): # Get the min and max order field value for the selected objects, then # get contiguous PKs for objects between the min and max and pass to # the sort view, to avoid inconsistent or ambiguous behaviour. field = self.opts.ordering[0].replace('-', '') qs = qs.model.objects.filter(**qs.aggregate(**{ '%s__gte' % field: Min(field), '%s__lte' % field: Max(field), })) ct = ContentType.objects.get_for_model(child) url = '%ssort/?pks=%s' % ( reverse('admin:%s_%s_changelist' % (ct.app_label, ct.model)), ','.join([str(pk) for pk in qs.values_list('pk', flat=True)]), ) return http.HttpResponseRedirect(url) class MyModelAdmin(MyBaseSortableAdmin): actions = ( "reorder_mymodel", "reorder_childmodel", ) def reorder_mymodel(self, request, qs): return self.reorder_children(qs, MyModel) reorder_chapters.short_description = 'Reorder selected MyModels' def reorder_childmodel(self, request, qs): return self.reorder_children(qs, ChildModel) reorder_elements.short_description = 'Reorder ChildModels for the selected MyModels' ``` This could be made generic enough for inclusion by default with a few tweaks, so that `Reorder selected {{ parent.verbose_name_plural }}` and `Reorder {{ child.verbose_name_plural }} for selected {{ parent.verbose_name_plural }}` admin actions could be included in sortable change lists. --- adminsortable/admin.py | 33 +++++++++++-------- .../templates/adminsortable/change_list.html | 6 ++-- .../adminsortable/shared/list_items.html | 3 +- .../adminsortable/shared/nested_objects.html | 6 ++-- .../adminsortable/shared/object_rep.html | 2 +- .../adminsortable/shared/objects.html | 4 +-- .../templatetags/adminsortable_tags.py | 32 ------------------ 7 files changed, 29 insertions(+), 57 deletions(-) delete mode 100644 adminsortable/templatetags/adminsortable_tags.py diff --git a/adminsortable/admin.py b/adminsortable/admin.py index 539d2b1..648c466 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -102,6 +102,24 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): ] + urls return urls + def get_sort_view_queryset(self, request, sortable_by_expression): + """ + Return a queryset, optionally filtered based on request and + `sortable_by_expression` to be used in the sort view. + """ + # get sort group index from querystring if present + sort_filter_index = request.GET.get('sort_filter') + + filters = {} + if sort_filter_index: + try: + filters = self.model.sorting_filters[int(sort_filter_index)][1] + except (IndexError, ValueError): + pass + + # Apply any sort filters to create a subset of sortable objects + return self.get_queryset(request).filter(**filters) + def sort_view(self, request): """ Custom admin view that displays the objects as a list whose sort @@ -115,19 +133,6 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): jquery_lib_path = 'admin/js/jquery.js' if VERSION < (1, 9) \ else 'admin/js/vendor/jquery/jquery.js' - # get sort group index from querystring if present - sort_filter_index = request.GET.get('sort_filter') - - filters = {} - if sort_filter_index: - try: - filters = self.model.sorting_filters[int(sort_filter_index)][1] - except (IndexError, ValueError): - pass - - # Apply any sort filters to create a subset of sortable objects - objects = self.get_queryset(request).filter(**filters) - # Determine if we need to regroup objects relative to a # foreign key specified on the model class that is extending Sortable. # Legacy support for 'sortable_by' defined as a model property @@ -175,6 +180,8 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): sortable_by_class_display_name = \ sortable_by_class_is_sortable = None + objects = self.get_sort_view_queryset(request, sortable_by_expression) + if sortable_by_property or sortable_by_fk: # Order the objects by the property they are sortable by, # then by the order, otherwise the regroup diff --git a/adminsortable/templates/adminsortable/change_list.html b/adminsortable/templates/adminsortable/change_list.html index 749d830..0dcbbf2 100644 --- a/adminsortable/templates/adminsortable/change_list.html +++ b/adminsortable/templates/adminsortable/change_list.html @@ -1,5 +1,5 @@ {% extends "admin/base_site.html" %} -{% load i18n admin_urls static admin_list adminsortable_tags %} +{% load i18n admin_urls static admin_list %} {% block extrastyle %} {{ block.super }} @@ -86,9 +86,9 @@ {% if objects %}

diff --git a/adminsortable/templates/adminsortable/shared/list_items.html b/adminsortable/templates/adminsortable/shared/list_items.html index 29df030..21f9005 100644 --- a/adminsortable/templates/adminsortable/shared/list_items.html +++ b/adminsortable/templates/adminsortable/shared/list_items.html @@ -1,9 +1,8 @@ -{% load adminsortable_tags %} {% with list_objects_length=list_objects|length %} {% for object in list_objects %}
  • {% if list_objects_length > 1 %} - {% render_object_rep object forloop %} + {% include "adminsortable/shared/object_rep.html" %} {% else %} {{ object }} {% endif %} diff --git a/adminsortable/templates/adminsortable/shared/nested_objects.html b/adminsortable/templates/adminsortable/shared/nested_objects.html index 8ef74d9..cf0483b 100644 --- a/adminsortable/templates/adminsortable/shared/nested_objects.html +++ b/adminsortable/templates/adminsortable/shared/nested_objects.html @@ -1,4 +1,4 @@ -{% load django_template_additions adminsortable_tags %} +{% load django_template_additions %} {% dynamic_regroup objects by group_expression as regrouped_objects %} {% if regrouped_objects %}