Changed behavior of (de)activating an item within the change form:

Instead of changing all descendants' active status to the current item's, it will only change the descendants' active status if the item is False.

As it makes sense to have an item active, but its children inactive, it doesn't make sense that an item is inactive, but its descendants are active.

This doesn't change the activate/deactivate admin actions. They will always  affect an item and its descendants.
This commit is contained in:
Corey Oordt 2012-01-04 23:53:50 -05:00
parent 11481dbdcf
commit 416898d2a5

View file

@ -107,10 +107,14 @@ class Category(MPTTModel):
super(Category, self).save(*args, **kwargs)
for item in self.get_descendants():
if item.active != self.active:
item.active = self.active
item.save()
# While you can activate an item without activating its descendants,
# It doesn't make sense that you can deactivate an item and have its
# decendants remain active.
if not self.active:
for item in self.get_descendants():
if item.active != self.active:
item.active = self.active
item.save()
class Meta:
verbose_name_plural = 'categories'