Merge branch 'master' into develop

This commit is contained in:
Brandon Taylor
2016-06-23 21:48:45 -04:00
5 changed files with 36 additions and 34 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
VERSION = (2, 0, 15)
DEV_N = None
VERSION = (2, 0, 16)
DEV_N = None
def get_version():
version = '{0}.{1}'.format(VERSION[0], VERSION[1])
+18 -22
View File
@@ -80,6 +80,22 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
class Meta:
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):
urls = super(SortableAdmin, self).get_urls()
@@ -224,37 +240,17 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
extra_context=extra_context)
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:
extra_context = {}
extra_context.update({
'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')
})
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,
form_url='', extra_context=extra_context)
@@ -10,7 +10,7 @@
{% 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 %}>
{% 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 %}
<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 %}