X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/537012c60af1ea1c0e39949c58df4647ddadc72b..02a98d2af6f1fabf567b575c5f2d818688af1594:/apps/toolbar/management/commands/fixbuttons.py?ds=sidebyside diff --git a/apps/toolbar/management/commands/fixbuttons.py b/apps/toolbar/management/commands/fixbuttons.py old mode 100755 new mode 100644 index 627ef25d..7a49b37a --- a/apps/toolbar/management/commands/fixbuttons.py +++ b/apps/toolbar/management/commands/fixbuttons.py @@ -1,8 +1,13 @@ -# -*- conding: utf-8 +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# __author__="lreqc" __date__ ="$2009-09-08 14:31:26$" from django.core.management.base import NoArgsCommand -from toolbar.models import Button +from toolbar.models import Button, ButtonGroup from django.utils import simplejson as json import re @@ -55,4 +60,14 @@ class Command(NoArgsCommand): b.group.clear() a.save() - b.delete() + if remove_duplicate: + b.delete() + + print "Searching for empty groups and orphaned buttons:" + for g in ButtonGroup.objects.all(): + if len(g.button_set.all()) == 0: + print "Empty group: '%s'" % g.slug + + for b in Button.objects.all(): + if len(b.group.all()) == 0: + print "orphan: '%s'" % b.slug