Merge branch 'master' of github.com:comoga/django-constance

This commit is contained in:
Jannis Leidel 2014-11-21 11:03:06 +01:00
commit d547eebd16
19 changed files with 306 additions and 22 deletions

View file

@ -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

View file

@ -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::

View file

@ -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'

View file

@ -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

10
constance/apps.py Normal file
View file

@ -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()

View file

@ -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())

View file

@ -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)

Binary file not shown.

View file

@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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ů"

Binary file not shown.

View file

@ -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 <EMAIL@ADDRESS>, 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 <morlandi@brainstorm.it>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"

Binary file not shown.

View file

@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 "Главная"

Binary file not shown.

View file

@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 "首页"

View file

@ -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)

View file

@ -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'

View file

@ -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

10
example/manage.py Executable file
View file

@ -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)