Updated version to 1.3.2.

Updated status to stable/production.
Added AttributeError exception handling for models that specify a SortableForeignKey that does not inherit from Sortable.
Added template support for nested objects that are sortable by a foreign key, where the foreign key is not sortable.
master
Brandon Taylor 2012-06-07 09:38:36 -04:00
parent 7a000f1724
commit 484f00d263
7 changed files with 32 additions and 17 deletions

11
README
View File

@ -45,7 +45,8 @@ have an inner Meta class that inherits from ``Sortable.Meta``
return self.title
It is also possible to order objects relative to another object that is a ForeignKey:
It is also possible to order objects relative to another object that is a ForeignKey,
even if that model does not inherit from Sortable:
from adminsortable.fields import SortableForeignKey
@ -129,16 +130,16 @@ Status
admin-sortable is currently used in production.
What's new in 1.3
What's new in 1.3.2
=============
- Refactored ``sortable_by`` to subclass ForeignKey rather than a property or classmethod.
No more extra property hackishness.
- Fixed an issue that prevented sorting on classes that specified a SortableForeignKey
class, where the SortableForeignKey model itself did not inherit from Sortable.
Features
=============
Current
---------
- Supports Django 1.3+
- Supports Django 1.4+
- Adds an admin view to any model that inherits from Sortable and SortableAdmin
that allows you to drag and drop objects into any order via jQueryUI.
- Adds drag and drop ordering to Tabular and Stacked Inline models that inherit from

View File

@ -1,4 +1,4 @@
VERSION = (1, 3, 1) # following PEP 386
VERSION = (1, 3, 2) # following PEP 386
DEV_N = None

View File

@ -59,7 +59,6 @@ class SortableAdmin(ModelAdmin):
changed via drag-and-drop.
"""
opts = self.model._meta
admin_site = self.admin_site
has_perm = request.user.has_perm(opts.app_label + '.' + opts.get_change_permission())
objects = self.model.objects.all()
@ -87,7 +86,10 @@ class SortableAdmin(ModelAdmin):
sortable_by_class_display_name = sortable_by_fk.rel.to._meta.verbose_name_plural
sortable_by_class = sortable_by_fk.rel.to
sortable_by_expression = sortable_by_fk.name.lower()
sortable_by_class_is_sortable = sortable_by_class.is_sortable()
try:
sortable_by_class_is_sortable = sortable_by_class.is_sortable()
except AttributeError:
sortable_by_class_is_sortable = False
else:
#model is not sortable by another model

View File

@ -1,6 +1,12 @@
{% load adminsortable_tags %}
{% for object in list_objects %}
<li>
{% render_object_rep object %}
</li>
{% endfor %}
{% with list_objects_length=list_objects|length %}
{% for object in list_objects %}
<li>
{% if list_objects_length > 1 %}
{% render_object_rep object %}
{% else %}
{{ object }}
{% endif %}
</li>
{% endfor %}
{% endwith %}

View File

@ -5,12 +5,18 @@
{% for regrouped_object in regrouped_objects %}
<li>
{% with object=regrouped_object.grouper %}
{% render_object_rep object %}
{% if sortable_by_class_is_sortable %}
{% render_object_rep object %}
{% else %}
{{ object }}
{% endif %}
{% endwith %}
{% if regrouped_object.list %}
<ul {% if regrouped_object.grouper.is_sortable %}class="sortable"{% endif %}>
{% with regrouped_object_list_length=regrouped_object.list|length %}
<ul {% if regrouped_object_list_length > 1 %}class="sortable"{% endif %}>
{% render_list_items regrouped_object.list %}
</ul>
{% endwith %}
{% endif %}
</li>
{% endfor %}

View File

@ -8,7 +8,7 @@ from django.test import TestCase
from django.test.client import Client, RequestFactory
from adminsortable.fields import SortableForeignKey
from adminsortable.models import Sortable, MultipleSortableForeignKeyException
from adminsortable.models import Sortable
from app.models import Category, Credit, Note

View File

@ -17,7 +17,7 @@ setup(
packages=find_packages(exclude=['sample_project']),
zip_safe=False,
include_package_data=True,
classifiers=['Development Status :: 4 - Beta',
classifiers=['Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',