Merge branch 'master' into develop
commit
54482b3bb3
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[](https://travis-ci.org/iambrandontaylor/django-admin-sortable)
|
[](https://travis-ci.org/iambrandontaylor/django-admin-sortable)
|
||||||
|
|
||||||
Current version: 2.0.15
|
Current version: 2.0.16
|
||||||
|
|
||||||
This project makes it easy to add drag-and-drop ordering to any model in
|
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,
|
Django admin. Inlines for a sortable model may also be made sortable,
|
||||||
|
|
@ -496,8 +496,11 @@ ordering on top of that just seemed a little much in my opinion.
|
||||||
### Status
|
### Status
|
||||||
django-admin-sortable is currently used in production.
|
django-admin-sortable is currently used in production.
|
||||||
|
|
||||||
### What's new in 2.0.15?
|
### What's new in 2.0.16?
|
||||||
- Refactored exception handling when determining `order_field_name`
|
- Simplification of admin url patterns
|
||||||
|
- Fixes for sortable lists when using Django CMS
|
||||||
|
|
||||||
|
Thanks to [@vstoykov](https://github.com/vstoykov) for both contributions.
|
||||||
|
|
||||||
### Future
|
### 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.
|
- Better template support for foreign keys that are self referential. If someone would like to take on rendering recursive sortables, that would be super.
|
||||||
|
|
|
||||||
13
README.rst
13
README.rst
|
|
@ -3,7 +3,7 @@ Django Admin Sortable
|
||||||
|
|
||||||
|Build Status|
|
|Build Status|
|
||||||
|
|
||||||
Current version: 2.0.15
|
Current version: 2.0.16
|
||||||
|
|
||||||
This project makes it easy to add drag-and-drop ordering to any model in
|
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,
|
Django admin. Inlines for a sortable model may also be made sortable,
|
||||||
|
|
@ -50,7 +50,7 @@ Download django-admin-sortable from
|
||||||
`source <https://github.com/iambrandontaylor/django-admin-sortable/archive/master.zip>`__
|
`source <https://github.com/iambrandontaylor/django-admin-sortable/archive/master.zip>`__
|
||||||
|
|
||||||
1. Unzip the directory and cd into the uncompressed project directory
|
1. Unzip the directory and cd into the uncompressed project directory
|
||||||
2.
|
2.
|
||||||
|
|
||||||
- Optional: Enable your virtualenv
|
- Optional: Enable your virtualenv
|
||||||
|
|
||||||
|
|
@ -611,11 +611,14 @@ Status
|
||||||
|
|
||||||
django-admin-sortable is currently used in production.
|
django-admin-sortable is currently used in production.
|
||||||
|
|
||||||
|
What's new in 2.0.16?
|
||||||
What's new in 2.0.15?
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
- Refactored exception handling when determining ``order_field_name``
|
- Simplification of admin url patterns
|
||||||
|
- Fixes for sortable lists when using Django CMS
|
||||||
|
|
||||||
|
Thanks to [@vstoykov](https://github.com/vstoykov) for both
|
||||||
|
contributions.
|
||||||
|
|
||||||
Future
|
Future
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
VERSION = (2, 0, 15)
|
VERSION = (2, 0, 16)
|
||||||
DEV_N = None
|
DEV_N = None
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
version = '{0}.{1}'.format(VERSION[0], VERSION[1])
|
version = '{0}.{1}'.format(VERSION[0], VERSION[1])
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,22 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_sortable_tabular_inlines(self):
|
||||||
|
base_classes = (SortableTabularInline, SortableGenericTabularInline)
|
||||||
|
return any(issubclass(klass, base_classes) for klass in self.inlines)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_sortable_stacked_inlines(self):
|
||||||
|
base_classes = (SortableStackedInline, SortableGenericStackedInline)
|
||||||
|
return any(issubclass(klass, base_classes) for klass in self.inlines)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def change_form_template(self):
|
||||||
|
if self.has_sortable_tabular_inlines or self.has_sortable_stacked_inlines:
|
||||||
|
return self.sortable_change_form_template
|
||||||
|
return super(SortableAdmin, self).change_form_template
|
||||||
|
|
||||||
def get_urls(self):
|
def get_urls(self):
|
||||||
urls = super(SortableAdmin, self).get_urls()
|
urls = super(SortableAdmin, self).get_urls()
|
||||||
|
|
||||||
|
|
@ -224,37 +240,17 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
|
||||||
extra_context=extra_context)
|
extra_context=extra_context)
|
||||||
|
|
||||||
def change_view(self, request, object_id, form_url='', extra_context=None):
|
def change_view(self, request, object_id, form_url='', extra_context=None):
|
||||||
self.has_sortable_tabular_inlines = False
|
|
||||||
self.has_sortable_stacked_inlines = False
|
|
||||||
|
|
||||||
if extra_context is None:
|
if extra_context is None:
|
||||||
extra_context = {}
|
extra_context = {}
|
||||||
|
|
||||||
extra_context.update({
|
extra_context.update({
|
||||||
'change_form_template_extends': self.change_form_template_extends,
|
'change_form_template_extends': self.change_form_template_extends,
|
||||||
|
'has_sortable_tabular_inlines': self.has_sortable_tabular_inlines,
|
||||||
|
'has_sortable_stacked_inlines': self.has_sortable_stacked_inlines,
|
||||||
'csrf_cookie_name': getattr(settings, 'CSRF_COOKIE_NAME', 'csrftoken')
|
'csrf_cookie_name': getattr(settings, 'CSRF_COOKIE_NAME', 'csrftoken')
|
||||||
})
|
})
|
||||||
|
|
||||||
for klass in self.inlines:
|
|
||||||
if issubclass(klass, SortableTabularInline) or issubclass(klass,
|
|
||||||
SortableGenericTabularInline):
|
|
||||||
self.has_sortable_tabular_inlines = True
|
|
||||||
if issubclass(klass, SortableStackedInline) or issubclass(klass,
|
|
||||||
SortableGenericStackedInline):
|
|
||||||
self.has_sortable_stacked_inlines = True
|
|
||||||
|
|
||||||
if self.has_sortable_tabular_inlines or \
|
|
||||||
self.has_sortable_stacked_inlines:
|
|
||||||
|
|
||||||
self.change_form_template = self.sortable_change_form_template
|
|
||||||
|
|
||||||
extra_context.update({
|
|
||||||
'has_sortable_tabular_inlines':
|
|
||||||
self.has_sortable_tabular_inlines,
|
|
||||||
'has_sortable_stacked_inlines':
|
|
||||||
self.has_sortable_stacked_inlines
|
|
||||||
})
|
|
||||||
|
|
||||||
return super(SortableAdmin, self).change_view(request, object_id,
|
return super(SortableAdmin, self).change_view(request, object_id,
|
||||||
form_url='', extra_context=extra_context)
|
form_url='', extra_context=extra_context)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
{% for field in line %}
|
{% for field in line %}
|
||||||
<div{% if not line.fields|length_is:'1' %} class="field-box{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %}"{% elif field.is_checkbox %} class="checkbox-row"{% endif %}>
|
<div{% if not line.fields|length_is:'1' %} class="field-box{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %}"{% elif field.is_checkbox %} class="checkbox-row"{% endif %}>
|
||||||
{% if not line.fields|length_is:'1' and not field.is_readonly %}{{ field.errors }}{% endif %}
|
{% if not line.fields|length_is:'1' and not field.is_readonly %}{{ field.errors }}{% endif %}
|
||||||
{% if forloop.first %}
|
{% if forloop.parentloop.first %}
|
||||||
{% if inline_admin_form_forloop.counter <= initial_forms_count %}
|
{% if inline_admin_form_forloop.counter <= initial_forms_count %}
|
||||||
<i class="fa fa-{% if inline_admin_form_forloop.first %}sort-desc{% elif inline_admin_form_forloop.counter == initial_forms_count %}sort-asc{% else %}sort{% endif %}"></i>
|
<i class="fa fa-{% if inline_admin_form_forloop.first %}sort-desc{% elif inline_admin_form_forloop.counter == initial_forms_count %}sort-asc{% else %}sort{% endif %}"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue