summaryrefslogtreecommitdiffstats
path: root/forum/deps/livesettings
diff options
context:
space:
mode:
Diffstat (limited to 'forum/deps/livesettings')
-rw-r--r--forum/deps/livesettings/README4
-rw-r--r--forum/deps/livesettings/__init__.py16
-rw-r--r--forum/deps/livesettings/forms.py38
-rw-r--r--forum/deps/livesettings/functions.py247
-rw-r--r--forum/deps/livesettings/locale/de/LC_MESSAGES/django.mobin0 -> 706 bytes
-rw-r--r--forum/deps/livesettings/locale/de/LC_MESSAGES/django.po101
-rw-r--r--forum/deps/livesettings/locale/en/LC_MESSAGES/django.mobin0 -> 367 bytes
-rw-r--r--forum/deps/livesettings/locale/en/LC_MESSAGES/django.po100
-rw-r--r--forum/deps/livesettings/locale/es/LC_MESSAGES/django.po0
-rw-r--r--forum/deps/livesettings/locale/fr/LC_MESSAGES/django.mobin0 -> 1621 bytes
-rw-r--r--forum/deps/livesettings/locale/fr/LC_MESSAGES/django.po113
-rw-r--r--forum/deps/livesettings/locale/he/LC_MESSAGES/django.mobin0 -> 1655 bytes
-rw-r--r--forum/deps/livesettings/locale/he/LC_MESSAGES/django.po98
-rw-r--r--forum/deps/livesettings/locale/it/LC_MESSAGES/django.mobin0 -> 1582 bytes
-rw-r--r--forum/deps/livesettings/locale/it/LC_MESSAGES/django.po106
-rw-r--r--forum/deps/livesettings/locale/ko/LC_MESSAGES/django.mobin0 -> 1128 bytes
-rw-r--r--forum/deps/livesettings/locale/ko/LC_MESSAGES/django.po100
-rw-r--r--forum/deps/livesettings/locale/pl/LC_MESSAGES/django.mobin0 -> 1470 bytes
-rw-r--r--forum/deps/livesettings/locale/pl/LC_MESSAGES/django.po97
-rw-r--r--forum/deps/livesettings/locale/pt_BR/LC_MESSAGES/django.mobin0 -> 1208 bytes
-rw-r--r--forum/deps/livesettings/locale/pt_BR/LC_MESSAGES/django.po100
-rw-r--r--forum/deps/livesettings/locale/ru/LC_MESSAGES/django.mobin0 -> 1178 bytes
-rw-r--r--forum/deps/livesettings/locale/ru/LC_MESSAGES/django.po85
-rw-r--r--forum/deps/livesettings/locale/sv/LC_MESSAGES/django.mobin0 -> 1481 bytes
-rw-r--r--forum/deps/livesettings/locale/sv/LC_MESSAGES/django.po92
-rw-r--r--forum/deps/livesettings/locale/tr/LC_MESSAGES/django.mobin0 -> 1242 bytes
-rw-r--r--forum/deps/livesettings/locale/tr/LC_MESSAGES/django.po102
-rw-r--r--forum/deps/livesettings/models.py170
-rw-r--r--forum/deps/livesettings/overrides.py55
-rw-r--r--forum/deps/livesettings/signals.py3
-rw-r--r--forum/deps/livesettings/templates/livesettings/_admin_site_views.html15
-rw-r--r--forum/deps/livesettings/templates/livesettings/group_settings.html81
-rw-r--r--forum/deps/livesettings/templates/livesettings/site_settings.html101
-rw-r--r--forum/deps/livesettings/templates/livesettings/text.txt1
-rw-r--r--forum/deps/livesettings/templatetags/__init__.py0
-rw-r--r--forum/deps/livesettings/templatetags/config_tags.py91
-rw-r--r--forum/deps/livesettings/tests.py545
-rw-r--r--forum/deps/livesettings/urls.py7
-rw-r--r--forum/deps/livesettings/utils.py87
-rw-r--r--forum/deps/livesettings/values.py628
-rw-r--r--forum/deps/livesettings/views.py93
41 files changed, 3276 insertions, 0 deletions
diff --git a/forum/deps/livesettings/README b/forum/deps/livesettings/README
new file mode 100644
index 00000000..6fe70cc5
--- /dev/null
+++ b/forum/deps/livesettings/README
@@ -0,0 +1,4 @@
+this is very slightly forked version of django-livesettings
+for use in the askbot forum project
+
+will attempt to re-merge into the original django-livesettings
diff --git a/forum/deps/livesettings/__init__.py b/forum/deps/livesettings/__init__.py
new file mode 100644
index 00000000..49aaacc9
--- /dev/null
+++ b/forum/deps/livesettings/__init__.py
@@ -0,0 +1,16 @@
+"""Database persistent administrative settings with defaults.
+
+This code is a large fork of the excellent "dbsettings" code found at
+http://code.google.com/p/django-values/
+
+The items set here are intended to be changeable during runtime, and do not require a
+programmer to test or install.
+
+Appropriate: Your google code for adwords.
+Inappropriate: The keyedcache timeout for the store.
+
+"""
+
+from functions import *
+from models import *
+from values import * \ No newline at end of file
diff --git a/forum/deps/livesettings/forms.py b/forum/deps/livesettings/forms.py
new file mode 100644
index 00000000..f8d40895
--- /dev/null
+++ b/forum/deps/livesettings/forms.py
@@ -0,0 +1,38 @@
+from django import forms
+from forum.deps.livesettings import *
+import logging
+
+log = logging.getLogger('configuration')
+
+class SettingsEditor(forms.Form):
+ "Base editor, from which customized forms are created"
+
+ def __init__(self, *args, **kwargs):
+ settings = kwargs.pop('settings')
+ super(SettingsEditor, self).__init__(*args, **kwargs)
+ flattened = []
+ groups = []
+ for setting in settings:
+ if isinstance(setting, ConfigurationGroup):
+ for s in setting:
+ flattened.append(s)
+ else:
+ flattened.append(setting)
+
+ for setting in flattened:
+ # Add the field to the customized field list
+ kw = {
+ 'label': setting.description,
+ 'help_text': setting.help_text,
+ # Provide current setting values for initializing the form
+ 'initial': setting.editor_value
+ }
+ field = setting.make_field(**kw)
+
+ k = '%s__%s' % (setting.group.key, setting.key)
+ self.fields[k] = field
+ if not setting.group in groups:
+ groups.append(setting.group)
+ #log.debug("Added field: %s = %s" % (k, str(field)))
+
+ self.groups = groups \ No newline at end of file
diff --git a/forum/deps/livesettings/functions.py b/forum/deps/livesettings/functions.py
new file mode 100644
index 00000000..4c2073ea
--- /dev/null
+++ b/forum/deps/livesettings/functions.py
@@ -0,0 +1,247 @@
+from django.utils.translation import ugettext
+from forum.deps.livesettings import values
+from forum.deps.livesettings.models import SettingNotSet
+from forum.deps.livesettings.utils import is_string_like
+
+import logging
+
+log = logging.getLogger('configuration')
+
+_NOTSET = object()
+
+class ConfigurationSettings(object):
+ """A singleton manager for ConfigurationSettings"""
+
+ class __impl(object):
+ def __init__(self):
+ self.settings = values.SortedDotDict()
+ self.prereg = {}
+
+ def __getitem__(self, key):
+ """Get an element either by ConfigurationGroup object or by its key"""
+ key = self._resolve_key(key)
+ return self.settings.get(key)
+
+ def __getattr__(self, key):
+ """Get an element either by ConfigurationGroup object or by its key"""
+ try:
+ return self[key]
+ except:
+ raise AttributeError, key
+
+ def __iter__(self):
+ for v in self.groups():
+ yield v
+
+ def __len__(self):
+ return len(self.settings)
+
+ def __contains__(self, key):
+ try:
+ key = self._resolve_key(key)
+ return self.settings.has_key(key)
+ except:
+ return False
+
+ def _resolve_key(self, raw):
+ if is_string_like(raw):
+ key = raw
+
+ elif isinstance(raw, values.ConfigurationGroup):
+ key = raw.key
+
+ else:
+ group = self.groups()[raw]
+ key = group.key
+
+ return key
+
+ def get_config(self, group, key):
+ try:
+ if isinstance(group, values.ConfigurationGroup):
+ group = group.key
+
+ cg = self.settings.get(group, None)
+ if not cg:
+ raise SettingNotSet('%s config group does not exist' % group)
+
+ else:
+ return cg[key]
+ except KeyError:
+ raise SettingNotSet('%s.%s' % (group, key))
+
+ def groups(self):
+ """Return ordered list"""
+ return self.settings.values()
+
+ def has_config(self, group, key):
+ if isinstance(group, values.ConfigurationGroup):
+ group = group.key
+
+ cfg = self.settings.get(group, None)
+ if cfg and key in cfg:
+ return True
+ else:
+ return False
+
+ def preregister_choice(self, group, key, choice):
+ """Setup a choice for a group/key which hasn't been instantiated yet."""
+ k = (group, key)
+ if self.prereg.has_key(k):
+ self.prereg[k].append(choice)
+ else:
+ self.prereg[k] = [choice]
+
+ def register(self, value):
+ g = value.group
+ if not isinstance(g, values.ConfigurationGroup):
+ raise ValueError('value.group should be an instance of ConfigurationGroup')
+
+ groupkey = g.key
+ valuekey = value.key
+
+ k = (groupkey, valuekey)
+ if self.prereg.has_key(k):
+ for choice in self.prereg[k]:
+ value.add_choice(choice)
+
+ if not groupkey in self.settings:
+ self.settings[groupkey] = g
+
+ self.settings[groupkey][valuekey] = value
+
+ return value
+
+ __instance = None
+
+ def __init__(self):
+ if ConfigurationSettings.__instance is None:
+ ConfigurationSettings.__instance = ConfigurationSettings.__impl()
+ #ConfigurationSettings.__instance.load_app_configurations()
+
+ self.__dict__['_ConfigurationSettings__instance'] = ConfigurationSettings.__instance
+
+ def __getattr__(self, attr):
+ """ Delegate access to implementation """
+ return getattr(self.__instance, attr)
+
+ def __getitem__(self, key):
+ return self.__instance[key]
+
+ def __len__(self):
+ return len(self.__instance)
+
+ def __setattr__(self, attr, value):
+ """ Delegate access to implementation """
+ return setattr(self.__instance, attr, value)
+
+ def __unicode__(self):
+ return u"ConfigurationSettings: " + unicode(self.groups())
+
+def config_exists(group, key):
+ """Test to see if a setting has been registered"""
+
+ return ConfigurationSettings().has_config(group, key)
+
+def config_get(group, key):
+ """Get a configuration setting"""
+ try:
+ return ConfigurationSettings().get_config(group, key)
+ except SettingNotSet:
+ log.debug('SettingNotSet: %s.%s', group, key)
+ raise
+
+def config_get_group(group):
+ return ConfigurationSettings()[group]
+
+def config_collect_values(group, groupkey, key, unique=True, skip_missing=True):
+ """Look up (group, groupkey) from config, then take the values returned and
+ use them as groups for a second-stage lookup.
+
+ For example:
+
+ config_collect_values(PAYMENT, MODULES, CREDITCHOICES)
+
+ Stage 1: ['PAYMENT_GOOGLE', 'PAYMENT_AUTHORIZENET']
+ Stage 2: config_value('PAYMENT_GOOGLE', 'CREDITCHOICES')
+ + config_value('PAYMENT_AUTHORIZENET', 'CREDITCHOICES')
+ Stage 3: (if unique is true) remove dupes
+ """
+ groups = config_value(group, groupkey)
+
+ ret = []
+ for g in groups:
+ try:
+ ret.append(config_value(g, key))
+ except KeyError, ke:
+ if not skip_missing:
+ raise SettingNotSet('No config %s.%s' % (g, key))
+
+ if unique:
+ out = []
+ for x in ret:
+ if not x in out:
+ out.append(x)
+ ret = out
+
+ return ret
+
+def config_register(value):
+ """Register a value or values.
+
+ Parameters:
+ -A Value
+ """
+ return ConfigurationSettings().register(value)
+
+def config_register_list(*args):
+ for value in args:
+ config_register(value)
+
+def config_value(group, key, default=_NOTSET):
+ """Get a value from the configuration system"""
+ try:
+ return config_get(group, key).value
+ except SettingNotSet:
+ if default != _NOTSET:
+ return default
+ raise
+
+def config_value_safe(group, key, default_value):
+ """Get a config value with a default fallback, safe for use during SyncDB."""
+ raw = default_value
+
+ try:
+ raw = config_value(group, key)
+ except SettingNotSet:
+ pass
+ except ImportError, e:
+ log.warn("Error getting %s.%s, OK if you are in SyncDB.", group, key)
+
+ return raw
+
+
+def config_choice_values(group, key, skip_missing=True, translate=False):
+ """Get pairs of key, label from the setting."""
+ try:
+ cfg = config_get(group, key)
+ choices = cfg.choice_values
+
+ except SettingNotSet:
+ if skip_missing:
+ return []
+ else:
+ raise SettingNotSet('%s.%s' % (group, key))
+
+ if translate:
+ choices = [(k, ugettext(v)) for k, v in choices]
+
+ return choices
+
+def config_add_choice(group, key, choice):
+ """Add a choice to a value"""
+ if config_exists(group, key):
+ cfg = config_get(group, key)
+ cfg.add_choice(choice)
+ else:
+ ConfigurationSettings().preregister_choice(group, key, choice)
diff --git a/forum/deps/livesettings/locale/de/LC_MESSAGES/django.mo b/forum/deps/livesettings/locale/de/LC_MESSAGES/django.mo
new file mode 100644
index 00000000..e176bc53
--- /dev/null
+++ b/forum/deps/livesettings/locale/de/LC_MESSAGES/django.mo
Binary files differ
diff --git a/forum/deps/livesettings/locale/de/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/de/LC_MESSAGES/django.po
new file mode 100644
index 00000000..1cef701b
--- /dev/null
+++ b/forum/deps/livesettings/locale/de/LC_MESSAGES/django.po
@@ -0,0 +1,101 @@
+# Satchmo Translation Package
+# Copyright (C) 2008 Satchmo Project
+# This file is distributed under the same license as the Satchmo package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-03-22 15:10+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: values.py:88
+msgid "Base Settings"
+msgstr "Basiseinstellungen"
+
+#: values.py:194
+msgid "Default value: \"\""
+msgstr "Standardwert: \"\""
+
+#: values.py:201
+msgid "Default value: "
+msgstr "Standardwert: "
+
+#: values.py:204
+#, python-format
+msgid "Default value: %s"
+msgstr "Standardwert: %s"
+
+#: templates/livesettings/group_settings.html:10
+#: templates/livesettings/site_settings.html:10
+msgid "Home"
+msgstr "Start"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Log out"
+msgstr "Abmelden"
+
+#: templates/livesettings/group_settings.html:18
+#: templates/livesettings/site_settings.html:18
+#, fuzzy
+msgid "Please correct the error below."
+msgid_plural "Please correct the errors below."
+msgstr[0] ""
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+msgstr[1] ""
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+#, fuzzy
+msgid "Documentation"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Change password"
+msgstr "Passwort ändern"
+
+#: templates/livesettings/site_settings.html:11
+msgid "Edit Site Settings"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:11
+msgid "Edit Group Settings"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:24
+#, python-format
+msgid "Settings included in %(name)s."
+msgstr ""
+
+#: templates/livesettings/group_settings.html:49
+#: templates/livesettings/site_settings.html:61
+msgid "You don't have permission to edit values."
+msgstr ""
+
+#: templates/livesettings/site_settings.html:34
+#, python-format
+msgid "Group settings: %(name)s"
+msgstr ""
+
diff --git a/forum/deps/livesettings/locale/en/LC_MESSAGES/django.mo b/forum/deps/livesettings/locale/en/LC_MESSAGES/django.mo
new file mode 100644
index 00000000..c2bc0b94
--- /dev/null
+++ b/forum/deps/livesettings/locale/en/LC_MESSAGES/django.mo
Binary files differ
diff --git a/forum/deps/livesettings/locale/en/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/en/LC_MESSAGES/django.po
new file mode 100644
index 00000000..45eb23a5
--- /dev/null
+++ b/forum/deps/livesettings/locale/en/LC_MESSAGES/django.po
@@ -0,0 +1,100 @@
+# Satchmo Translation Package
+# Copyright (C) 2008 Satchmo Project
+# This file is distributed under the same license as the Satchmo package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-12-31 00:49-0600\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: values.py:88
+msgid "Base Settings"
+msgstr ""
+
+#: values.py:194
+msgid "Default value: \"\""
+msgstr ""
+
+#: values.py:201
+msgid "Default value: "
+msgstr ""
+
+#: values.py:204
+#, python-format
+msgid "Default value: %s"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:10
+#: templates/livesettings/site_settings.html:10
+msgid "Home"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Log out"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:18
+#: templates/livesettings/site_settings.html:18
+#, fuzzy
+msgid "Please correct the error below."
+msgid_plural "Please correct the errors below."
+msgstr[0] ""
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+msgstr[1] ""
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Documentation"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Change password"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:11
+msgid "Edit Group Settings"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:24
+#, python-format
+msgid "Settings included in %(name)s."
+msgstr ""
+
+#: templates/livesettings/group_settings.html:49
+#: templates/livesettings/site_settings.html:61
+msgid "You don't have permission to edit values."
+msgstr ""
+
+#: templates/livesettings/site_settings.html:11
+msgid "Edit Site Settings"
+msgstr ""
+
+#: templates/livesettings/site_settings.html:34
+#, python-format
+msgid "Group settings: %(name)s"
+msgstr ""
+
diff --git a/forum/deps/livesettings/locale/es/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/es/LC_MESSAGES/django.po
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/forum/deps/livesettings/locale/es/LC_MESSAGES/django.po
diff --git a/forum/deps/livesettings/locale/fr/LC_MESSAGES/django.mo b/forum/deps/livesettings/locale/fr/LC_MESSAGES/django.mo
new file mode 100644
index 00000000..dd872edd
--- /dev/null
+++ b/forum/deps/livesettings/locale/fr/LC_MESSAGES/django.mo
Binary files differ
diff --git a/forum/deps/livesettings/locale/fr/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/fr/LC_MESSAGES/django.po
new file mode 100644
index 00000000..90475585
--- /dev/null
+++ b/forum/deps/livesettings/locale/fr/LC_MESSAGES/django.po
@@ -0,0 +1,113 @@
+# Satchmo Translation Package
+# Copyright (C) 2008 Satchmo Project
+# Jacques Moulin <jacques@tpi.be>, 2008.
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-11-02 16:11+0100\n"
+"PO-Revision-Date: 2008-11-02 17:51+0100\n"
+"Last-Translator: Jacques Moulin <jacques@tpi.be>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Poedit-Language: French\n"
+"X-Poedit-SourceCharset: utf-8\n"
+
+#: templates/livesettings/group_settings.html.py:10
+#: templates/livesettings/site_settings.html.py:25
+#: templates/livesettings/group_settings.html.py:10
+#: templates/livesettings/site_settings.html.py:25
+msgid "Home"
+msgstr "Accueil"
+
+#: models.py:76
+#: models.py:115
+msgid "Site"
+msgstr "Site"
+
+#: values.py:94
+msgid "Base Settings"
+msgstr "Configuration de base"
+
+#: values.py:200
+msgid "Default value: \"\""
+msgstr "Valeur par défaut: \"\""
+
+#: values.py:207
+msgid "Default value: "
+msgstr "Valeur par défaut:"
+
+#: values.py:210
+#, python-format
+msgid "Default value: %s"
+msgstr "Valeur par défaut: %s"
+
+#: templates/livesettings/group_settings.html.py:7
+#: templates/livesettings/site_settings.html.py:22
+#: templates/livesettings/group_settings.html.py:7
+#: templates/livesettings/site_settings.html.py:22
+msgid "Documentation"
+msgstr "Documentation"
+
+#: templates/livesettings/group_settings.html.py:7
+#: templates/livesettings/site_settings.html.py:22
+#: templates/livesettings/group_settings.html.py:7
+#: templates/livesettings/site_settings.html.py:22
+msgid "Change password"
+msgstr "Modifier le mot de passe"
+
+#: templates/livesettings/group_settings.html.py:7
+#: templates/livesettings/site_settings.html.py:22
+#: templates/livesettings/group_settings.html.py:7
+#: templates/livesettings/site_settings.html.py:22
+msgid "Log out"
+msgstr "Se déconnecter"
+
+#: templates/livesettings/group_settings.html.py:11
+#: templates/livesettings/group_settings.html.py:11
+msgid "Edit Group Settings"
+msgstr "Editer les paramètres de groupe"
+
+#: templates/livesettings/group_settings.html.py:18
+#: templates/livesettings/site_settings.html.py:43
+#: templates/livesettings/group_settings.html.py:18
+#: templates/livesettings/site_settings.html.py:41
+msgid "Please correct the error below."
+msgid_plural "Please correct the errors below."
+msgstr[0] "Veuillez corriger l'erreur ci-dessous:"
+msgstr[1] "Veuillez corriger les erreurs ci-dessous:"
+
+#: templates/livesettings/group_settings.html.py:24
+#: templates/livesettings/group_settings.html.py:24
+msgid "Settings included in %(name)s."
+msgstr "Paramètres inclus dans %(name)s."
+
+#: templates/livesettings/group_settings.html.py:49
+#: templates/livesettings/site_settings.html.py:89
+#: templates/livesettings/group_settings.html.py:49
+#: templates/livesettings/site_settings.html.py:87
+msgid "You don't have permission to edit values."
+msgstr "Vous n'avez pas le droit d'éditer les valeurs."
+
+#: templates/livesettings/site_settings.html.py:26
+#: templates/livesettings/site_settings.html.py:26
+msgid "Edit Site Settings"
+msgstr "Editer les paramètres du site"
+
+#: templates/livesettings/site_settings.html.py:59
+#: templates/livesettings/site_settings.html.py:58
+msgid "Group settings: %(name)s"
+msgstr "Paramètres du groupe: %(name)s"
+
+#: templates/livesettings/site_settings.html.py:86
+#: templates/livesettings/site_settings.html.py:84
+msgid "Uncollapse all"
+msgstr "Déployer tout"
+
+#: templates/livesettings/_admin_site_views.html.py:5
+msgid "Sites"
+msgstr "Sites"
+
diff --git a/forum/deps/livesettings/locale/he/LC_MESSAGES/django.mo b/forum/deps/livesettings/locale/he/LC_MESSAGES/django.mo
new file mode 100644
index 00000000..04270a04
--- /dev/null
+++ b/forum/deps/livesettings/locale/he/LC_MESSAGES/django.mo
Binary files differ
diff --git a/forum/deps/livesettings/locale/he/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/he/LC_MESSAGES/django.po
new file mode 100644
index 00000000..362f5612
--- /dev/null
+++ b/forum/deps/livesettings/locale/he/LC_MESSAGES/django.po
@@ -0,0 +1,98 @@
+# translation of Satchmo
+# Copyright (C) 2008 The Satchmo Project
+# This file is distributed under the same license as the Satchmo package.
+#
+# Aviv Greenberg <avivgr@gmail.com>, 2008.
+msgid ""
+msgstr ""
+"Project-Id-Version: django\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-03-13 23:02+0200\n"
+"PO-Revision-Date: 2009-03-22 07:45\n"
+"Last-Translator: Aviv Greenberg <avivgr@gmail.com>\n"
+"Language-Team: <en@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: KBabel 1.11.4\n"
+"X-Translated-Using: django-rosetta 0.4.0\n"
+
+#: models.py:75 models.py:114
+msgid "Site"
+msgstr "אתר"
+
+#: values.py:96
+msgid "Base Settings"
+msgstr "תצורה בסיסית"
+
+#: values.py:202
+msgid "Default value: \"\""
+msgstr "ברירת מחדל:\"\""
+
+#: values.py:209
+msgid "Default value: "
+msgstr "ברירת מחדל:"
+
+#: values.py:212
+#, python-format
+msgid "Default value: %s"
+msgstr "ברירת מחדל:%s"
+
+#: templates/livesettings/_admin_site_views.html:4
+msgid "Sites"
+msgstr "אתרים"
+
+#: templates/livesettings/group_settings.html:11
+#: templates/livesettings/site_settings.html:23
+msgid "Documentation"
+msgstr "תיעוד"
+
+#: templates/livesettings/group_settings.html:11
+#: templates/livesettings/site_settings.html:23
+msgid "Change password"
+msgstr "שינוי סיסמה"
+
+#: templates/livesettings/group_settings.html:11
+#: templates/livesettings/site_settings.html:23
+msgid "Log out"
+msgstr "יציאה"
+
+#: templates/livesettings/group_settings.html:14
+#: templates/livesettings/site_settings.html:26
+msgid "Home"
+msgstr "דף הבית"
+
+#: templates/livesettings/group_settings.html:15
+msgid "Edit Group Settings"
+msgstr "ערוך הגדרות קבוצה"
+
+#: templates/livesettings/group_settings.html:22
+#: templates/livesettings/site_settings.html:44
+msgid "Please correct the error below."
+msgid_plural "Please correct the errors below."
+msgstr[0] "נא לתקן את השגיאה המופיעה מתחת."
+msgstr[1] "נא לתקן את השגיאות המופיעות מתחת."
+
+#: templates/livesettings/group_settings.html:28
+#, python-format
+msgid "Settings included in %(name)s."
+msgstr "הגדרות כלולות %(name)s"
+
+#: templates/livesettings/group_settings.html:53
+#: templates/livesettings/site_settings.html:90
+msgid "You don't have permission to edit values."
+msgstr "אינך מורשה לערוך ערכים."
+
+#: templates/livesettings/site_settings.html:27
+msgid "Edit Site Settings"
+msgstr "ערוך הגדרות אתר"
+
+#: templates/livesettings/site_settings.html:60
+#, python-format
+msgid "Group settings: %(name)s"
+msgstr "הגדרות קבוצה: %(name)s"
+
+#: templates/livesettings/site_settings.html:87
+msgid "Uncollapse all"
+msgstr "הסתר פרטים"
diff --git a/forum/deps/livesettings/locale/it/LC_MESSAGES/django.mo b/forum/deps/livesettings/locale/it/LC_MESSAGES/django.mo
new file mode 100644
index 00000000..05c50952
--- /dev/null
+++ b/forum/deps/livesettings/locale/it/LC_MESSAGES/django.mo
Binary files differ
diff --git a/forum/deps/livesettings/locale/it/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/it/LC_MESSAGES/django.po
new file mode 100644
index 00000000..66401866
--- /dev/null
+++ b/forum/deps/livesettings/locale/it/LC_MESSAGES/django.po
@@ -0,0 +1,106 @@
+# translation of django.po to Italiano
+# Copyright (C) 2008 Satchmo Project
+# This file is distributed under the same license as the PACKAGE package.
+#
+# costantino giuliodori <costantino.giuliodori@gmail.com>, 2007.
+# Alessandro Ronchi <alessandro.ronchi@soasi.com>, 2008.
+msgid ""
+msgstr ""
+"Project-Id-Version: django\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-09-27 09:16-0700\n"
+"PO-Revision-Date: 2008-09-30 13:13+0200\n"
+"Last-Translator: Alessandro Ronchi <alessandro.ronchi@soasi.com>\n"
+"Language-Team: Italiano <it@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.11.4\n"
+"Plural-Forms: nplurals=2; plural=n > 1\n"
+
+#: templates/livesettings/group_settings.html:10
+#: templates/livesettings/site_settings.html:25
+msgid "Home"
+msgstr "Pagina iniziale"
+
+#: models.py:76
+#: models.py:115
+msgid "Site"
+msgstr "Sito"
+
+#: values.py:94
+msgid "Base Settings"
+msgstr "Impostazioni base"
+
+#: values.py:200
+msgid "Default value: \"\""
+msgstr "Valore di default: \"\""
+
+#: values.py:207
+msgid "Default value: "
+msgstr "Valore di default: "
+
+#: values.py:210
+#, python-format
+msgid "Default value: %s"
+msgstr "Valore di default:%s"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+# translated = "Extra di spedizione"
+msgid "Documentation"
+msgstr "Documentazione"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+msgid "Change password"
+msgstr "Cambia Password"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+msgid "Log out"
+msgstr "Esci"
+
+#: templates/livesettings/group_settings.html:11
+msgid "Edit Group Settings"
+msgstr "Modifica le impostazioni del Gruppo"
+
+#: templates/livesettings/group_settings.html:18
+#: templates/livesettings/site_settings.html:43
+# translated = ""
+msgid "Please correct the error below."
+msgid_plural "Please correct the errors below."
+msgstr[0] "Correggi l'errore indicato di seguito."
+msgstr[1] "Correggi gli errori indicati di seguito."
+
+#: templates/livesettings/group_settings.html:24
+# translated = "Modificare le impostazioni di gruppo"
+#, python-format
+msgid "Settings included in %(name)s."
+msgstr "Impostazioni incluse in %(name)s."
+
+#: templates/livesettings/group_settings.html:49
+#: templates/livesettings/site_settings.html:89
+# translated = "Impostazioni incluse in% (nome) s."
+msgid "You don't have permission to edit values."
+msgstr "Non hai il permesso di modificare questi valori."
+
+#: templates/livesettings/site_settings.html:26
+# translated = "Non avete il permesso di modificare i valori."
+msgid "Edit Site Settings"
+msgstr "Modifica le impostazioni del sito"
+
+#: templates/livesettings/site_settings.html:59
+# translated = "Modifica impostazioni sito"
+#, python-format
+msgid "Group settings: %(name)s"
+msgstr "Impostazioni di gruppo: %(name)s"
+
+#: templates/livesettings/site_settings.html:86
+msgid "Uncollapse all"
+msgstr "Espandi tutti"
+
+#: templates/livesettings/_admin_site_views.html:5
+msgid "Sites"
+msgstr "Siti"
+
diff --git a/forum/deps/livesettings/locale/ko/LC_MESSAGES/django.mo b/forum/deps/livesettings/locale/ko/LC_MESSAGES/django.mo
new file mode 100644
index 00000000..e0738605
--- /dev/null
+++ b/forum/deps/livesettings/locale/ko/LC_MESSAGES/django.mo
Binary files differ
diff --git a/forum/deps/livesettings/locale/ko/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/ko/LC_MESSAGES/django.po
new file mode 100644
index 00000000..0dbd2d4d
--- /dev/null
+++ b/forum/deps/livesettings/locale/ko/LC_MESSAGES/django.po
@@ -0,0 +1,100 @@
+# Satchmo Translation Package
+# Copyright (C) 2008 Satchmo Project
+# This file is distributed under the same license as the Satchmo package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-12-31 00:49-0600\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: values.py:88
+msgid "Base Settings"
+msgstr "기본 세팅"
+
+#: values.py:194
+msgid "Default value: \"\""
+msgstr "기본 값: \"\""
+
+#: values.py:201
+msgid "Default value: "
+msgstr "기본 값: "
+
+#: values.py:204
+#, python-format
+msgid "Default value: %s"
+msgstr "기본 값:%s"
+
+#: templates/livesettings/group_settings.html:10
+#: templates/livesettings/site_settings.html:10
+msgid "Home"
+msgstr "홈"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Log out"
+msgstr "로그 아웃"
+
+#: templates/livesettings/group_settings.html:18
+#: templates/livesettings/site_settings.html:18
+#, fuzzy
+msgid "Please correct the error below."
+msgid_plural "Please correct the errors below."
+msgstr[0] ""
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+msgstr[1] ""
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Documentation"
+msgstr "문서"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Change password"
+msgstr "패스워드 변경"
+
+#: templates/livesettings/group_settings.html:11
+msgid "Edit Group Settings"
+msgstr "그룹설정 수정"
+
+#: templates/livesettings/group_settings.html:24
+#, python-format
+msgid "Settings included in %(name)s."
+msgstr "%(name)s을 포함한 설정"
+
+#: templates/livesettings/group_settings.html:49
+#: templates/livesettings/site_settings.html:61
+msgid "You don't have permission to edit values."
+msgstr "이 값을 수정할 권한이 없습니다."
+
+#: templates/livesettings/site_settings.html:11
+msgid "Edit Site Settings"
+msgstr "사이트 설정 수정"
+
+#: templates/livesettings/site_settings.html:34
+#, python-format
+msgid "Group settings: %(name)s"
+msgstr "그룹 설정: %(name)s"
+
diff --git a/forum/deps/livesettings/locale/pl/LC_MESSAGES/django.mo b/forum/deps/livesettings/locale/pl/LC_MESSAGES/django.mo
new file mode 100644
index 00000000..f45e49ed
--- /dev/null
+++ b/forum/deps/livesettings/locale/pl/LC_MESSAGES/django.mo
Binary files differ
diff --git a/forum/deps/livesettings/locale/pl/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/pl/LC_MESSAGES/django.po
new file mode 100644
index 00000000..1e7b4199
--- /dev/null
+++ b/forum/deps/livesettings/locale/pl/LC_MESSAGES/django.po
@@ -0,0 +1,97 @@
+# Satchmo Translation Package
+# Copyright (C) 2008 Satchmo Project
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-09-03 18:10+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: <jerzyk@jerzyk.com>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: templates/livesettings/group_settings.html:10
+#: templates/livesettings/site_settings.html:25
+msgid "Home"
+msgstr "Strona startowa"
+
+#: models.py:76
+#: models.py:115
+msgid "Site"
+msgstr "Strona"
+
+#: values.py:93
+msgid "Base Settings"
+msgstr "Ustawienia podstawowe"
+
+#: values.py:199
+msgid "Default value: \"\""
+msgstr "Domyślna wartość: \"\""
+
+#: values.py:206
+msgid "Default value: "
+msgstr "Domyślna wartość: "
+
+#: values.py:209
+#, python-format
+msgid "Default value: %s"
+msgstr "Domyślna wartość: %s"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+msgid "Documentation"
+msgstr "Dokumentacja"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+msgid "Change password"
+msgstr "Zmiana hasła"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+msgid "Log out"
+msgstr "Wyloguj"
+
+#: templates/livesettings/group_settings.html:11
+msgid "Edit Group Settings"
+msgstr "Edycja Ustawień dla Grupy"
+
+#: templates/livesettings/group_settings.html:18
+#: templates/livesettings/site_settings.html:43
+msgid "Please correct the error below."
+msgid_plural "Please correct the errors below."
+msgstr[0] "Proszę poprawić poniższy błąd."
+msgstr[1] "Proszę poprawić poniższe błędy."
+
+#: templates/livesettings/group_settings.html:24
+#, python-format
+msgid "Settings included in %(name)s."
+msgstr "Ustawienia w %(name)s."
+
+#: templates/livesettings/group_settings.html:49
+#: templates/livesettings/site_settings.html:89
+msgid "You don't have permission to edit values."
+msgstr "Nie masz uprawnień do zmiany tych wartości."
+
+#: templates/livesettings/site_settings.html:26
+msgid "Edit Site Settings"
+msgstr "Edytuj ustawienia serwisu"
+
+#: templates/livesettings/site_settings.html:59
+#, python-format
+msgid "Group settings: %(name)s"
+msgstr "Ustawienia grupy: %(name)s"
+
+#: templates/livesettings/site_settings.html:86
+msgid "Uncollapse all"
+msgstr "Rozwiń wszystko"
+
+#: templates/livesettings/_admin_site_views.html:5
+msgid "Sites"
+msgstr "Strony"
+
diff --git a/forum/deps/livesettings/locale/pt_BR/LC_MESSAGES/django.mo b/forum/deps/livesettings/locale/pt_BR/LC_MESSAGES/django.mo
new file mode 100644
index 00000000..a8bfb8b2
--- /dev/null
+++ b/forum/deps/livesettings/locale/pt_BR/LC_MESSAGES/django.mo
Binary files differ
diff --git a/forum/deps/livesettings/locale/pt_BR/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/pt_BR/LC_MESSAGES/django.po
new file mode 100644
index 00000000..72d49df7
--- /dev/null
+++ b/forum/deps/livesettings/locale/pt_BR/LC_MESSAGES/django.po
@@ -0,0 +1,100 @@
+# Satchmo Translation Package
+# Copyright (C) 2008 Satchmo Project
+# This file is distributed under the same license as the PACKAGE package.
+# Terry Laundos Aguiar <terry@s1solucoes.com.br>, 2008.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-09-05 23:50-0300\n"
+"PO-Revision-Date: 2008-09-05 23:51-0300\n"
+"Last-Translator: Terry Laundos Aguiar <terry@s1solucoes.com.br>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: templates/livesettings/group_settings.html:10
+#: templates/livesettings/site_settings.html:25
+msgid "Home"
+msgstr "Inicial"
+
+#: models.py:76
+#: models.py:115
+#, fuzzy
+msgid "Site"
+msgstr "Estado"
+
+#: values.py:93
+msgid "Base Settings"
+msgstr "Configurações Iniciais"
+
+#: values.py:199
+msgid "Default value: \"\""
+msgstr "Valor padrão: \"\""
+
+#: values.py:206
+msgid "Default value: "
+msgstr "Valor padrão: "
+
+#: values.py:209
+#, python-format
+msgid "Default value: %s"
+msgstr "Valor padrão: %s"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+msgid "Documentation"
+msgstr "Documentação"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+msgid "Change password"
+msgstr "Mudar senha"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+msgid "Log out"
+msgstr "Deslogar"
+
+#: templates/livesettings/group_settings.html:11
+msgid "Edit Group Settings"
+msgstr "Editar preferências de grupo"
+
+#: templates/livesettings/group_settings.html:18
+#: templates/livesettings/site_settings.html:43
+msgid "Please correct the error below."
+msgid_plural "Please correct the errors below."
+msgstr[0] ""
+msgstr[1] ""
+
+#: templates/livesettings/group_settings.html:24
+#, python-format
+msgid "Settings included in %(name)s."
+msgstr "Configurações inclusas no %(name)s."
+
+#: templates/livesettings/group_settings.html:49
+#: templates/livesettings/site_settings.html:89
+msgid "You don't have permission to edit values."
+msgstr "Você não tem permissão para editar valores."
+
+#: templates/livesettings/site_settings.html:26
+msgid "Edit Site Settings"
+msgstr "Editar configurações do site"
+
+#: templates/livesettings/site_settings.html:59
+#, python-format
+msgid "Group settings: %(name)s"
+msgstr "Configurações de grupo: %(name)s"
+
+#: templates/livesettings/site_settings.html:86
+#, fuzzy
+msgid "Uncollapse all"
+msgstr "Desmarcar todos"
+
+#: templates/livesettings/_admin_site_views.html:5
+#, fuzzy
+msgid "Sites"
+msgstr "Notas"
+
diff --git a/forum/deps/livesettings/locale/ru/LC_MESSAGES/django.mo b/forum/deps/livesettings/locale/ru/LC_MESSAGES/django.mo
new file mode 100644
index 00000000..42e6074a
--- /dev/null
+++ b/forum/deps/livesettings/locale/ru/LC_MESSAGES/django.mo
Binary files differ
diff --git a/forum/deps/livesettings/locale/ru/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/ru/LC_MESSAGES/django.po
new file mode 100644
index 00000000..a0db054b
--- /dev/null
+++ b/forum/deps/livesettings/locale/ru/LC_MESSAGES/django.po
@@ -0,0 +1,85 @@
+# Satchmo Translation Package
+# Copyright (C) 2008 Satchmo Project
+# This file is distributed under the same license as the Satchmo package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Satchmo\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-12-31 00:49-0600\n"
+"PO-Revision-Date: 2009-03-02 21:52+0300\n"
+"Last-Translator: Данил Семеленов <danil.mail@gmail.com>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language-Team: \n"
+
+#: values.py:88
+msgid "Base Settings"
+msgstr "Основные настройки"
+
+#: values.py:194
+msgid "Default value: \"\""
+msgstr "Значение по умолчанию: \"\""
+
+#: values.py:201
+msgid "Default value: "
+msgstr "Значение по умолчанию: "
+
+#: values.py:204
+#, python-format
+msgid "Default value: %s"
+msgstr "Значение по умолчанию: %s"
+
+#: templates/livesettings/group_settings.html:10
+#: templates/livesettings/site_settings.html:10
+msgid "Home"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Log out"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:18
+#: templates/livesettings/site_settings.html:18
+#, fuzzy
+msgid "Please correct the error below."
+msgid_plural "Please correct the errors below."
+msgstr[0] ""
+msgstr[1] ""
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Documentation"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Change password"
+msgstr ""
+
+#: templates/livesettings/group_settings.html:11
+msgid "Edit Group Settings"
+msgstr "Изменить группу настроек"
+
+#: templates/livesettings/group_settings.html:24
+#, python-format
+msgid "Settings included in %(name)s."
+msgstr "Настройки включены в %(name)s."
+
+#: templates/livesettings/group_settings.html:49
+#: templates/livesettings/site_settings.html:61
+msgid "You don't have permission to edit values."
+msgstr "У вас нет разрешения изменять значение."
+
+#: templates/livesettings/site_settings.html:11
+msgid "Edit Site Settings"
+msgstr "Изменить настройки сайта"
+
+#: templates/livesettings/site_settings.html:34
+#, python-format
+msgid "Group settings: %(name)s"
+msgstr "Группа настроек: %(name)s"
+
diff --git a/forum/deps/livesettings/locale/sv/LC_MESSAGES/django.mo b/forum/deps/livesettings/locale/sv/LC_MESSAGES/django.mo
new file mode 100644
index 00000000..caed0ab9
--- /dev/null
+++ b/forum/deps/livesettings/locale/sv/LC_MESSAGES/django.mo
Binary files differ
diff --git a/forum/deps/livesettings/locale/sv/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/sv/LC_MESSAGES/django.po
new file mode 100644
index 00000000..6b096f6b
--- /dev/null
+++ b/forum/deps/livesettings/locale/sv/LC_MESSAGES/django.po
@@ -0,0 +1,92 @@
+# Satchmo Translation Package
+# Copyright (C) 2008 Satchmo Project
+# This file is distributed under the same license as the PACKAGE package.
+# N.L. <kotorinl@yahoo.co.uk>, 2008.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Satchmo svn\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-04-30 23:40+0200\n"
+"PO-Revision-Date: 2008-04-30 23:35+0100\n"
+"Last-Translator: N.L. <kotorinl@yahoo.co.uk>\n"
+"Language-Team: Group\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-Language: Swedish\n"
+"X-Poedit-Basepath: ../../../\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Poedit-Country: SWEDEN\n"
+
+#: values.py:89
+msgid "Base Settings"
+msgstr "Grundinställningar"
+
+#: values.py:195
+msgid "Default value: \"\""
+msgstr "Förvalt värde: \"\""
+
+#: values.py:202
+msgid "Default value: "
+msgstr "Förvalt värde:"
+
+#: values.py:205
+#, python-format
+msgid "Default value: %s"
+msgstr "Förvalt värde: %s"
+
+#: templates/livesettings/group_settings.html:10
+#: templates/livesettings/site_settings.html:25
+msgid "Home"
+msgstr "Hem"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+msgid "Log out"
+msgstr "Logga ut"
+
+#: templates/livesettings/group_settings.html:18
+#: templates/livesettings/site_settings.html:41
+msgid "Please correct the error below."
+msgid_plural "Please correct the errors below."
+msgstr[0] "Var god rätta till felet nedan."
+msgstr[1] "Var god rätta till felen nedan."
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+msgid "Documentation"
+msgstr "Dokumentation"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:22
+msgid "Change password"
+msgstr "Byt lösenord"
+
+#: templates/livesettings/site_settings.html:26
+msgid "Edit Site Settings"
+msgstr "Ändra sajtinställningar"
+
+#: templates/livesettings/group_settings.html:11
+msgid "Edit Group Settings"
+msgstr "Redigera gruppinställningar"
+
+#: templates/livesettings/group_settings.html:24
+#, python-format
+msgid "Settings included in %(name)s."
+msgstr "Inställningar som ingår i %(name)s."
+
+#: templates/livesettings/group_settings.html:49
+#: templates/livesettings/site_settings.html:87
+msgid "You don't have permission to edit values."
+msgstr "Du har inte tillåtelse att ändra värden."
+
+#: templates/livesettings/site_settings.html:58
+#, python-format
+msgid "Group settings: %(name)s"
+msgstr "Gruppinställningar: %(name)s"
+
+#: templates/livesettings/site_settings.html:84
+msgid "Uncollapse all"
+msgstr "Visa alla"
+
diff --git a/forum/deps/livesettings/locale/tr/LC_MESSAGES/django.mo b/forum/deps/livesettings/locale/tr/LC_MESSAGES/django.mo
new file mode 100644
index 00000000..d56ad423
--- /dev/null
+++ b/forum/deps/livesettings/locale/tr/LC_MESSAGES/django.mo
Binary files differ
diff --git a/forum/deps/livesettings/locale/tr/LC_MESSAGES/django.po b/forum/deps/livesettings/locale/tr/LC_MESSAGES/django.po
new file mode 100644
index 00000000..bb2a1506
--- /dev/null
+++ b/forum/deps/livesettings/locale/tr/LC_MESSAGES/django.po
@@ -0,0 +1,102 @@
+# Satchmo Translation Package
+# Copyright (C) 2008 Satchmo Project
+# This file is distributed under the same license as the Satchmo package.
+# Selin Çuhadar <selincuhadar@gmail.com>, 2008.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Satchmo\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-12-31 00:49-0600\n"
+"PO-Revision-Date: 2008-06-09 18:18+0200\n"
+"Last-Translator: Selin Çuhadar <selincuhadar@gmail.com>\n"
+"Language-Team: Turkish <selincuhadar@gmail.com>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-Country: TURKEY\n"
+"X-Poedit-SourceCharset: utf-8\n"
+
+#: values.py:88
+msgid "Base Settings"
+msgstr "Temel Ayarlar"
+
+#: values.py:194
+msgid "Default value: \"\""
+msgstr "Geçerli Değer: \"\""
+
+#: values.py:201
+msgid "Default value: "
+msgstr "Geçerli Değer:"
+
+#: values.py:204
+#, python-format
+msgid "Default value: %s"
+msgstr "Geçerli Değer: %s"
+
+#: templates/livesettings/group_settings.html:10
+#: templates/livesettings/site_settings.html:10
+msgid "Home"
+msgstr "Ev"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Log out"
+msgstr "Oturumu kapa"
+
+#: templates/livesettings/group_settings.html:18
+#: templates/livesettings/site_settings.html:18
+#, fuzzy
+msgid "Please correct the error below."
+msgid_plural "Please correct the errors below."
+msgstr[0] ""
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+msgstr[1] ""
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+"#-#-#-#-# django.pot (PACKAGE VERSION) #-#-#-#-#\n"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Documentation"
+msgstr "Dokümentasyon"
+
+#: templates/livesettings/group_settings.html:7
+#: templates/livesettings/site_settings.html:7
+msgid "Change password"
+msgstr "Şifreyi değiştir"
+
+#: templates/livesettings/group_settings.html:11
+msgid "Edit Group Settings"
+msgstr "Grup Ayarlarını Düzenle"
+
+#: templates/livesettings/group_settings.html:24
+#, python-format
+msgid "Settings included in %(name)s."
+msgstr "%(name)s ayarlara dahil edildi."
+
+#: templates/livesettings/group_settings.html:49
+#: templates/livesettings/site_settings.html:61
+msgid "You don't have permission to edit values."
+msgstr "Değerleri düzenlemek için gerekli izniniz yok."
+
+#: templates/livesettings/site_settings.html:11
+msgid "Edit Site Settings"
+msgstr "Site Ayarlarını Düzenle"
+
+#: templates/livesettings/site_settings.html:34
+#, python-format
+msgid "Group settings: %(name)s"
+msgstr "Grup ayarları: %(name)s"
+
diff --git a/forum/deps/livesettings/models.py b/forum/deps/livesettings/models.py
new file mode 100644
index 00000000..5d27033c
--- /dev/null
+++ b/forum/deps/livesettings/models.py
@@ -0,0 +1,170 @@
+from django.conf import settings
+from django.contrib.sites.models import Site
+from django.db import models
+from django.db.models import loading
+from django.utils.translation import ugettext_lazy as _
+from keyedcache import cache_key, cache_get, cache_set, NotCachedError
+from keyedcache.models import CachedObjectMixin
+from forum.deps.livesettings.overrides import get_overrides
+import logging
+
+log = logging.getLogger('configuration.models')
+
+__all__ = ['SettingNotSet', 'Setting', 'LongSetting', 'find_setting']
+
+def _safe_get_siteid(site):
+ if not site:
+ try:
+ site = Site.objects.get_current()
+ siteid = site.id
+ except:
+ siteid = settings.SITE_ID
+ else:
+ siteid = site.id
+ return siteid
+
+def find_setting(group, key, site=None):
+ """Get a setting or longsetting by group and key, cache and return it."""
+
+ siteid = _safe_get_siteid(site)
+ setting = None
+
+ use_db, overrides = get_overrides(siteid)
+ ck = cache_key('Setting', siteid, group, key)
+
+ if use_db:
+ try:
+ setting = cache_get(ck)
+
+ except NotCachedError, nce:
+ if loading.app_cache_ready():
+ try:
+ setting = Setting.objects.get(site__id__exact=siteid, key__exact=key, group__exact=group)
+
+ except Setting.DoesNotExist:
+ # maybe it is a "long setting"
+ try:
+ setting = LongSetting.objects.get(site__id__exact=siteid, key__exact=key, group__exact=group)
+
+ except LongSetting.DoesNotExist:
+ pass
+
+ cache_set(ck, value=setting)
+
+ else:
+ grp = overrides.get(group, None)
+ if grp and grp.has_key(key):
+ val = grp[key]
+ setting = ImmutableSetting(key=key, group=group, value=val)
+ log.debug('Returning overridden: %s', setting)
+
+ if not setting:
+ raise SettingNotSet(key, cachekey=ck)
+
+ return setting
+
+class SettingNotSet(Exception):
+ def __init__(self, k, cachekey=None):
+ self.key = k
+ self.cachekey = cachekey
+ self.args = [self.key, self.cachekey]
+
+class SettingManager(models.Manager):
+ def get_query_set(self):
+ all = super(SettingManager, self).get_query_set()
+ siteid = _safe_get_siteid(None)
+ return all.filter(site__id__exact=siteid)
+
+
+class ImmutableSetting(object):
+
+ def __init__(self, group="", key="", value="", site=1):
+ self.site = site
+ self.group = group
+ self.key = key
+ self.value = value
+
+ def cache_key(self, *args, **kwargs):
+ return cache_key('OverrideSetting', self.site, self.group, self.key)
+
+ def delete(self):
+ pass
+
+ def save(self, *args, **kwargs):
+ pass
+
+ def __repr__(self):
+ return "ImmutableSetting: %s.%s=%s" % (self.group, self.key, self.value)
+
+
+class Setting(models.Model, CachedObjectMixin):
+ site = models.ForeignKey(Site, verbose_name=_('Site'))
+ group = models.CharField(max_length=100, blank=False, null=False)
+ key = models.CharField(max_length=100, blank=False, null=False)
+ value = models.CharField(max_length=255, blank=True)
+
+ objects = SettingManager()
+
+ def __nonzero__(self):
+ return self.id is not None
+
+ def cache_key(self, *args, **kwargs):
+ return cache_key('Setting', self.site, self.group, self.key)
+
+ def delete(self):
+ self.cache_delete()
+ super(Setting, self).delete()
+
+ def save(self, force_insert=False, force_update=False):
+ try:
+ site = self.site
+ except Site.DoesNotExist:
+ self.site = Site.objects.get_current()
+
+ super(Setting, self).save(force_insert=force_insert, force_update=force_update)
+
+ self.cache_set()
+
+ class Meta:
+ unique_together = ('site', 'group', 'key')
+
+
+class LongSettingManager(models.Manager):
+ def get_query_set(self):
+ all = super(LongSettingManager, self).get_query_set()
+ siteid = _safe_get_siteid(None)
+ return all.filter(site__id__exact=siteid)
+
+class LongSetting(models.Model, CachedObjectMixin):
+ """A Setting which can handle more than 255 characters"""
+ site = models.ForeignKey(Site, verbose_name=_('Site'))
+ group = models.CharField(max_length=100, blank=False, null=False)
+ key = models.CharField(max_length=100, blank=False, null=False)
+ value = models.TextField(blank=True)
+
+ objects = LongSettingManager()
+
+ def __nonzero__(self):
+ return self.id is not None
+
+ def cache_key(self, *args, **kwargs):
+ # note same cache pattern as Setting. This is so we can look up in one check.
+ # they can't overlap anyway, so this is moderately safe. At the worst, the
+ # Setting will override a LongSetting.
+ return cache_key('Setting', self.site, self.group, self.key)
+
+ def delete(self):
+ self.cache_delete()
+ super(LongSetting, self).delete()
+
+ def save(self, force_insert=False, force_update=False):
+ try:
+ site = self.site
+ except Site.DoesNotExist:
+ self.site = Site.objects.get_current()
+ super(LongSetting, self).save(force_insert=force_insert, force_update=force_update)
+ self.cache_set()
+
+ class Meta:
+ unique_together = ('site', 'group', 'key')
+
diff --git a/forum/deps/livesettings/overrides.py b/forum/deps/livesettings/overrides.py
new file mode 100644
index 00000000..58c1079b
--- /dev/null
+++ b/forum/deps/livesettings/overrides.py
@@ -0,0 +1,55 @@
+"""Allows forum.deps.livesettings to be "locked down" and no longer use the settings page or the database
+for settings retrieval.
+"""
+
+from django.conf import settings as djangosettings
+from django.contrib.sites.models import Site
+import logging
+
+__all__ = ['get_overrides']
+
+def _safe_get_siteid(site):
+ if not site:
+ try:
+ site = Site.objects.get_current()
+ siteid = site.id
+ except:
+ siteid = djangosettings.SITE_ID
+ else:
+ siteid = site.id
+ return siteid
+
+def get_overrides(siteid=-1):
+ """Check to see if forum.deps.livesettings is allowed to use the database. If not, then
+ it will only use the values in the dictionary, LIVESETTINGS_OPTIONS[SITEID]['SETTINGS'],
+ this allows 'lockdown' of a live site.
+
+ The LIVESETTINGS dict must be formatted as follows::
+
+ LIVESETTINGS_OPTIONS = {
+ 1 : {
+ 'DB' : [True/False],
+ SETTINGS = {
+ 'GROUPKEY' : {'KEY', val, 'KEY2', val},
+ 'GROUPKEY2' : {'KEY', val, 'KEY2', val},
+ }
+ }
+ }
+
+ In the settings dict above, the "val" entries must exactly match the format
+ stored in the database for a setting. Do not use a literal True or an integer,
+ it needs to be the string representation of them.
+
+ Returns a tuple (DB_ALLOWED, SETTINGS)
+ """
+ overrides = (True, {})
+ if hasattr(djangosettings, 'LIVESETTINGS_OPTIONS'):
+ if siteid == -1:
+ siteid = _safe_get_siteid(None)
+
+ opts = djangosettings.LIVESETTINGS_OPTIONS
+ if opts.has_key(siteid):
+ opts = opts[siteid]
+ overrides = (opts.get('DB', True), opts['SETTINGS'])
+
+ return overrides
diff --git a/forum/deps/livesettings/signals.py b/forum/deps/livesettings/signals.py
new file mode 100644
index 00000000..ddea31f5
--- /dev/null
+++ b/forum/deps/livesettings/signals.py
@@ -0,0 +1,3 @@
+import django.dispatch
+
+configuration_value_changed = django.dispatch.Signal()
diff --git a/forum/deps/livesettings/templates/livesettings/_admin_site_views.html b/forum/deps/livesettings/templates/livesettings/_admin_site_views.html
new file mode 100644
index 00000000..17d08f58
--- /dev/null
+++ b/forum/deps/livesettings/templates/livesettings/_admin_site_views.html
@@ -0,0 +1,15 @@
+{% load i18n %}
+<div id="content-related">
+ <div class="module" id="sites-module">
+ <h2 class="module-title">{% trans 'Sites' %}</h2>
+ <div class="module-content">
+ <ul>
+ {% for label, link in links %}
+ <li>
+ <a href="{{ link }}">{{ label }}</a>
+ </li>
+ {% endfor %}
+ </ul>
+ </div>
+ </div>
+</div>
diff --git a/forum/deps/livesettings/templates/livesettings/group_settings.html b/forum/deps/livesettings/templates/livesettings/group_settings.html
new file mode 100644
index 00000000..e56f764f
--- /dev/null
+++ b/forum/deps/livesettings/templates/livesettings/group_settings.html
@@ -0,0 +1,81 @@
+{% extends "admin/base_site.html" %}
+{% load i18n admin_modify config_tags %}
+{% block extrastyle %}
+{{ block.super }}
+<link rel="stylesheet" type="text/css" href="{% load adminmedia %}{% admin_media_prefix %}css/base.css" />
+{% endblock %}
+
+{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/forms.css{% endblock %}
+{% block coltype %}colMS{% endblock %}
+{% block bodyclass %}dashboard{% endblock %}
+{% block userlinks %}<a href="/admin/doc/">{% trans 'Documentation' %}</a> / <a href="/admin/password_change/">{% trans 'Change password' %}</a> / <a href="/admin/logout/">{% trans 'Log out' %}</a>{% endblock %}
+{% block breadcrumbs %}{% if not is_popup %}
+<div class="breadcrumbs">
+ <a href="/admin/">{% trans "Home" %}</a> &rsaquo;
+ {% trans "Edit Group Settings" %}
+</div>
+{% endif %}{% endblock %}
+{% block content %}
+<div id="content-main">
+{% if form.errors %}
+ <p class="errornote">
+ {% blocktrans count form.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
+ </p>
+{% endif %}
+{% if form.fields %}
+<form method="post">
+ <div class="module">
+ <table summary="{% filter capfirst %}{% blocktrans with group.name as name %}Settings included in {{ name }}.{% endblocktrans %}{% endfilter %}" width="100%">
+ {% for field in form %}
+ {% if field.is_hidden %}
+ <!-- skip hidden field {{field.key}} -->
+ {% else %}
+ {% if field.errors %}
+ <tr class="error">
+ <td colspan="2">{{ field.errors }}</td>
+ </tr>
+ {% endif %}
+ <tr{% if field.errors %} class="error"{% endif %}>
+ <td style="width: 50%;">
+ {{ field.label_tag }}
+ {% if field.help_text %}
+ <p class="help">{{ field.help_text|safe }}</p>
+ {% endif %}
+ {% if field.field.default_text %}
+ <p class="help">{{ field.field.default_text|safe }}</p>
+ {% endif %}
+ </td>
+ <td>{{ field }}</td>
+ </tr>
+ {% endif %}
+ {% endfor %}
+ </table>
+ {% for field in form %}
+ {% if field.is_hidden %}
+ {{field}}
+ {% endif %}
+ {% endfor %}
+ </div>
+ <input type="submit" value="Save" class="default" />
+</form>
+{% else %}
+ <p>{% trans "You don't have permission to edit values." %}</p>
+{% endif %}
+</div>
+{% if all_groups %}
+<div id="content-related">
+ <div class="module">
+ <h2>{% trans "Setting groups" %}</h2>
+ <ul>
+ {% for g in all_groups %}
+ {% ifequal g.key group.key %}
+ <li><b>{{g.name}}</b></li>
+ {% else %}
+ <li><a href="{% url group_settings g.key %}">{{g.name}}</a></li>
+ {% endifequal %}
+ {% endfor %}
+ </ul>
+ </div>
+</div>
+{% endif %}
+{% endblock %}
diff --git a/forum/deps/livesettings/templates/livesettings/site_settings.html b/forum/deps/livesettings/templates/livesettings/site_settings.html
new file mode 100644
index 00000000..35333778
--- /dev/null
+++ b/forum/deps/livesettings/templates/livesettings/site_settings.html
@@ -0,0 +1,101 @@
+{% extends "admin/base_site.html" %}
+{% load i18n admin_modify config_tags %}
+
+{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/forms.css{% endblock %}
+{% block extrahead %}
+<script type="text/javascript" src="{% url admin:jsi18n %}"></script>
+<script type="text/javascript" src="{% admin_media_prefix %}js/core.js"></script>
+<script type="text/javascript" src="{% admin_media_prefix %}js/admin/CollapsedFieldsets.js"></script>
+{% endblock %}
+{% block extrastyle %}
+{{ block.super }}
+<link rel="stylesheet" type="text/css" href="{% load adminmedia %}{% admin_media_prefix %}css/base.css" />
+<style type="text/css">
+ul.fieldref { margin: 0; padding: 0; font-size: 9px; }
+ul.fieldref li { float: left; margin: 0 10px 0 0; list-style: none; }
+fieldset.collapsed h2 { display: block !important; }
+fieldset.collapsed h2 a { display: inline !important; }
+div.fieldcontainer { float: left; margin-right: 0; }
+</style>
+{% endblock %}
+{% block coltype %}colMS{% endblock %}
+{% block bodyclass %}dashboard{% endblock %}
+{% block userlinks %}<a href="/admin/doc/">{% trans 'Documentation' %}</a> / <a href="/admin/password_change/">{% trans 'Change password' %}</a> / <a href="/admin/logout/">{% trans 'Log out' %}</a>{% endblock %}
+{% block breadcrumbs %}{% if not is_popup %}
+<div class="breadcrumbs">
+ <a href="/admin/">{% trans "Home" %}</a> &rsaquo;
+ {% trans "Edit Site Settings" %}
+</div>
+{% endif %}{% endblock %}
+{% block content %}
+{% comment %}
+<div class="fieldcontainer">
+<ul class="fieldref">
+{% for group in form.groups %}
+ <li><a onclick="javascript:CollapsedFieldsets.show({{ forloop.counter0 }});" href="#{{ group.key }}">{{ group.name }}</a></li>
+{% endfor %}
+</ul>
+</div>
+{% endcomment %}
+<span style="clear: both;" />
+<div id="content-main">
+{% if not use_db %}
+ <p>{% trans "Livesettings are disabled for this site." %}</p>
+ <p>{% trans "All configuration options must be edited in the site settings.py file" %}</p>
+ </div>
+ {% admin_site_views 'satchmo_site_settings' %}
+{% else %}
+ {% if form.errors %}
+ <p class="errornote">
+ {% blocktrans count form.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
+ </p>
+ {% endif %}
+ {% if form.fields %}
+ <form method="post">
+ {% for field in form %}
+ {% if field.is_hidden %}
+ {{ field }}
+ {% else %}
+ {% ifchanged field.field.group %}{% with field.field.group as group %}
+ {% if not forloop.first %}
+ </table>
+ </fieldset>
+ {% endif %}
+ <fieldset class="module collapse">
+ <h2 id="{{ group.key }}">{{ group.name }}</h2>
+ <table summary="{% blocktrans with group.name as name %}Group settings: {{ name }}{% endblocktrans %}" style="width: 100%">
+ {% endwith %}{% endifchanged %}
+
+ {% if field.errors %}
+ <tr class="error">
+ <td colspan="2">{{ field.errors }}</td>
+ </tr>
+ {% endif %}
+ <tr{% if field.errors %} class="error"{% endif %}>
+ <td style="width: 50%;">
+ {{ field.label_tag }}
+ {% if field.help_text %}
+ <p class="help">{{ field.help_text|break_at:40|safe }}</p>
+ {% endif %}
+ {% if field.field.default_text %}
+ <p class="help">{{ field.field.default_text|break_at:40}}</p>
+ {% endif %}
+ </td>
+ <td>{{ field }}</td>
+ </tr>
+ {% endif %}
+ {% endfor %}
+ </table>
+ </div>
+ {% admin_site_views 'satchmo_site_settings' %}
+ <br class="clear:both;" />
+ <input type="submit" value="Save" class="default" />
+ <p><a onclick="javascript:CollapsedFieldsets.uncollapse_all(); return false;" href="#">{% trans 'Uncollapse all' %}</a></p>
+ <p><a href="{% url settings_export %}">Export</a></p>
+ </form>
+ {% else %}
+ <p>{% trans "You don't have permission to edit values." %}</p>
+ {% endif %}
+{% endif %}
+</div>
+{% endblock %}
diff --git a/forum/deps/livesettings/templates/livesettings/text.txt b/forum/deps/livesettings/templates/livesettings/text.txt
new file mode 100644
index 00000000..d57a57e3
--- /dev/null
+++ b/forum/deps/livesettings/templates/livesettings/text.txt
@@ -0,0 +1 @@
+{{ text|safe }} \ No newline at end of file
diff --git a/forum/deps/livesettings/templatetags/__init__.py b/forum/deps/livesettings/templatetags/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/forum/deps/livesettings/templatetags/__init__.py
diff --git a/forum/deps/livesettings/templatetags/config_tags.py b/forum/deps/livesettings/templatetags/config_tags.py
new file mode 100644
index 00000000..140014ba
--- /dev/null
+++ b/forum/deps/livesettings/templatetags/config_tags.py
@@ -0,0 +1,91 @@
+from django import template
+from django.contrib.sites.models import Site
+from django.core import urlresolvers
+from forum.deps.livesettings import config_value
+from forum.deps.livesettings.utils import url_join
+import logging
+
+log = logging.getLogger('configuration.config_tags')
+
+register = template.Library()
+
+def force_space(value, chars=40):
+ """Forces spaces every `chars` in value"""
+
+ chars = int(chars)
+ if len(value) < chars:
+ return value
+ else:
+ out = []
+ start = 0
+ end = 0
+ looping = True
+
+ while looping:
+ start = end
+ end += chars
+ out.append(value[start:end])
+ looping = end < len(value)
+
+ return ' '.join(out)
+
+def break_at(value, chars=40):
+ """Force spaces into long lines which don't have spaces"""
+ #todo: EF - lazy patch
+ return value
+
+ chars = int(chars)
+ value = unicode(value)
+ if len(value) < chars:
+ return value
+ else:
+ out = []
+ line = value.split(' ')
+ for word in line:
+ if len(word) > chars:
+ out.append(force_space(word, chars))
+ else:
+ out.append(word)
+
+ return " ".join(out)
+
+register.filter('break_at', break_at)
+
+def config_boolean(option):
+ """Looks up the configuration option, returning true or false."""
+ args = option.split('.')
+ try:
+ val = config_value(*args)
+ except:
+ log.warn('config_boolean tag: Tried to look up config setting "%s", got SettingNotSet, returning False', option)
+ val = False
+ if val:
+ return "true"
+ else:
+ return ""
+
+register.filter('config_boolean', config_boolean)
+
+def admin_site_views(view):
+ """Returns a formatted list of sites, rendering for view, if any"""
+
+ if view:
+ path = urlresolvers.reverse(view)
+ else:
+ path = None
+
+ links = []
+ for site in Site.objects.all():
+ paths = ["http://", site.domain]
+ if path:
+ paths.append(path)
+
+ links.append((site.name, url_join(paths)))
+
+ ret = {
+ 'links' : links,
+ }
+ return ret
+
+
+register.inclusion_tag('forum.deps.livesettings/_admin_site_views.html')(admin_site_views)
diff --git a/forum/deps/livesettings/tests.py b/forum/deps/livesettings/tests.py
new file mode 100644
index 00000000..f604af99
--- /dev/null
+++ b/forum/deps/livesettings/tests.py
@@ -0,0 +1,545 @@
+from django.conf import settings as djangosettings
+from django.test import TestCase
+import keyedcache
+from forum.deps.livesettings import *
+import logging
+log = logging.getLogger('test');
+
+class ConfigurationFunctionTest(TestCase):
+
+ def testSetSingleConfigItem(self):
+ value = IntegerValue(BASE_GROUP, 'SingleItem')
+ config_register(value)
+ self.assert_(config_exists(BASE_GROUP, 'SingleItem'))
+
+ def testSetTwoConfigItems(self):
+ s = [IntegerValue(BASE_GROUP, 'testTwoA'), StringValue(BASE_GROUP, 'testTwoB')]
+ config_register_list(*s)
+
+ self.assert_(config_exists(BASE_GROUP, 'testTwoA'))
+ self.assert_(config_exists(BASE_GROUP, 'testTwoB'))
+
+ def testSetGroup(self):
+ g1 = ConfigurationGroup('test1','test1')
+ value = IntegerValue(g1, 'SingleGroupedItem')
+ config_register(value)
+ self.assertFalse(config_exists(BASE_GROUP, 'SingleGroupedItem'))
+ self.assert_(config_exists(g1, 'SingleGroupedItem'))
+
+
+class ConfigurationTestSettings(TestCase):
+
+ def setUp(self):
+ # clear out cache from previous runs
+ keyedcache.cache_delete()
+ g = ConfigurationGroup('test2','test2')
+ self.g = g
+ config_register(StringValue(g, 's1'))
+ config_register(IntegerValue(g, 's2', default=10))
+ config_register(IntegerValue(g, 's3', default=10))
+
+ def testSetSetting(self):
+ c = config_get('test2', 's1')
+ c.update('test')
+
+ self.assertEqual(c.value, 'test')
+ self.assertEqual(c.setting.value, 'test')
+
+ def testSettingDefault(self):
+ c = config_get('test2', 's2')
+ self.assertEqual(c.value, 10)
+
+ def testSetAndReset(self):
+ """Test setting one value and then updating"""
+ c = config_get('test2', 's1')
+ c.update('test1')
+
+ self.assertEqual(c.value, 'test1')
+
+ # should be true, since it is an update
+ self.assert_(c.update('test2'))
+ self.assertEqual(c.value, 'test2')
+
+ def testTwice(self):
+ """Config items should respond False to duplicate requests to update."""
+
+ c = config_get('test2', 's1')
+ c.update('test1')
+
+ self.assertFalse(c.update('test1'))
+
+
+ def testDeletesDefault(self):
+ c = config_get('test2', 's3')
+ # false because it isn't saving a default value
+ self.assertFalse(c.update(10))
+
+ self.assert_(c.update(20))
+ self.assertEqual(c.value, 20)
+ try:
+ s = c.setting
+ except SettingNotSet:
+ self.fail("Should have a setting now")
+
+ # now delete and go back to no setting by setting the default
+ self.assert_(c.update(10))
+ self.assertEqual(c.value, 10)
+
+ try:
+ s = c.setting
+ self.fail('Should throw SettingNotSet')
+ except SettingNotSet:
+ pass
+
+
+class ConfigTestDotAccess(TestCase):
+ def setUp(self):
+ # clear out cache from previous runs
+ keyedcache.cache_delete()
+
+ g = ConfigurationGroup('test3','test3')
+ self.g = g
+ c1 = config_register(BooleanValue(g, 's1', default=True))
+ c2 = config_register(IntegerValue(g, 's2', default=10))
+ c2.update(100)
+
+ def testDotAccess(self):
+ self.assert_(ConfigurationSettings().test3.s1.value)
+ self.assertEqual(ConfigurationSettings().test3.s2.value, 100)
+
+ def testSettingProperty(self):
+ c = config_get('test3','s2')
+ s = c.setting
+ self.assert_(s.value, 100)
+
+ def testDictValues(self):
+ d = self.g.dict_values()
+ self.assertEqual(d, {'s1': True, 's2' : 100})
+
+class ConfigTestModuleValue(TestCase):
+ def setUp(self):
+ # clear out cache from previous runs
+ keyedcache.cache_delete()
+
+ g = ConfigurationGroup('modules','module test')
+ self.g = g
+ self.c = config_register(ModuleValue(g, 'test'))
+
+ # def testModule(self):
+ # c = config_get('modules', 'test')
+ # c.update('satchmo_store')
+
+ # self.assert_(hasattr(self.c.value, 'get_version'))
+
+class ConfigTestSortOrder(TestCase):
+ def setUp(self):
+ # clear out cache from previous runs
+ keyedcache.cache_delete()
+
+ g1 = ConfigurationGroup('group1', 'Group 1', ordering=-1001)
+ g2 = ConfigurationGroup('group2', 'Group 2', ordering=-1002)
+ g3 = ConfigurationGroup('group3', 'Group 3', ordering=-1003)
+
+ self.g1 = g1
+ self.g2 = g2
+ self.g3 = g3
+
+ self.g1c1 = config_register(IntegerValue(g1, 'c1'))
+ self.g1c2 = config_register(IntegerValue(g1, 'c2'))
+ self.g1c3 = config_register(IntegerValue(g1, 'c3'))
+
+ self.g2c1 = config_register(IntegerValue(g2, 'c1'))
+ self.g2c2 = config_register(IntegerValue(g2, 'c2'))
+ self.g2c3 = config_register(IntegerValue(g2, 'c3'))
+
+ self.g3c1 = config_register(IntegerValue(g3, 'c1'))
+ self.g3c2 = config_register(IntegerValue(g3, 'c2'))
+ self.g3c3 = config_register(IntegerValue(g3, 'c3'))
+
+ def testGroupOrdering(self):
+ mgr = ConfigurationSettings()
+ self.assertEqual(mgr[2].key, self.g1.key)
+ self.assertEqual(mgr[1].key, self.g2.key)
+ self.assertEqual(mgr[0].key, self.g3.key)
+
+
+class TestMultipleValues(TestCase):
+
+ def setUp(self):
+ # clear out cache from previous runs
+ keyedcache.cache_delete()
+
+ g1 = ConfigurationGroup('m1', 'Multiple Group 1', ordering=1000)
+ self.g1 = g1
+
+ self.g1c1 = config_register(MultipleStringValue(g1,
+ 'c1',
+ choices=((1,'one'),(2,'two'),(3,'three'))))
+
+ def testSave(self):
+
+ c = config_get('m1','c1')
+ c.update([1,2])
+ self.assertEqual(c.value, [1,2])
+
+ def testAddChoice(self):
+
+ config_add_choice('m1','c1',(4, 'four'))
+ c = config_get('m1','c1')
+ self.assertEqual(c.choices, ((1,'one'),(2,'two'),(3,'three'),(4,'four')))
+
+ def testChoiceValues(self):
+ self.g1c1.update([1,2])
+
+ self.assertEqual(self.g1c1.value, [1,2])
+ self.assertEqual(self.g1c1.choice_values, [(1, 'one'),(2, 'two')])
+
+ choices = config_choice_values('m1', 'c1')
+ self.assertEqual(choices, [(1, 'one'),(2, 'two')])
+
+class TestMultipleValuesWithDefault(TestCase):
+
+ def setUp(self):
+ # clear out cache from previous runs
+ keyedcache.cache_delete()
+
+ g1 = ConfigurationGroup('mv2', 'Multiple Group 2', ordering=1000)
+ self.g1 = g1
+
+ self.g1c1 = config_register(MultipleStringValue(g1,
+ 'c1',
+ choices=((1,'one'),(2,'two'),(3,'three')),
+ default=[1,2]))
+
+ def testDefault(self):
+
+ c = config_get('mv2','c1')
+ self.assertEqual(c.value, [1,2])
+
+ c.update([1,2,3])
+ self.assertEqual(c.value, [1,2,3])
+
+class ConfigTestChoices(TestCase):
+
+ def testAddPreregisteredChoice(self):
+ """Test that we can register choices before the config is actually set up."""
+ config_add_choice('ctg1', 'c1', ('a', 'Item A'))
+ config_add_choice('ctg1', 'c1', ('b', 'Item B'))
+ config_add_choice('ctg1', 'c1', ('c', 'Item C'))
+
+ g1 = ConfigurationGroup('ctg1', 'Choice 1', ordering=1000)
+ config_register(StringValue(g1, 'c1'))
+
+ c = config_get('ctg1','c1')
+
+ self.assertEqual(c.choices, [('a','Item A'), ('b','Item B'), ('c','Item C')])
+
+
+class ConfigTestRequires(TestCase):
+
+ def setUp(self):
+ # clear out cache from previous runs
+ keyedcache.cache_delete()
+
+ g1 = ConfigurationGroup('req1', 'Requirements 1', ordering=1000)
+
+ self.g1 = g1
+
+ bool1 = config_register(BooleanValue(g1, 'bool1', default=False, ordering=1))
+ bool2 = config_register(BooleanValue(g1, 'bool2', ordering=2))
+
+ self.g1c1 = config_register(IntegerValue(g1, 'c1', requires=bool1, ordering=3))
+
+ self.g1c2 = config_register(IntegerValue(g1, 'c2', requires=bool2, ordering=4))
+ self.g1c3 = config_register(IntegerValue(g1, 'c3', ordering=5))
+
+ bool2.update(True)
+
+ def testSimpleRequires(self):
+
+ v = config_value('req1', 'bool2')
+ self.assertTrue(v)
+
+ keys = [cfg.key for cfg in self.g1]
+ self.assertEqual(keys, ['bool1', 'bool2', 'c2','c3'])
+
+ c = config_get('req1','bool1')
+ c.update(True)
+
+ keys = [cfg.key for cfg in self.g1]
+ self.assertEqual(keys, ['bool1', 'bool2', 'c1', 'c2', 'c3'])
+
+class ConfigTestRequiresChoices(TestCase):
+
+ def setUp(self):
+ # clear out cache from previous runs
+ keyedcache.cache_delete()
+
+ g1 = ConfigurationGroup('req2', 'Requirements 2', ordering=1000)
+
+ self.g1 = g1
+
+ choices1 = config_register(MultipleStringValue(BASE_GROUP, 'rc1', ordering=1))
+
+ self.g1c1 = config_register(IntegerValue(g1, 'c1', requires=choices1, ordering=3))
+ self.g1c2 = config_register(IntegerValue(g1, 'c2', requires=choices1, ordering=4))
+ self.g1c3 = config_register(IntegerValue(g1, 'c3', ordering=5))
+
+ choices1.update('c1')
+
+ g2 = ConfigurationGroup('req3', 'Requirements 3', ordering=1000)
+
+ self.g2 = g2
+
+ choices2 = config_register(StringValue(BASE_GROUP, 'choices2', ordering=1))
+
+ self.g2c1 = config_register(IntegerValue(g2, 'c1', requires=choices2, ordering=3))
+ self.g2c2 = config_register(IntegerValue(g2, 'c2', requires=choices2, ordering=4))
+ self.g2c3 = config_register(IntegerValue(g2, 'c3', requires=choices2, ordering=5))
+
+ choices2.update('c1')
+
+ def testSimpleRequiresChoices(self):
+
+ v = config_value('BASE', 'rc1')
+ self.assertEquals(v, ['c1'])
+
+ g = config_get_group('req2')
+ keys = [cfg.key for cfg in g]
+ self.assertEqual(keys, ['c1','c3'])
+
+ c = config_get('BASE', 'rc1')
+ c.update(['c1','c2'])
+
+ g = config_get_group('req2')
+ keys = [cfg.key for cfg in g]
+ self.assertEqual(keys, ['c1', 'c2', 'c3'])
+
+ def testRequiresSingleValue(self):
+ v = config_value('BASE', 'choices2')
+ self.assertEquals(v, 'c1')
+
+ keys = [cfg.key for cfg in self.g2]
+ self.assertEqual(keys, ['c1'])
+
+ c = config_get('BASE', 'choices2')
+ c.update('c2')
+
+ keys = [cfg.key for cfg in self.g2]
+ self.assertEqual(keys, ['c2'])
+
+class ConfigTestRequiresValue(TestCase):
+
+ def setUp(self):
+ # clear out cache from previous runs
+ keyedcache.cache_delete()
+
+ g1 = ConfigurationGroup('reqval', 'Requirements 3', ordering=1000)
+
+ self.g1 = g1
+
+ choices1 = config_register(MultipleStringValue(BASE_GROUP, 'valchoices', ordering=1))
+
+ self.g1c1 = config_register(IntegerValue(g1, 'c1', requires=choices1, requiresvalue='foo', ordering=3))
+ self.g1c2 = config_register(IntegerValue(g1, 'c2', requires=choices1, requiresvalue='bar', ordering=4))
+ self.g1c3 = config_register(IntegerValue(g1, 'c3', ordering=5))
+
+ choices1.update('foo')
+
+ g2 = ConfigurationGroup('reqval2', 'Requirements 4', ordering=1000)
+
+ self.g2 = g2
+
+ choices2 = config_register(StringValue(BASE_GROUP, 'valchoices2', ordering=1,
+ choices=(('a','test a'),('b', 'test b'),('c', 'test c'))))
+
+ self.g2c1 = config_register(IntegerValue(g2, 'c1', requires=choices2, requiresvalue='a', ordering=3))
+ self.g2c2 = config_register(IntegerValue(g2, 'c2', requires=choices2, requiresvalue='b', ordering=4))
+ self.g2c3 = config_register(IntegerValue(g2, 'c3', requires=choices2, requiresvalue='c', ordering=5))
+
+ choices2.update('a')
+
+ def testRequiresValue(self):
+ v = config_value('BASE', 'valchoices')
+ self.assertEquals(v, ['foo'])
+
+ g = config_get_group('reqval')
+
+ keys = [cfg.key for cfg in g]
+ self.assertEqual(keys, ['c1','c3'])
+
+ c = config_get('BASE', 'valchoices')
+ c.update(['foo','bar'])
+
+ g = config_get_group('reqval')
+ keys = [cfg.key for cfg in g]
+ self.assertEqual(keys, ['c1', 'c2', 'c3'])
+
+ def testRequiresSingleValue(self):
+ v = config_value('BASE', 'valchoices2')
+ self.assertEquals(v, 'a')
+
+ keys = [cfg.key for cfg in self.g2]
+ self.assertEqual(keys, ['c1'])
+
+ c = config_get('BASE', 'valchoices2')
+ c.update('b')
+
+ keys = [cfg.key for cfg in self.g2]
+ self.assertEqual(keys, ['c2'])
+
+class ConfigTestGroupRequires(TestCase):
+ def setUp(self):
+ # clear out cache from previous runs
+ keyedcache.cache_delete()
+
+ choices1 = config_register(MultipleStringValue(BASE_GROUP, 'groupchoice', ordering=1))
+ choices2 = config_register(MultipleStringValue(BASE_GROUP, 'groupchoice2', ordering=1))
+
+ g1 = ConfigurationGroup('groupreq', 'Requirements 4', ordering=1000, requires=choices1)
+ self.g1 = g1
+
+ self.g1c1 = config_register(IntegerValue(g1, 'c1', ordering=3))
+ self.g1c2 = config_register(IntegerValue(g1, 'c2', requires=choices2, requiresvalue='bar', ordering=4))
+ self.g1c3 = config_register(IntegerValue(g1, 'c3', ordering=5))
+
+ def testRequiresValue(self):
+ c = config_get('BASE', 'groupchoice')
+ self.assertEquals(c.value, [])
+
+ keys = [cfg.key for cfg in self.g1]
+ self.assertEqual(keys, [])
+
+ c2 = config_get('BASE', 'groupchoice2')
+ c2.update('bar')
+
+ keys = [cfg.key for cfg in self.g1]
+ self.assertEqual(keys, ['c2'])
+
+ c.update(['groupreq'])
+
+ keys = [cfg.key for cfg in self.g1]
+ self.assertEqual(keys, ['c1', 'c2', 'c3'])
+
+class ConfigCollectGroup(TestCase):
+ def setUp(self):
+ keyedcache.cache_delete()
+ choices = config_register(MultipleStringValue(BASE_GROUP, 'collect', ordering=1))
+ self.choices = choices
+
+ g1 = ConfigurationGroup('coll1', 'Collection 1')
+ g2 = ConfigurationGroup('coll2', 'Collection 2')
+ g3 = ConfigurationGroup('coll3', 'Collection 3')
+
+ g1c1 = config_register(StringValue(g1, 'test'))
+ g1c2 = config_register(StringValue(g1, 'test1'))
+ g2c1 = config_register(StringValue(g2, 'test'))
+ g3c1 = config_register(StringValue(g3, 'test'))
+
+ g1c1.update('set a')
+ g1c2.update('set b')
+ g2c1.update('set a')
+ g3c1.update('set d')
+
+ choices.update(['coll1','coll3'])
+
+ def testCollectSimple(self):
+ v = config_collect_values('BASE', 'collect', 'test')
+
+ self.assertEqual(v, ['set a', 'set d'])
+
+ def testCollectUnique(self):
+ self.choices.update(['coll1','coll2','coll3'])
+
+ v = config_collect_values('BASE', 'collect', 'test', unique=False)
+
+ self.assertEqual(v, ['set a', 'set a', 'set d'])
+
+ v = config_collect_values('BASE', 'collect', 'test', unique=True)
+
+ self.assertEqual(v, ['set a', 'set d'])
+
+class LongSettingTest(TestCase):
+ def setUp(self):
+ keyedcache.cache_delete()
+ wide = config_register(LongStringValue(BASE_GROUP, 'LONG', ordering=1, default="woot"))
+ self.wide = wide
+ self.wide.update('*' * 1000)
+
+ def testLongStorage(self):
+ w = config_value('BASE', 'LONG')
+ self.assertEqual(len(w), 1000)
+ self.assertEqual(w, '*'*1000)
+
+ def testShortInLong(self):
+ self.wide.update("test")
+ w = config_value('BASE', 'LONG')
+ self.assertEqual(len(w), 4)
+ self.assertEqual(w, 'test')
+
+ def testDelete(self):
+ remember = self.wide.setting.id
+ self.wide.update('woot')
+
+ try:
+ q = LongSetting.objects.get(pk = remember)
+ self.fail("Should be deletec")
+ except LongSetting.DoesNotExist:
+ pass
+
+class OverrideTest(TestCase):
+ """Test settings overrides"""
+ def setUp(self):
+ # clear out cache from previous runs
+ keyedcache.cache_delete()
+
+ djangosettings.LIVESETTINGS_OPTIONS = {
+ 1 : {
+ 'DB' : False,
+ 'SETTINGS' : {
+ 'overgroup' : {
+ 's2' : '100',
+ 'choices' : '["one","two","three"]'
+ }
+ }
+ }
+ }
+
+ g = ConfigurationGroup('overgroup','Override Group')
+ self.g = g
+ config_register(StringValue(g, 's1'))
+ config_register(IntegerValue(g, 's2', default=10))
+ config_register(IntegerValue(g, 's3', default=10))
+ config_register(MultipleStringValue(g, 'choices'))
+
+ def tearDown(self):
+ djangosettings.LIVESETTINGS_OPTIONS = {}
+
+ def testOverriddenSetting(self):
+ """Accessing an overridden setting should give the override value."""
+ c = config_get('overgroup', 's2')
+ self.assertEquals(c.value, 100)
+
+ def testCantChangeSetting(self):
+ """When overridden, setting a value should not work, should get the overridden value"""
+ c = config_get('overgroup', 's2')
+ c.update(1)
+
+ c = config_get('overgroup', 's2')
+ self.assertEquals(c.value, 100)
+
+ def testNotOverriddenSetting(self):
+ """Settings which are not overridden should return their defaults"""
+ c = config_get('overgroup', 's3')
+
+ self.assertEquals(c.value, 10)
+
+ def testOverriddenListSetting(self):
+ """Make sure lists work when overridden"""
+
+ c = config_get('overgroup', 'choices')
+ v = c.value
+ self.assertEqual(len(v), 3)
+ self.assertEqual(v[0], "one")
+ self.assertEqual(v[1], "two")
+ self.assertEqual(v[2], "three")
diff --git a/forum/deps/livesettings/urls.py b/forum/deps/livesettings/urls.py
new file mode 100644
index 00000000..4d2bf0f2
--- /dev/null
+++ b/forum/deps/livesettings/urls.py
@@ -0,0 +1,7 @@
+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('forum.deps.livesettings.views',
+ url(r'^$', 'site_settings', {}, name='site_settings'),
+ url(r'^export/$', 'export_as_python', {}, name='settings_export'),
+ url(r'^(?P<group>[^/]+)/$', 'group_settings', name='group_settings'),
+)
diff --git a/forum/deps/livesettings/utils.py b/forum/deps/livesettings/utils.py
new file mode 100644
index 00000000..c0e0e293
--- /dev/null
+++ b/forum/deps/livesettings/utils.py
@@ -0,0 +1,87 @@
+import sys
+import types
+import os
+
+def can_loop_over(maybe):
+ """Test value to see if it is list like"""
+ try:
+ iter(maybe)
+ except:
+ return 0
+ else:
+ return 1
+
+def is_list_or_tuple(maybe):
+ return isinstance(maybe, (types.TupleType, types.ListType))
+
+
+def is_scalar(maybe):
+ """Test to see value is a string, an int, or some other scalar type"""
+ return is_string_like(maybe) or not can_loop_over(maybe)
+
+def is_string_like(maybe):
+ """Test value to see if it acts like a string"""
+ try:
+ maybe+""
+ except TypeError:
+ return 0
+ else:
+ return 1
+
+
+def flatten_list(sequence, scalarp=is_scalar, result=None):
+ """flatten out a list by putting sublist entries in the main list"""
+ if result is None:
+ result = []
+
+ for item in sequence:
+ if scalarp(item):
+ result.append(item)
+ else:
+ flatten_list(item, scalarp, result)
+
+def load_module(module):
+ """Load a named python module."""
+ try:
+ module = sys.modules[module]
+ except KeyError:
+ __import__(module)
+ module = sys.modules[module]
+ return module
+
+def get_flat_list(sequence):
+ """flatten out a list and return the flat list"""
+ flat = []
+ flatten_list(sequence, result=flat)
+ return flat
+
+def url_join(*args):
+ """Join any arbitrary strings into a forward-slash delimited string.
+ Do not strip leading / from first element, nor trailing / from last element.
+
+ This function can take lists as arguments, flattening them appropriately.
+
+ example:
+ url_join('one','two',['three','four'],'five') => 'one/two/three/four/five'
+ """
+ if len(args) == 0:
+ return ""
+
+ args = get_flat_list(args)
+
+ if len(args) == 1:
+ return str(args[0])
+
+ else:
+ args = [str(arg).replace("\\", "/") for arg in args]
+
+ work = [args[0]]
+ for arg in args[1:]:
+ if arg.startswith("/"):
+ work.append(arg[1:])
+ else:
+ work.append(arg)
+
+ joined = reduce(os.path.join, work)
+
+ return joined.replace("\\", "/")
diff --git a/forum/deps/livesettings/values.py b/forum/deps/livesettings/values.py
new file mode 100644
index 00000000..f00fdc97
--- /dev/null
+++ b/forum/deps/livesettings/values.py
@@ -0,0 +1,628 @@
+"""Taken and modified from the dbsettings project.
+
+http://code.google.com/p/django-values/
+"""
+from decimal import Decimal
+from django import forms
+from django.core.exceptions import ImproperlyConfigured
+from django.utils import simplejson
+from django.utils.datastructures import SortedDict
+from django.utils.encoding import smart_str
+from django.utils.translation import gettext, ugettext_lazy as _
+from forum.deps.livesettings.models import find_setting, LongSetting, Setting, SettingNotSet
+from forum.deps.livesettings.overrides import get_overrides
+from forum.deps.livesettings.utils import load_module, is_string_like, is_list_or_tuple
+import datetime
+import logging
+import signals
+
+__all__ = ['BASE_GROUP', 'ConfigurationGroup', 'Value', 'BooleanValue', 'DecimalValue', 'DurationValue',
+ 'FloatValue', 'IntegerValue', 'ModuleValue', 'PercentValue', 'PositiveIntegerValue', 'SortedDotDict',
+ 'StringValue', 'LongStringValue', 'MultipleStringValue']
+
+_WARN = {}
+
+log = logging.getLogger('configuration')
+
+NOTSET = object()
+
+class SortedDotDict(SortedDict):
+
+ def __getattr__(self, key):
+ try:
+ return self[key]
+ except:
+ raise AttributeError, key
+
+ def __iter__(self):
+ vals = self.values()
+ for k in vals:
+ yield k
+
+ def values(self):
+ vals = super(SortedDotDict, self).values()
+ vals = [v for v in vals if isinstance(v, (ConfigurationGroup, Value))]
+ vals.sort()
+ return vals
+
+class ConfigurationGroup(SortedDotDict):
+ """A simple wrapper for a group of configuration values"""
+ def __init__(self, key, name, *args, **kwargs):
+ """Create a new ConfigurationGroup.
+
+ Arguments:
+ - key
+ - group name - for display to user
+
+ Named Arguments:
+ - ordering: integer, optional, defaults to 1.
+ - requires: See `Value` requires. The default `requires` all member values will have if not overridden.
+ - requiresvalue: See `Values` requires_value. The default `requires_value` if not overridden on the `Value` objects.
+ """
+ self.key = key
+ self.name = name
+ self.ordering = kwargs.pop('ordering', 1)
+ self.requires = kwargs.pop('requires', None)
+ if self.requires:
+ reqval = kwargs.pop('requiresvalue', key)
+ if not is_list_or_tuple(reqval):
+ reqval = (reqval, reqval)
+
+ self.requires_value = reqval[0]
+ self.requires.add_choice(reqval)
+
+ super(ConfigurationGroup, self).__init__(*args, **kwargs)
+
+ def __cmp__(self, other):
+ return cmp((self.ordering, self.name), (other.ordering, other.name))
+
+ def __eq__(self, other):
+ return (type(self) == type(other)
+ and self.ordering == other.ordering
+ and self.name == other.name)
+
+ def __ne__(self, other):
+ return not self == other
+
+ def dict_values(self, load_modules=True):
+ vals = {}
+ keys = super(ConfigurationGroup, self).keys()
+ for key in keys:
+ v = self[key]
+ if isinstance(v, Value):
+ value = v.value
+ else:
+ value = v
+ vals[key] = value
+ return vals
+
+ def values(self):
+ vals = super(ConfigurationGroup, self).values()
+ return [v for v in vals if v.enabled()]
+
+BASE_GROUP = ConfigurationGroup('BASE', _('Base Settings'), ordering=0)
+
+class Value(object):
+
+ creation_counter = 0
+
+ def __init__(self, group, key, **kwargs):
+ """
+ Create a new Value object for configuration.
+
+ Args:
+ - `ConfigurationGroup`
+ - key - a string key
+
+ Named arguments:
+ - `description` - Will be passed to the field for form usage. Should be a translation proxy. Ex: _('example')
+ - `help_text` - Will be passed to the field for form usage.
+ - `choices` - If given, then the form field will use a select box
+ - `ordering` - Defaults to alphabetical by key if not given.
+ - `requires` - If given as a `Value`, then this field will only be rendered if that Value evaluates true (for Boolean requires) or the proper key is in the associated value.
+ - `requiresvalue` - If set, then this field will only be rendered if that value is in the list returned by self.value. Defaults to self.key.
+ - `hidden` - If true, then render a hidden field.
+ - `default` - If given, then this Value will return that default whenever it has no assocated `Setting`.
+ - `update_callback` - if given, then this value will call the callback whenever updated
+ """
+ self.group = group
+ self.key = key
+ self.description = kwargs.get('description', None)
+ self.help_text = kwargs.get('help_text')
+ self.choices = kwargs.get('choices',[])
+ self.ordering = kwargs.pop('ordering', 0)
+ self.hidden = kwargs.pop('hidden', False)
+ self.update_callback = kwargs.pop('update_callback', None)
+ self.requires = kwargs.pop('requires', None)
+ if self.requires:
+ reqval = kwargs.pop('requiresvalue', key)
+ if not is_list_or_tuple(reqval):
+ reqval = (reqval, reqval)
+
+ self.requires_value = reqval[0]
+ self.requires.add_choice(reqval)
+
+ elif group.requires:
+ self.requires = group.requires
+ self.requires_value = group.requires_value
+
+ if kwargs.has_key('default'):
+ self.default = kwargs.pop('default')
+ self.use_default = True
+ else:
+ self.use_default = False
+
+ self.creation_counter = Value.creation_counter
+ Value.creation_counter += 1
+
+ def __cmp__(self, other):
+ return cmp((self.ordering, self.description, self.creation_counter), (other.ordering, other.description, other.creation_counter))
+
+ def __eq__(self, other):
+ if type(self) == type(other):
+ return self.value == other.value
+ else:
+ return self.value == other
+
+ def __iter__(self):
+ return iter(self.value)
+
+ def __unicode__(self):
+ return unicode(self.value)
+
+ def __str__(self):
+ return str(self.value)
+
+ def add_choice(self, choice):
+ """Add a choice if it doesn't already exist."""
+ if not is_list_or_tuple(choice):
+ choice = (choice, choice)
+ skip = False
+ for k, v in self.choices:
+ if k == choice[0]:
+ skip = True
+ break
+ if not skip:
+ self.choices += (choice, )
+
+ def choice_field(self, **kwargs):
+ if self.hidden:
+ kwargs['widget'] = forms.MultipleHiddenInput()
+ return forms.ChoiceField(choices=self.choices, **kwargs)
+
+ def _choice_values(self):
+ choices = self.choices
+ vals = self.value
+ return [x for x in choices if x[0] in vals]
+
+ choice_values = property(fget=_choice_values)
+
+ def copy(self):
+ new_value = self.__class__(self.key)
+ new_value.__dict__ = self.__dict__.copy()
+ return new_value
+
+ def _default_text(self):
+ if not self.use_default:
+ note = ""
+ else:
+ if self.default == "":
+ note = _('Default value: ""')
+
+ elif self.choices:
+ work = []
+ for x in self.choices:
+ if x[0] in self.default:
+ work.append(smart_str(x[1]))
+ note = gettext('Default value: ') + ", ".join(work)
+
+ else:
+ note = _("Default value: %s") % unicode(self.default)
+
+ return note
+
+ default_text = property(fget=_default_text)
+
+ def enabled(self):
+ enabled = False
+ try:
+ if not self.requires:
+ enabled = True
+ else:
+ v = self.requires.value
+ if self.requires.choices:
+ enabled = self.requires_value == v or self.requires_value in v
+ elif v:
+ enabled = True
+ except SettingNotSet:
+ pass
+ return enabled
+
+ def make_field(self, **kwargs):
+ if self.choices:
+ if self.hidden:
+ kwargs['widget'] = forms.MultipleHiddenInput()
+ field = self.choice_field(**kwargs)
+ else:
+ if self.hidden:
+ kwargs['widget'] = forms.HiddenInput()
+ field = self.field(**kwargs)
+
+ field.group = self.group
+ field.default_text = self.default_text
+ return field
+
+ def make_setting(self, db_value):
+ log.debug('new setting %s.%s', self.group.key, self.key)
+ return Setting(group=self.group.key, key=self.key, value=db_value)
+
+ def _setting(self):
+ return find_setting(self.group.key, self.key)
+
+ setting = property(fget = _setting)
+
+ def _value(self):
+ use_db, overrides = get_overrides()
+
+ if not use_db:
+ try:
+ val = overrides[self.group.key][self.key]
+ except KeyError:
+ if self.use_default:
+ val = self.default
+ else:
+ raise SettingNotSet('%s.%s is not in your LIVESETTINGS_OPTIONS' % (self.group.key, self.key))
+
+ else:
+ try:
+ val = self.setting.value
+
+ except SettingNotSet, sns:
+ if self.use_default:
+ val = self.default
+ if overrides:
+ # maybe override the default
+ grp = overrides.get(self.group.key, {})
+ if grp.has_key(self.key):
+ val = grp[self.key]
+ else:
+ val = NOTSET
+
+ except AttributeError, ae:
+ log.error("Attribute error: %s", ae)
+ log.error("%s: Could not get _value of %s", self.key, self.setting)
+ raise(ae)
+
+ except Exception, e:
+ global _WARN
+ log.error(e)
+ if str(e).find("configuration_setting") > -1:
+ if not _WARN.has_key('configuration_setting'):
+ log.warn('Error loading setting %s.%s from table, OK if you are in syncdb', self.group.key, self.key)
+ _WARN['configuration_setting'] = True
+
+ if self.use_default:
+ val = self.default
+ else:
+ raise ImproperlyConfigured("All settings used in startup must have defaults, %s.%s does not", self.group.key, self.key)
+ else:
+ import traceback
+ traceback.print_exc()
+ log.warn("Problem finding settings %s.%s, %s", self.group.key, self.key, e)
+ raise SettingNotSet("Startup error, couldn't load %s.%s" %(self.group.key, self.key))
+ return val
+
+ def update(self, value):
+ use_db, overrides = get_overrides()
+
+ if use_db:
+ current_value = self.value
+
+ new_value = self.to_python(value)
+ if current_value != new_value:
+ if self.update_callback:
+ new_value = apply(self.update_callback, (current_value, new_value))
+
+ db_value = self.get_db_prep_save(new_value)
+
+ try:
+ s = self.setting
+ s.value = db_value
+
+ except SettingNotSet:
+ s = self.make_setting(db_value)
+
+ if self.use_default and self.default == new_value:
+ if s.id:
+ log.info("Deleted setting %s.%s", self.group.key, self.key)
+ s.delete()
+ else:
+ log.info("Updated setting %s.%s = %s", self.group.key, self.key, value)
+ s.save()
+
+ signals.configuration_value_changed.send(self, old_value=current_value, new_value=new_value, setting=self)
+
+ return True
+ else:
+ log.debug('not updating setting %s.%s - forum.deps.livesettings db is disabled',self.group.key, self.key)
+
+ return False
+
+ @property
+ def value(self):
+ val = self._value()
+ return self.to_python(val)
+
+ @property
+ def editor_value(self):
+ val = self._value()
+ return self.to_editor(val)
+
+ # Subclasses should override the following methods where applicable
+
+ def to_python(self, value):
+ "Returns a native Python object suitable for immediate use"
+ if value == NOTSET:
+ value = None
+ return value
+
+ def get_db_prep_save(self, value):
+ "Returns a value suitable for storage into a CharField"
+ if value == NOTSET:
+ value = ""
+ return unicode(value)
+
+ def to_editor(self, value):
+ "Returns a value suitable for display in a form widget"
+ if value == NOTSET:
+ return NOTSET
+ return unicode(value)
+
+###############
+# VALUE TYPES #
+###############
+
+class BooleanValue(Value):
+
+ class field(forms.BooleanField):
+
+ def __init__(self, *args, **kwargs):
+ kwargs['required'] = False
+ forms.BooleanField.__init__(self, *args, **kwargs)
+
+ def add_choice(self, choice):
+ # ignore choice adding for boolean types
+ pass
+
+ def to_python(self, value):
+ if value in (True, 't', 'True', 1, '1'):
+ return True
+ return False
+
+ to_editor = to_python
+
+class DecimalValue(Value):
+ class field(forms.DecimalField):
+
+ def __init__(self, *args, **kwargs):
+ kwargs['required'] = False
+ forms.DecimalField.__init__(self, *args, **kwargs)
+
+ def to_python(self, value):
+ if value==NOTSET:
+ return Decimal("0")
+
+ try:
+ return Decimal(value)
+ except TypeError, te:
+ log.warning("Can't convert %s to Decimal for settings %s.%s", value, self.group.key, self.key)
+ raise TypeError(te)
+
+ def to_editor(self, value):
+ if value == NOTSET:
+ return "0"
+ else:
+ return unicode(value)
+
+# DurationValue has a lot of duplication and ugliness because of issue #2443
+# Until DurationField is sorted out, this has to do some extra work
+class DurationValue(Value):
+
+ class field(forms.CharField):
+ def clean(self, value):
+ try:
+ return datetime.timedelta(seconds=float(value))
+ except (ValueError, TypeError):
+ raise forms.ValidationError('This value must be a real number.')
+ except OverflowError:
+ raise forms.ValidationError('The maximum allowed value is %s' % datetime.timedelta.max)
+
+ def to_python(self, value):
+ if value == NOTSET:
+ value = 0
+ if isinstance(value, datetime.timedelta):
+ return value
+ try:
+ return datetime.timedelta(seconds=float(value))
+ except (ValueError, TypeError):
+ raise forms.ValidationError('This value must be a real number.')
+ except OverflowError:
+ raise forms.ValidationError('The maximum allowed value is %s' % datetime.timedelta.max)
+
+ def get_db_prep_save(self, value):
+ if value == NOTSET:
+ return NOTSET
+ else:
+ return unicode(value.days * 24 * 3600 + value.seconds + float(value.microseconds) / 1000000)
+
+class FloatValue(Value):
+
+ class field(forms.FloatField):
+
+ def __init__(self, *args, **kwargs):
+ kwargs['required'] = False
+ forms.FloatField.__init__(self, *args, **kwargs)
+
+ def to_python(self, value):
+ if value == NOTSET:
+ value = 0
+ return float(value)
+
+ def to_editor(self, value):
+ if value == NOTSET:
+ return "0"
+ else:
+ return unicode(value)
+
+class IntegerValue(Value):
+ class field(forms.IntegerField):
+
+ def __init__(self, *args, **kwargs):
+ kwargs['required'] = False
+ forms.IntegerField.__init__(self, *args, **kwargs)
+
+ def to_python(self, value):
+ if value == NOTSET:
+ value = 0
+ return int(value)
+
+ def to_editor(self, value):
+ if value == NOTSET:
+ return "0"
+ else:
+ return unicode(value)
+
+
+class PercentValue(Value):
+
+ class field(forms.DecimalField):
+
+ def __init__(self, *args, **kwargs):
+ kwargs['required'] = False
+ forms.DecimalField.__init__(self, 100, 0, 5, 2, *args, **kwargs)
+
+ class widget(forms.TextInput):
+ def render(self, *args, **kwargs):
+ # Place a percent sign after a smaller text field
+ attrs = kwargs.pop('attrs', {})
+ attrs['size'] = attrs['max_length'] = 6
+ return forms.TextInput.render(self, attrs=attrs, *args, **kwargs) + '%'
+
+ def to_python(self, value):
+ if value == NOTSET:
+ value = 0
+ return Decimal(value) / 100
+
+ def to_editor(self, value):
+ if value == NOTSET:
+ return "0"
+ else:
+ return unicode(value)
+
+class PositiveIntegerValue(IntegerValue):
+
+ class field(forms.IntegerField):
+
+ def __init__(self, *args, **kwargs):
+ kwargs['min_value'] = 0
+ forms.IntegerField.__init__(self, *args, **kwargs)
+
+
+class StringValue(Value):
+
+ class field(forms.CharField):
+ def __init__(self, *args, **kwargs):
+ kwargs['required'] = False
+ forms.CharField.__init__(self, *args, **kwargs)
+
+ def to_python(self, value):
+ if value == NOTSET:
+ value = ""
+ return unicode(value)
+
+ to_editor = to_python
+
+class LongStringValue(Value):
+
+ class field(forms.CharField):
+ def __init__(self, *args, **kwargs):
+ kwargs['required'] = False
+ kwargs['widget'] = forms.Textarea()
+ forms.CharField.__init__(self, *args, **kwargs)
+
+ def make_setting(self, db_value):
+ log.debug('new long setting %s.%s', self.group.key, self.key)
+ return LongSetting(group=self.group.key, key=self.key, value=db_value)
+
+ def to_python(self, value):
+ if value == NOTSET:
+ value = ""
+ return unicode(value)
+
+ to_editor = to_python
+
+
+class MultipleStringValue(Value):
+
+ class field(forms.CharField):
+
+ def __init__(self, *args, **kwargs):
+ kwargs['required'] = False
+ forms.CharField.__init__(self, *args, **kwargs)
+
+ def choice_field(self, **kwargs):
+ kwargs['required'] = False
+ return forms.MultipleChoiceField(choices=self.choices, **kwargs)
+
+ def get_db_prep_save(self, value):
+ if is_string_like(value):
+ value = [value]
+ return simplejson.dumps(value)
+
+ def to_python(self, value):
+ if not value or value == NOTSET:
+ return []
+ if is_list_or_tuple(value):
+ return value
+ else:
+ try:
+ return simplejson.loads(value)
+ except:
+ if is_string_like(value):
+ return [value]
+ else:
+ log.warning('Could not decode returning empty list: %s', value)
+ return []
+
+
+ to_editor = to_python
+
+class ModuleValue(Value):
+ """Handles setting modules, storing them as strings in the db."""
+
+ class field(forms.CharField):
+
+ def __init__(self, *args, **kwargs):
+ kwargs['required'] = False
+ forms.CharField.__init__(self, *args, **kwargs)
+
+ def load_module(self, module):
+ """Load a child module"""
+ value = self._value()
+ if value == NOTSET:
+ raise SettingNotSet("%s.%s", self.group.key, self.key)
+ else:
+ return load_module("%s.%s" % (value, module))
+
+ def to_python(self, value):
+ if value == NOTSET:
+ v = {}
+ else:
+ v = load_module(value)
+ return v
+
+ def to_editor(self, value):
+ if value == NOTSET:
+ value = ""
+ return value
+
diff --git a/forum/deps/livesettings/views.py b/forum/deps/livesettings/views.py
new file mode 100644
index 00000000..ae78ca3f
--- /dev/null
+++ b/forum/deps/livesettings/views.py
@@ -0,0 +1,93 @@
+from django.http import HttpResponseRedirect
+from django.core.urlresolvers import reverse
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+from django.contrib.admin.views.decorators import staff_member_required
+from django.views.decorators.cache import never_cache
+from forum.deps.livesettings import ConfigurationSettings, forms
+from forum.deps.livesettings.overrides import get_overrides
+import logging
+
+log = logging.getLogger('configuration.views')
+
+def group_settings(request, group, template='forum.deps.livesettings/group_settings.html'):
+ # Determine what set of settings this editor is used for
+
+ use_db, overrides = get_overrides();
+
+ mgr = ConfigurationSettings()
+
+ settings = mgr[group]
+ title = settings.name
+ log.debug('title: %s', title)
+
+ if use_db:
+ # Create an editor customized for the current user
+ #editor = forms.customized_editor(settings)
+
+ if request.method == 'POST':
+ # Populate the form with user-submitted data
+ data = request.POST.copy()
+ form = forms.SettingsEditor(data, settings=settings)
+ if form.is_valid():
+ form.full_clean()
+ for name, value in form.cleaned_data.items():
+ group, key = name.split('__')
+ cfg = mgr.get_config(group, key)
+ if cfg.update(value):
+
+ # Give user feedback as to which settings were changed
+ request.user.message_set.create(message='Updated %s on %s' % (cfg.key, cfg.group.key))
+
+ return HttpResponseRedirect(request.path)
+ else:
+ # Leave the form populated with current setting values
+ #form = editor()
+ form = forms.SettingsEditor(settings=settings)
+ else:
+ form = None
+
+ return render_to_response(template, {
+ 'all_groups': mgr.groups(),
+ 'title': title,
+ 'group' : settings,
+ 'form': form,
+ 'use_db' : use_db
+ }, context_instance=RequestContext(request))
+group_settings = never_cache(staff_member_required(group_settings))
+
+# Site-wide setting editor is identical, but without a group
+# staff_member_required is implied, since it calls group_settings
+def site_settings(request):
+ mgr = ConfigurationSettings()
+ default_group= mgr.groups()[0].key
+ return HttpResponseRedirect(reverse('group_settings', args=[default_group]))
+ #return group_settings(request, group=None, template='forum.deps.livesettings/site_settings.html')
+
+def export_as_python(request):
+ """Export site settings as a dictionary of dictionaries"""
+
+ from forum.deps.livesettings.models import Setting, LongSetting
+ import pprint
+
+ work = {}
+ both = list(Setting.objects.all())
+ both.extend(list(LongSetting.objects.all()))
+
+ for s in both:
+ if not work.has_key(s.site.id):
+ work[s.site.id] = {}
+ sitesettings = work[s.site.id]
+
+ if not sitesettings.has_key(s.group):
+ sitesettings[s.group] = {}
+ sitegroup = sitesettings[s.group]
+
+ sitegroup[s.key] = s.value
+
+ pp = pprint.PrettyPrinter(indent=4)
+ pretty = pp.pformat(work)
+
+ return render_to_response('forum.deps.livesettings/text.txt', { 'text' : pretty }, mimetype='text/plain')
+
+export_as_python = never_cache(staff_member_required(export_as_python))