diff --git a/.travis.yml b/.travis.yml index dfb56ec..2c01a7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,13 @@ python: - 2.7 - 3.2 - 3.3 + - 3.4 + - "pypy" env: - DJANGO_VERSION=1.3.7 - - DJANGO_VERSION=1.4.5 - - DJANGO_VERSION=1.5.1 + - DJANGO_VERSION=1.4.13 + - DJANGO_VERSION=1.5.8 + - DJANGO_VERSION=1.6.5 install: - pip install Django==$DJANGO_VERSION - python setup.py install @@ -22,3 +25,11 @@ matrix: env: DJANGO_VERSION=1.4.5 - python: 3.3 env: DJANGO_VERSION=1.3.7 + - python: 3.4 + env: DJANGO_VERSION=1.4.5 + - python: 3.4 + env: DJANGO_VERSION=1.3.7 + - python: "pypy" + env: DJANGO_VERSION=1.4.5 + - python: "pypy" + env: DJANGO_VERSION=1.3.7 diff --git a/README.rst b/README.rst index 0730ad8..ea0e4f1 100644 --- a/README.rst +++ b/README.rst @@ -72,7 +72,7 @@ Redis (default) CONSTANCE_BACKEND = 'constance.backends.redisd.RedisBackend' -The is the default backend and has a couple of options: +This is the default backend and has a couple of options: * ``CONSTANCE_REDIS_CONNECTION`` @@ -108,7 +108,7 @@ Database CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend' -If you want to use this backend you also need to add the databse backend +If you want to use this backend you also need to add the database backend to your ``INSTALLED_APPS`` setting to make sure the data model is correctly created:: diff --git a/constance/__init__.py b/constance/__init__.py index 3f6145f..52b7b0c 100644 --- a/constance/__init__.py +++ b/constance/__init__.py @@ -1,3 +1,8 @@ from constance.config import Config -config = Config() +try: + from django.apps import AppConfig +except ImportError: + config = Config() +else: + default_app_config = 'constance.apps.ConstanceConfig' diff --git a/constance/admin.py b/constance/admin.py index 9029551..c3ab6ce 100644 --- a/constance/admin.py +++ b/constance/admin.py @@ -21,7 +21,10 @@ except ImportError: # Django < 1.4 from django.conf.urls.defaults import patterns, url -from constance import config, settings +from constance import settings +from constance.config import Config as ConfigClass + +config = ConfigClass() NUMERIC_WIDGET = forms.TextInput(attrs={'size': 10}) @@ -37,6 +40,7 @@ FIELDS = { int: INTEGER_LIKE, Decimal: (fields.DecimalField, {'widget': NUMERIC_WIDGET}), str: STRING_LIKE, + list: STRING_LIKE, datetime: (fields.DateTimeField, {'widget': widgets.AdminSplitDateTime}), date: (fields.DateField, {'widget': widgets.AdminDateWidget}), time: (fields.TimeField, {'widget': widgets.AdminTimeWidget}), @@ -142,7 +146,7 @@ class Config(object): app_label = 'constance' object_name = 'Config' model_name = module_name = 'config' - verbose_name_plural = 'config' + verbose_name_plural = _('config') get_ordered_objects = lambda x: False abstract = False swapped = False diff --git a/constance/apps.py b/constance/apps.py new file mode 100644 index 0000000..264e545 --- /dev/null +++ b/constance/apps.py @@ -0,0 +1,10 @@ +from django.apps import AppConfig +from constance.config import Config +from django.utils.translation import ugettext_lazy as _ + +class ConstanceConfig(AppConfig): + name = 'constance' + verbose_name = _('Constance') + + def ready(self): + self.module.config = Config() diff --git a/constance/backends/database/__init__.py b/constance/backends/database/__init__.py index 3a447cb..a257974 100644 --- a/constance/backends/database/__init__.py +++ b/constance/backends/database/__init__.py @@ -65,4 +65,4 @@ class DatabaseBackend(Backend): def clear(self, sender, instance, created, **kwargs): if db_cache and not created: - db_cache.delete_many(settings.CONFIG.keys()) + db_cache.delete_many(self.add_prefix(k) for k in settings.CONFIG.keys()) diff --git a/constance/backends/redisd.py b/constance/backends/redisd.py index d32477d..688eee1 100644 --- a/constance/backends/redisd.py +++ b/constance/backends/redisd.py @@ -1,3 +1,4 @@ +import six from six.moves import zip from django.core.exceptions import ImproperlyConfigured @@ -25,7 +26,7 @@ class RedisBackend(Backend): except ImportError: raise ImproperlyConfigured( "The Redis backend requires redis-py to be installed.") - if isinstance(settings.REDIS_CONNECTION, basestring): + if isinstance(settings.REDIS_CONNECTION, six.string_types): self._rd = redis.from_url(settings.REDIS_CONNECTION) else: self._rd = redis.Redis(**settings.REDIS_CONNECTION) diff --git a/constance/locale/cs_CZ/LC_MESSAGES/django.mo b/constance/locale/cs_CZ/LC_MESSAGES/django.mo new file mode 100644 index 0000000..b39473c Binary files /dev/null and b/constance/locale/cs_CZ/LC_MESSAGES/django.mo differ diff --git a/constance/locale/cs_CZ/LC_MESSAGES/django.po b/constance/locale/cs_CZ/LC_MESSAGES/django.po new file mode 100644 index 0000000..f9b50bb --- /dev/null +++ b/constance/locale/cs_CZ/LC_MESSAGES/django.po @@ -0,0 +1,62 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-07-14 10:52+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: admin.py:98 +msgid "Live settings updated successfully." +msgstr "Nastavení bylo úspěšně uloženo." + +#: admin.py:103 +msgid "Constance config" +msgstr "Nastavení konstant" + +#: admin.py:146 +msgid "config" +msgstr "nastavení" + +#: backends/database/models.py:19 +msgid "constance" +msgstr "konstanta" + +#: backends/database/models.py:20 +msgid "constances" +msgstr "konstanty" + +#: templates/admin/constance/change_list.html:39 +msgid "Name" +msgstr "Název" + +#: templates/admin/constance/change_list.html:40 +msgid "Default" +msgstr "Výchozí hodnota" + +#: templates/admin/constance/change_list.html:41 +msgid "Value" +msgstr "Hodnota" + +#: templates/admin/constance/change_list.html:42 +msgid "Is modified" +msgstr "Je změněna?" + +#: templates/admin/constance/change_list.html:68 +msgid "Save" +msgstr "Uložit" + +#: templates/admin/constance/change_list.html:78 +msgid "Home" +msgstr "Domů" diff --git a/constance/locale/it/LC_MESSAGES/django.mo b/constance/locale/it/LC_MESSAGES/django.mo new file mode 100644 index 0000000..1cf26fc Binary files /dev/null and b/constance/locale/it/LC_MESSAGES/django.mo differ diff --git a/constance/locale/it/LC_MESSAGES/django.po b/constance/locale/it/LC_MESSAGES/django.po new file mode 100644 index 0000000..66589e7 --- /dev/null +++ b/constance/locale/it/LC_MESSAGES/django.po @@ -0,0 +1,59 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-02-12 06:57+0100\n" +"PO-Revision-Date: 2014-02-12 07:01+0100\n" +"Last-Translator: Mario Orlandi \n" +"Language-Team: LANGUAGE \n" +"Language: \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" + +#: admin.py:97 +msgid "Live settings updated successfully." +msgstr "Le impostazioni attive sono state aggiornate correttamente." + +#: admin.py:102 +msgid "Constance config" +msgstr "Configurazione Impostazioni" + +#: backends/database/models.py:19 +msgid "constance" +msgstr "impostazione" + +#: backends/database/models.py:20 +msgid "constances" +msgstr "impostazioni" + +#: templates/admin/constance/change_list.html:39 +msgid "Name" +msgstr "Nome" + +#: templates/admin/constance/change_list.html:40 +msgid "Default" +msgstr "Default" + +#: templates/admin/constance/change_list.html:41 +msgid "Value" +msgstr "Valore" + +#: templates/admin/constance/change_list.html:42 +msgid "Is modified" +msgstr "Modificato" + +#: templates/admin/constance/change_list.html:68 +msgid "Save" +msgstr "Salva" + +#: templates/admin/constance/change_list.html:78 +msgid "Home" +msgstr "Inizio" + diff --git a/constance/locale/ru/LC_MESSAGES/django.mo b/constance/locale/ru/LC_MESSAGES/django.mo new file mode 100644 index 0000000..99641a6 Binary files /dev/null and b/constance/locale/ru/LC_MESSAGES/django.mo differ diff --git a/constance/locale/ru/LC_MESSAGES/django.po b/constance/locale/ru/LC_MESSAGES/django.po new file mode 100644 index 0000000..d3bd180 --- /dev/null +++ b/constance/locale/ru/LC_MESSAGES/django.po @@ -0,0 +1,67 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-08-07 13:13+0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: admin.py:98 +msgid "Live settings updated successfully." +msgstr "Настройки успешно сохранены" + +#: admin.py:103 +msgid "Constance config" +msgstr "Настройки" + +#: admin.py:146 +msgid "config" +msgstr "настройки" + +#: apps.py:7 +#, fuzzy +msgid "Constance" +msgstr "настройки" + +#: backends/database/models.py:19 +msgid "constance" +msgstr "настройки" + +#: backends/database/models.py:20 +msgid "constances" +msgstr "настройки" + +#: templates/admin/constance/change_list.html:39 +msgid "Name" +msgstr "Название" + +#: templates/admin/constance/change_list.html:40 +msgid "Default" +msgstr "По умолчанию" + +#: templates/admin/constance/change_list.html:41 +msgid "Value" +msgstr "Текущее значение" + +#: templates/admin/constance/change_list.html:42 +msgid "Is modified" +msgstr "Было изменено" + +#: templates/admin/constance/change_list.html:68 +msgid "Save" +msgstr "Сохранить" + +#: templates/admin/constance/change_list.html:78 +msgid "Home" +msgstr "Главная" diff --git a/constance/locale/zh_CN/LC_MESSAGES/django.mo b/constance/locale/zh_CN/LC_MESSAGES/django.mo new file mode 100644 index 0000000..6ec0e0f Binary files /dev/null and b/constance/locale/zh_CN/LC_MESSAGES/django.mo differ diff --git a/constance/locale/zh_CN/LC_MESSAGES/django.po b/constance/locale/zh_CN/LC_MESSAGES/django.po new file mode 100644 index 0000000..46264bc --- /dev/null +++ b/constance/locale/zh_CN/LC_MESSAGES/django.po @@ -0,0 +1,63 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-04-01 19:00+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#: admin.py:97 +msgid "Live settings updated successfully." +msgstr "成功更新实时配置" + +#: admin.py:102 +msgid "Constance config" +msgstr "常量配置" + +#: admin.py:145 +msgid "config" +msgstr "配置" + +#: backends/database/models.py:19 +msgid "constance" +msgstr "常量" + +#: backends/database/models.py:20 +msgid "constances" +msgstr "常量" + +#: templates/admin/constance/change_list.html:39 +msgid "Name" +msgstr "名称" + +#: templates/admin/constance/change_list.html:40 +msgid "Default" +msgstr "默认值" + +#: templates/admin/constance/change_list.html:41 +msgid "Value" +msgstr "值" + +#: templates/admin/constance/change_list.html:42 +msgid "Is modified" +msgstr "是否修改" + +#: templates/admin/constance/change_list.html:68 +msgid "Save" +msgstr "保存" + +#: templates/admin/constance/change_list.html:78 +msgid "Home" +msgstr "首页" diff --git a/example/cheeseshop/manage.py b/example/cheeseshop/manage.py deleted file mode 100755 index 5e78ea9..0000000 --- a/example/cheeseshop/manage.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python -from django.core.management import execute_manager -try: - import settings # Assumed to be in the same directory. -except ImportError: - import sys - sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) - sys.exit(1) - -if __name__ == "__main__": - execute_manager(settings) diff --git a/example/cheeseshop/settings.py b/example/cheeseshop/settings.py index b13adcf..7d4a7c3 100644 --- a/example/cheeseshop/settings.py +++ b/example/cheeseshop/settings.py @@ -99,6 +99,7 @@ INSTALLED_APPS = ( 'cheeseshop.apps.catalog', 'cheeseshop.apps.storage', 'constance', + 'constance.backends.database', ) CONSTANCE_CONNECTION = { @@ -108,8 +109,10 @@ CONSTANCE_CONNECTION = { } CONSTANCE_CONFIG = { - 'BANNER': ('The National Cheese Emporium', 'name of the shop'), + 'BANNER': ('The National Cheese Emporium', 'name of the shop'), 'OWNER': ('Mr. Henry Wensleydale', 'owner of the shop'), 'MUSICIANS': (4, 'number of musicians inside the shop'), 'DATE_ESTABLISHED': (datetime(1972, 11, 30), "the shop's first opening"), } + +CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend' diff --git a/example/cheeseshop/urls.py b/example/cheeseshop/urls.py index 57ec253..b17590b 100644 --- a/example/cheeseshop/urls.py +++ b/example/cheeseshop/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import * from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.conf import settings diff --git a/example/manage.py b/example/manage.py new file mode 100755 index 0000000..0ea7766 --- /dev/null +++ b/example/manage.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cheeseshop.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv)