mirror of
https://github.com/jazzband/django-categories.git
synced 2026-04-28 10:44:52 +00:00
Merge branch '0.8.3'
This commit is contained in:
commit
8e1c3ac347
2 changed files with 18 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
|||
__version_info__ = {
|
||||
'major': 0,
|
||||
'minor': 8,
|
||||
'micro': 2,
|
||||
'micro': 3,
|
||||
'releaselevel': 'final',
|
||||
'serial': 1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,25 +97,37 @@ class CategoryAdmin(TreeEditor, admin.ModelAdmin):
|
|||
)
|
||||
|
||||
actions = ['activate', 'deactivate']
|
||||
def get_actions(self, request):
|
||||
actions = super(CategoryAdmin, self).get_actions(request)
|
||||
if 'delete_selected' in actions:
|
||||
del actions['delete_selected']
|
||||
return actions
|
||||
|
||||
def deactivate(self, request, queryset):
|
||||
"""
|
||||
Set active to False for selected items
|
||||
"""
|
||||
for item in queryset:
|
||||
selected_cats = Category.objects.filter(
|
||||
pk__in=[int(x) for x in request.POST.getlist('_selected_action')])
|
||||
|
||||
for item in selected_cats:
|
||||
if item.active:
|
||||
item.active = False
|
||||
item.save()
|
||||
item.children.all().update(active=False)
|
||||
deactivate.short_description = "Deactivate selected categories and their children"
|
||||
|
||||
def activate(self, request, queryset):
|
||||
"""
|
||||
Set active to True for selected items
|
||||
"""
|
||||
for item in queryset:
|
||||
if not item.active:
|
||||
item.active = True
|
||||
item.save()
|
||||
selected_cats = Category.objects.filter(
|
||||
pk__in=[int(x) for x in request.POST.getlist('_selected_action')])
|
||||
|
||||
for item in selected_cats:
|
||||
item.active = True
|
||||
item.save()
|
||||
item.children.all().update(active=True)
|
||||
activate.short_description = "Activate selected categories and their children"
|
||||
|
||||
if RELATION_MODELS:
|
||||
|
|
|
|||
Loading…
Reference in a new issue