26
26
print "Adding content type '%s | %s'" % (ct.app_label, ct.model)
27
27
# The presence of any remaining content types means the supplied app has an
28
# undefined model and can safely be removed, which cascades to also remove
29
# related permissions.
30
for ct in content_types:
32
print "Deleting stale content type '%s | %s'" % (ct.app_label, ct.model)
35
def update_all_contenttypes(verbosity=2):
28
# undefined model. Confirm that the content type is stale before deletion.
30
if kwargs.get('interactive', False):
31
content_type_display = '\n'.join([' %s | %s' % (ct.app_label, ct.model) for ct in content_types])
32
ok_to_delete = raw_input("""The following content types are stale and need to be deleted:
36
Any objects related to these content types by a foreign key will also
37
be deleted. Are you sure you want to delete these content types?
38
If you're unsure, answer 'no'.
40
Type 'yes' to continue, or 'no' to cancel: """ % content_type_display)
44
if ok_to_delete == 'yes':
45
for ct in content_types:
47
print "Deleting stale content type '%s | %s'" % (ct.app_label, ct.model)
51
print "Stale content types remain."
53
def update_all_contenttypes(verbosity=2, **kwargs):
36
54
for app in get_apps():
37
update_contenttypes(app, None, verbosity)
55
update_contenttypes(app, None, verbosity, **kwargs)
39
57
signals.post_syncdb.connect(update_contenttypes)