Commits

Hynek Cernoch committed 3681e76 Draft

Moved to similar names before merge

Comments (0)

Files changed (18)

livesettings/test_app/__init__.py

Empty file removed.

livesettings/test_app/localsite/__init__.py

Empty file removed.

livesettings/test_app/localsite/config.py

-from livesettings import config_register, ConfigurationGroup, PositiveIntegerValue, MultipleStringValue, ModuleValue
-from django.utils.translation import ugettext_lazy as _
-
-# First, setup a grup to hold all our possible configs
-MYAPP_GROUP = ConfigurationGroup('MyApp', _('My App Settings'), ordering=0)
-
-# Now, add our number of images to display value
-# If a user doesn't enter a value, default to 5
-config_register(PositiveIntegerValue(
-    MYAPP_GROUP,
-        'NUM_IMAGES',
-        description = _('Number of images to display'),
-        help_text = _("How many images to display on front page."),
-        default = 5
-    ))
-
-# Another example of allowing the user to select from several values
-config_register(MultipleStringValue(
-        MYAPP_GROUP,
-        'MEASUREMENT_SYSTEM',
-        description=_("Measurement System"),
-        help_text=_("Default measurement system to use."),
-        choices=[('metric',_('Metric')),
-                    ('imperial',_('Imperial'))],
-        default="imperial"
-    ))
-
-config_register(ModuleValue(
-        MYAPP_GROUP,
-        'MODULE',
-        #description=_("Measurement System"),
-        #help_text=_("Default measurement system to use."),
-        default="django"
-    ))

livesettings/test_app/localsite/models.py

-import config

livesettings/test_app/localsite/templates/myapp/index.html

-<html><body>
-<pre>
-<p>Measurement system: {{ measurement_system }}</p>
-<p>Image count: {{ image_count }}</p>
-<p><a href="{% url satchmo_site_settings %}">Values can be modified</a> if the user has sufficient permissions (livesettings_setting:change).</p>
-</body></html>

livesettings/test_app/localsite/views.py

-from django.shortcuts import render_to_response
-from livesettings import config_value
-
-def index(request):
-    image_count = config_value('MyApp','NUM_IMAGES')
-    # Note, the measurement_system will return a list of selected values
-    # in this case, we use the first one
-    measurement_system = config_value('MyApp','MEASUREMENT_SYSTEM')
-    return render_to_response('myapp/index.html',
-                            {'image_count': image_count,
-                            'measurement_system': measurement_system[0]})

livesettings/test_app/manage.py

-#!/usr/bin/env python
-import os.path
-import sys
-
-DIRNAME = os.path.dirname(__file__)
-
-if not DIRNAME in sys.path:
-    sys.path.append(DIRNAME)
-
-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)

livesettings/test_app/settings.py

