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
parent
7a000f1724
commit
484f00d263
11
README
11
README
|
|
@ -45,7 +45,8 @@ have an inner Meta class that inherits from ``Sortable.Meta``
|
||||||
return self.title
|
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
|
from adminsortable.fields import SortableForeignKey
|
||||||
|
|
||||||
|
|
@ -129,16 +130,16 @@ Status
|
||||||
admin-sortable is currently used in production.
|
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.
|
- Fixed an issue that prevented sorting on classes that specified a SortableForeignKey
|
||||||
No more extra property hackishness.
|
class, where the SortableForeignKey model itself did not inherit from Sortable.
|
||||||
|
|
||||||
Features
|
Features
|
||||||
=============
|
=============
|
||||||
Current
|
Current
|
||||||
---------
|
---------
|
||||||
- Supports Django 1.3+
|
- Supports Django 1.4+
|
||||||
- Adds an admin view to any model that inherits from Sortable and SortableAdmin
|
- 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.
|
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
|
- Adds drag and drop ordering to Tabular and Stacked Inline models that inherit from
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
VERSION = (1, 3, 1) # following PEP 386
|
VERSION = (1, 3, 2) # following PEP 386
|
||||||
DEV_N = None
|
DEV_N = None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@ class SortableAdmin(ModelAdmin):
|
||||||
changed via drag-and-drop.
|
changed via drag-and-drop.
|
||||||
"""
|
"""
|
||||||
opts = self.model._meta
|
opts = self.model._meta
|
||||||
admin_site = self.admin_site
|
|
||||||
has_perm = request.user.has_perm(opts.app_label + '.' + opts.get_change_permission())
|
has_perm = request.user.has_perm(opts.app_label + '.' + opts.get_change_permission())
|
||||||
objects = self.model.objects.all()
|
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_display_name = sortable_by_fk.rel.to._meta.verbose_name_plural
|
||||||
sortable_by_class = sortable_by_fk.rel.to
|
sortable_by_class = sortable_by_fk.rel.to
|
||||||
sortable_by_expression = sortable_by_fk.name.lower()
|
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:
|
else:
|
||||||
#model is not sortable by another model
|
#model is not sortable by another model
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
{% load adminsortable_tags %}
|
{% load adminsortable_tags %}
|
||||||
{% for object in list_objects %}
|
{% with list_objects_length=list_objects|length %}
|
||||||
<li>
|
{% for object in list_objects %}
|
||||||
{% render_object_rep object %}
|
<li>
|
||||||
</li>
|
{% if list_objects_length > 1 %}
|
||||||
{% endfor %}
|
{% render_object_rep object %}
|
||||||
|
{% else %}
|
||||||
|
{{ object }}
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
{% endwith %}
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,18 @@
|
||||||
{% for regrouped_object in regrouped_objects %}
|
{% for regrouped_object in regrouped_objects %}
|
||||||
<li>
|
<li>
|
||||||
{% with object=regrouped_object.grouper %}
|
{% with object=regrouped_object.grouper %}
|
||||||
{% render_object_rep object %}
|
{% if sortable_by_class_is_sortable %}
|
||||||
|
{% render_object_rep object %}
|
||||||
|
{% else %}
|
||||||
|
{{ object }}
|
||||||
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% if regrouped_object.list %}
|
{% 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 %}
|
{% render_list_items regrouped_object.list %}
|
||||||
</ul>
|
</ul>
|
||||||
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from django.test import TestCase
|
||||||
from django.test.client import Client, RequestFactory
|
from django.test.client import Client, RequestFactory
|
||||||
|
|
||||||
from adminsortable.fields import SortableForeignKey
|
from adminsortable.fields import SortableForeignKey
|
||||||
from adminsortable.models import Sortable, MultipleSortableForeignKeyException
|
from adminsortable.models import Sortable
|
||||||
from app.models import Category, Credit, Note
|
from app.models import Category, Credit, Note
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -17,7 +17,7 @@ setup(
|
||||||
packages=find_packages(exclude=['sample_project']),
|
packages=find_packages(exclude=['sample_project']),
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
classifiers=['Development Status :: 4 - Beta',
|
classifiers=['Development Status :: 5 - Production/Stable',
|
||||||
'Environment :: Web Environment',
|
'Environment :: Web Environment',
|
||||||
'Framework :: Django',
|
'Framework :: Django',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue