Exemplo n.º 1
0
 def save(self, *args, **kwargs):
     try:
         #get the old value as reference for updating the cache
         orig = Setting.objects.get(pk = self.pk)
     except Setting.DoesNotExist:
         orig = None
         
     if self.name == 'theme':
         from theme.utils import theme_options
         self.input_value = theme_options()
         super(Setting, self).save(*args, **kwargs)
         call_command('touch_settings')
     else:
         super(Setting, self).save(*args, **kwargs)
     
     #update the cache when value has changed
     if orig and self.value != orig.value:
         from site_settings.utils import (delete_setting_cache,
             cache_setting, delete_all_settings_cache)
         from site_settings.cache import SETTING_PRE_KEY
         # delete the cache for all the settings to reset the context
         delete_all_settings_cache()
         # delete and set cache for single key and save the value in the database
         delete_setting_cache(self.scope, self.scope_category, self.name)
         cache_setting(self.scope, self.scope_category, self.name, self)
Exemplo n.º 2
0
 def handle(self, scope=None, scope_category=None, name=None, value=None, **options):
     """
     Set the website theme via theme name
     """
     from site_settings.models import Setting
     from site_settings.utils import delete_all_settings_cache
     
     if scope and scope_category and name and value:
         try:
             setting = Setting.objects.filter(
                 name=name,
                 scope=scope,
                 scope_category=scope_category,
             ).update(value=value)
         except:
             if int(options['verbosity']) > 0:
                 print "We could not update that setting."
         delete_all_settings_cache()