def handle_noargs(self, **options): from django_wizard.autodiscover import autodiscover import django_wizard.wizard django_wizard.wizard.config_index = ConfigIndex() django_wizard.wizard.fixtures_index = FixtureIndex() autodiscover() options = django_wizard.wizard.config_index._registry.values() apps = list(set([option.app for option in options])) def output(value): if value.__class__ in [str, unicode]: return """'%s'""" % (value) else: return str(value) for app in apps: app_module = __import__(app) app_dir = os.path.dirname(app_module.__file__) config_file = open(os.path.join(app_dir, 'config.py'), 'w+') config_options = [option for option in options if option.app == app] for option in config_options: config_file.write("%s = %s" % (option.name, output(json.loads(option.default)))) config_file.write('\n')
def handle_noargs(self, **options): from django_wizard.autodiscover import autodiscover print "---Loading app configuration definitions---" autodiscover() print "---Creating configuration directory---" if not os.path.exists(os.path.join(settings.PROJECT_ROOT, 'django_wizard_configurations')): os.mkdir(os.path.join(settings.PROJECT_ROOT, 'django_wizard_configurations'))
def reset_configs(request): from django_wizard.autodiscover import autodiscover from django_wizard.wizard import config_index defined_configs = DefinedConfigOption.objects.all() for defined_config in defined_configs: defined_config.delete() configs = ConfigOption.objects.all() for config in configs: config.delete() config_index.clear_registry() autodiscover() return shortcuts.render_to_response('django_wizard/message.html', {'message':'Configuration have been reset to their default values.'}, context_instance = RequestContext(request))