def load_site_config(): """Sets up the SiteConfiguration, provides defaults and syncs settings.""" try: siteconfig = SiteConfiguration.objects.get_current() except SiteConfiguration.DoesNotExist: # Either warn or just create the thing. Depends on your app siteconfig = SiteConfiguration(site=Site.objects.get_current(), version="1.0") siteconfig.save() if not siteconfig.get_defaults(): siteconfig.add_defaults(defaults) apply_django_settings(siteconfig, settings_map) return siteconfig
def load_site_config(): """Set up the SiteConfiguration, provide defaults and sync settings.""" try: siteconfig = SiteConfiguration.objects.get_current() except SiteConfiguration.DoesNotExist: # Either warn or just create the thing. Depends on your app. siteconfig = SiteConfiguration(site=Site.objects.get_current(), version="1.0") siteconfig.save() # If TITLE and DESCRIPTION are not on the database then pick the defaults # from the settings and save them in the database. if not siteconfig.get_defaults(): SETTINGS_MAP = { # siteconfig key settings.py key 'DESCRIPTION': 'DESCRIPTION', 'TITLE': 'TITLE', } siteconfig.add_defaults(generate_defaults(SETTINGS_MAP)) return siteconfig
def load_site_config(): """Set up the SiteConfiguration, provide defaults and sync settings.""" try: siteconfig = SiteConfiguration.objects.get_current() except SiteConfiguration.DoesNotExist: siteconfig = SiteConfiguration(site=Site.objects.get_current(), version="1.0") siteconfig.save() # If TITLE and DESCRIPTION are not on the database then pick the defaults # from the settings and save them in the database. if not siteconfig.get_defaults(): from django.conf import settings defaults = {} for setting_name in ('DESCRIPTION', 'TITLE'): if hasattr(settings, setting_name): defaults[setting_name] = getattr(settings, setting_name) siteconfig.add_defaults(defaults) return siteconfig
def setUp(self): self.siteconfig = SiteConfiguration(site=Site.objects.get_current()) self.siteconfig.save()
def setUp(self): super(SiteConfigTestCase, self).setUp() self.siteconfig = SiteConfiguration(site=Site.objects.get_current()) self.siteconfig.save()