3 __date__ ="$2009-09-08 14:31:26$"
4 from django.core.management.base import NoArgsCommand
5 from toolbar.models import Button
6 from django.utils import simplejson as json
9 class Command(NoArgsCommand):
11 def handle_noargs(self, **options):
12 buttons = Button.objects.all()
13 print "Validating parameters... "
17 v = json.loads(b.params)
19 print 'Trying to fix button "%s" ...' % b.slug
22 if params[-1] == u')':
25 v = son.loads(re.sub(u'([\\w-]+)\\s*:', u'"\\1": ', params).encode('utf-8'))
27 print "Unable to fix '%s' " % b.params
28 print "Try to fix this button manually and rerun the script."
32 b.params = json.dumps(v)
35 print "Merge duplicate buttons (if any)..."
38 if b.slug not in hash:
43 print "Found duplicate of '%s'" % b.slug
46 remove_duplicate = True
47 if a.params != b.params:
48 print "Conflicting params for duplicate of '%s'." % b.slug
49 print "Groups will be joined, but won't remove duplicates."
50 remove_duplicate = False
52 for g in b.group.all():