-# Django settings.
-# If you have an existing project, then ensure that you modify local_settings-customize.py
-# and import it from your main settings file. (from local_settings import *)
-import os
-
-DIRNAME = os.path.dirname(__file__)
-
-DJANGO_PROJECT = 'test_app'
-DJANGO_SETTINGS_MODULE = 'test_app.settings'
-
-ADMINS = (
-     ('', ''),
-)
-
-MANAGERS = ADMINS
-
-DATABASES = {
-    'default': {
-        'ENGINE': 'django.db.backends.sqlite3',  # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'ado_mssql'.
-        'NAME': 'test.db',
-    }
-}
-
-# Local time zone for this installation. All choices can be found here:
-# http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
-TIME_ZONE = 'US/Pacific'
-
-# Language code for this installation. All choices can be found here:
-# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
-# http://blogs.law.harvard.edu/tech/stories/storyReader$15
-LANGUAGE_CODE = 'en-us'
-
-SITE_ID = 1
-
-# Absolute path to the directory that holds media.
-# Example: "/home/media/media.lawrence.com/"
-#Image files will be stored off of this path
-MEDIA_ROOT = os.path.join(DIRNAME, 'static/')
-#MEDIA_ROOT = "/static"
-# URL that handles the media served from MEDIA_ROOT.
-# Example: "http://media.lawrence.com"
-#MEDIA_URL = 'site_media'
-MEDIA_URL="/static/"
-# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
-# trailing slash.
-# Examples: "http://foo.com/media/", "/media/".
-ADMIN_MEDIA_PREFIX = '/media/'
-
-# Make this unique, and don't share it with anybody.
-SECRET_KEY = ''
-
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
-    'django.template.loaders.filesystem.Loader',
-    'django.template.loaders.app_directories.Loader',
-#     'django.template.loaders.eggs.load_template_source',
-)
-
-MIDDLEWARE_CLASSES = (
-    "django.middleware.common.CommonMiddleware",
-    "django.contrib.sessions.middleware.SessionMiddleware",
-    "django.middleware.locale.LocaleMiddleware",
-    "django.contrib.auth.middleware.AuthenticationMiddleware",
-    "django.contrib.messages.middleware.MessageMiddleware",
-    "django.middleware.doc.XViewMiddleware",
-    #'debug_toolbar.middleware.DebugToolbarMiddleware',
-)
-
-TEMPLATE_CONTEXT_PROCESSORS = ('django.contrib.auth.context_processors.auth',)
-
-ROOT_URLCONF = 'test_app.urls'
-
-INSTALLED_APPS = (
-    'django.contrib.sites',
-    'django.contrib.admin',
-    'django.contrib.auth',
-    'django.contrib.contenttypes',
-    'django.contrib.comments',
-    'django.contrib.flatpages',
-    'django.contrib.sessions',
-    'django.contrib.sitemaps',
-    'livesettings',
-    'test_app.localsite',
-)
-
-AUTHENTICATION_BACKENDS = (
-    'django.contrib.auth.backends.ModelBackend',
-)
-
-DEBUG_TOOLBAR_CONFIG = {
-   'INTERCEPT_REDIRECTS' : False,
-}
-
-CACHE_BACKEND = 'dummy:///'
-LIVESETTINGS_USE_KEYEDCACHE = False
-CACHE_PREFIX = 'T'
-CACHE_TIMEOUT = 300
-DEBUG = True

livesettings/test_app/urls.py

-from django.conf.urls.defaults import patterns, include
-from django.contrib import admin
-
-admin.autodiscover()
-
-urlpatterns = patterns('',
-    (r'^settings/', include('livesettings.urls')),
-    (r'^admin/', include(admin.site.urls)),
-    (r'^accounts/login/', 'django.contrib.auth.views.login', {'template_name': 'admin/login.html'}),
-    (r'^$', 'localsite.views.index')
-)

test-project/localsite/__init__.py

Empty file added.

test-project/localsite/config.py

+from livesettings import config_register, ConfigurationGroup, PositiveIntegerValue, MultipleStringValue, ModuleValue
+from django.utils.translation import ugettext_lazy as _
+
+# First, setup a grup to hold all our possible configs
+MYAPP_GROUP = ConfigurationGroup('MyApp', _('My App Settings'), ordering=0)
+
+# Now, add our number of images to display value
+# If a user doesn't enter a value, default to 5
+config_register(PositiveIntegerValue(
+    MYAPP_GROUP,
+        'NUM_IMAGES',
+        description = _('Number of images to display'),
+        help_text = _("How many images to display on front page."),
+        default = 5
+    ))
+
+# Another example of allowing the user to select from several values
+config_register(MultipleStringValue(
+        MYAPP_GROUP,
+        'MEASUREMENT_SYSTEM',
+        description=_("Measurement System"),
+        help_text=_("Default measurement system to use."),
+        choices=[('metric',_('Metric')),
+                    ('imperial',_('Imperial'))],
+        default="imperial"
+    ))
+
+config_register(ModuleValue(
+        MYAPP_GROUP,
+        'MODULE',
+        #description=_("Measurement System"),
+        #help_text=_("Default measurement system to use."),
+        default="django"
+    ))

test-project/localsite/models.py

+import config

test-project/localsite/templates/myapp/index.html

