Removed un-needed properties on script tags for JS imports.

Refactored sorting filters from class method into a model property with a default of an empty dictionary.
Refactored sortable admin class to not make two calls to determine sortability and also to get objects for sorting.
Added sorting_filters to sortable admin queryset.
This commit is contained in:
Brandon Taylor
2014-02-05 11:06:15 -05:00
parent e51f7535ca
commit 3970105ce5
10 changed files with 35 additions and 37 deletions
+5 -1
View File
@@ -60,4 +60,8 @@ class ProjectAdmin(SortableAdmin):
admin.site.register(Project, ProjectAdmin)
admin.site.register(Person, SortableAdmin)
class PersonAdmin(SortableAdmin):
sortable_change_list_with_sort_link_template = 'app/person/admin/change_list_with_sort_link.html'
admin.site.register(Person, PersonAdmin)
+2 -4
View File
@@ -105,9 +105,7 @@ class Person(Sortable):
last_name = models.CharField(max_length=50)
is_board_member = models.BooleanField(default=False)
sorting_filters = {'is_board_member': True}
def __unicode__(self):
return '{} {}'.format(self.first_name, self.last_name)
@classmethod
def ordering_subset(cls):
return cls.objects.filter(is_board_member=True)
Binary file not shown.
+1 -1
View File
@@ -1,2 +1,2 @@
django==1.5.2
django==1.6.1
south==0.8.1
+1 -4
View File
@@ -109,10 +109,7 @@ ROOT_URLCONF = 'sample_project.urls'
WSGI_APPLICATION = 'sample_project.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or
# "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
map_path('templates'),
)
INSTALLED_APPS = (
@@ -0,0 +1,9 @@
{% extends change_list_template_extends %}
{% load i18n %}
{% block object-tools-items %}
<li>
<a href="./sort/">{% trans 'Change Order of Board Members' %}</a>
</li>
{{ block.super }}
{% endblock %}