mirror of
https://github.com/jazzband/django-categories.git
synced 2026-03-16 22:30:24 +00:00
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:
parent
11481dbdcf
commit
416898d2a5
1 changed files with 8 additions and 4 deletions
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Reference in a new issue