+<html><body>
+<pre>
+<p>Measurement system: {{ measurement_system }}</p>
+<p>Image count: {{ image_count }}</p>
+<p><a href="{% url satchmo_site_settings %}">Values can be modified</a> if the user has sufficient permissions (livesettings_setting:change).</p>
+</body></html>

test-project/localsite/views.py

+from django.shortcuts import render_to_response
+from livesettings import config_value
+
+def index(request):
+    image_count = config_value('MyApp','NUM_IMAGES')
+    # Note, the measurement_system will return a list of selected values
+    # in this case, we use the first one
+    measurement_system = config_value('MyApp','MEASUREMENT_SYSTEM')
+    return render_to_response('myapp/index.html',
+                            {'image_count': image_count,
+                            'measurement_system': measurement_system[0]})

test-project/manage.py

+#!/usr/bin/env python
+import os.path
+import sys
+
+DIRNAME = os.path.dirname(__file__)
+
+if not DIRNAME in sys.path:
+    sys.path.append(DIRNAME)
+
+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)

test-project/test_project/__init__.py

Empty file added.

test-project/test_project/settings.py

+# Django settings.
+# If you have an existing project, then ensure that you modify local_settings-customize.py
+# and import it from your main settings file. (from local_settings import *)
+import os
+
+DIRNAME = os.path.dirname(__file__)
+
+DJANGO_PROJECT = 'test_app'
+DJANGO_SETTINGS_MODULE = 'test_app.settings'
+
+ADMINS = (
+     ('', ''),
+)
+
+MANAGERS = ADMINS
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3',  # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'ado_mssql'.
+        'NAME': 'test.db',
+    }
+}
+
+# Local time zone for this installation. All choices can be found here:
+# http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
+TIME_ZONE = 'US/Pacific'
+
+# Language code for this installation. All choices can be found here:
+# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
+# http://blogs.law.harvard.edu/tech/stories/storyReader$15
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+#Image files will be stored off of this path
+MEDIA_ROOT = os.path.join(DIRNAME, 'static/')
+#MEDIA_ROOT = "/static"
+# URL that handles the media served from MEDIA_ROOT.
+# Example: "http://media.lawrence.com"
+#MEDIA_URL = 'site_media'
+MEDIA_URL="/static/"
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/media/'
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = ''
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+    'django.template.loaders.filesystem.Loader',
+    'django.template.loaders.app_directories.Loader',
+#     'django.template.loaders.eggs.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+    "django.middleware.common.CommonMiddleware",
+    "django.contrib.sessions.middleware.SessionMiddleware",
+    "django.middleware.locale.LocaleMiddleware",
+    "django.contrib.auth.middleware.AuthenticationMiddleware",
+    "django.contrib.messages.middleware.MessageMiddleware",
+    "django.middleware.doc.XViewMiddleware",
+    #'debug_toolbar.middleware.DebugToolbarMiddleware',
+)
+
+TEMPLATE_CONTEXT_PROCESSORS = ('django.contrib.auth.context_processors.auth',)
+
+ROOT_URLCONF = 'test_app.urls'
+
+INSTALLED_APPS = (
+    'django.contrib.sites',
+    'django.contrib.admin',
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.comments',
+    'django.contrib.flatpages',
+    'django.contrib.sessions',
+    'django.contrib.sitemaps',
+    'livesettings',
+    'test_app.localsite',
+)
+
+AUTHENTICATION_BACKENDS = (
+    'django.contrib.auth.backends.ModelBackend',
+)
+
+DEBUG_TOOLBAR_CONFIG = {
+   'INTERCEPT_REDIRECTS' : False,
+}
+
+CACHE_BACKEND = 'dummy:///'
+LIVESETTINGS_USE_KEYEDCACHE = False
+CACHE_PREFIX = 'T'
+CACHE_TIMEOUT = 300
+DEBUG = True

test-project/test_project/urls.py

+from django.conf.urls.defaults import patterns, include
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+    (r'^settings/', include('livesettings.urls')),
+    (r'^admin/', include(admin.site.urls)),
+    (r'^accounts/login/', 'django.contrib.auth.views.login', {'template_name': 'admin/login.html'}),
+    (r'^$', 'localsite.views.index')
+)