Skip to content

Commit

Permalink
Merge pull request #158 from jrief/mtribaldos-not-first-sortable-column
Browse files Browse the repository at this point in the history
Mtribaldos not first sortable column
  • Loading branch information
jrief committed Jun 1, 2017
2 parents a9e7ae9 + c1b1095 commit 482f84a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
6 changes: 5 additions & 1 deletion adminsortable2/admin.py
Expand Up @@ -4,6 +4,8 @@
import os
import json

from re import sub

from types import MethodType

from django import forms
Expand Down Expand Up @@ -106,7 +108,9 @@ def __init__(self, model, admin_site):
if not self.list_display_links:
self.list_display_links = (self.list_display[0],)
self._add_reorder_method()
self.list_display = ['_reorder'] + list(self.list_display)
self.list_display = [sub(r'^%s$' % self.default_order_field, '_reorder', e) for e in self.list_display]
if '_reorder' not in self.list_display:
self.list_display = ['_reorder'] + list(self.list_display)

def _get_update_url_name(self):
return '%s_%s_sortable_update' % (self.model._meta.app_label, self.model._meta.model_name)
Expand Down
5 changes: 4 additions & 1 deletion docs/source/changelog.rst
Expand Up @@ -4,10 +4,13 @@
Release history
===============

0.6.12
------
* Fixes #155: Sortable column not the first field.

0.6.11
------
* Fixes Issue #147: Use current admin site name instead of 'admin'.
* Fixes #147: Use current admin site name instead of 'admin'.
* Fixes #122: Columns expand continuously with each sort.

0.6.9 and 0.6.10
Expand Down
5 changes: 4 additions & 1 deletion docs/source/usage.rst
Expand Up @@ -96,10 +96,13 @@ mixin class before model.ModelAdmin):
class MyModelAdmin(SortableAdminMixin, admin.ModelAdmin):
pass
That's it! The list view of the model admin interface now adds a column with a sensitive area.
That's it! The list view of the model admin interface now adds a column with a draggable area.
By clicking on that area, the user can move that row up or down. If he wants to move it to another
page, he can do that as a bulk operation, using the admin actions.

By default the draggable area is positioned on the first column. If it shall be placed somewhere else,
add the ordering field name explicitly to the attribute ``list_display``.


Overriding change list page
...........................
Expand Down
14 changes: 10 additions & 4 deletions setup.py
Expand Up @@ -17,17 +17,23 @@ def convert(filename, fmt):

CLASSIFIERS = [
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
'Development Status :: 4 - Beta',
'Programming Language :: Python :: 2',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Development Status :: 5 - Production/Stable',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Framework :: Django',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
]


Expand Down

0 comments on commit 482f84a

Please sign in to comment.