diff options
Diffstat (limited to 'example_project')
-rw-r--r-- | example_project/__init__.py | 3 | ||||
-rw-r--r-- | example_project/local_settings.py.gitlab-ci | 4 | ||||
-rw-r--r-- | example_project/local_settings.py.sample | 3 | ||||
-rwxr-xr-x | example_project/manage.py | 17 | ||||
-rw-r--r-- | example_project/settings.py | 105 | ||||
-rw-r--r-- | example_project/urls.py | 53 |
6 files changed, 102 insertions, 83 deletions
diff --git a/example_project/__init__.py b/example_project/__init__.py index 0cfc3ae26..c6adb7559 100644 --- a/example_project/__init__.py +++ b/example_project/__init__.py @@ -1,5 +1,6 @@ # force the retranslation of generated strings and external module -from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy as _ + _(u"username") _(u"email address") _(u"warehouse") diff --git a/example_project/local_settings.py.gitlab-ci b/example_project/local_settings.py.gitlab-ci index 81196b4a0..913f10fea 100644 --- a/example_project/local_settings.py.gitlab-ci +++ b/example_project/local_settings.py.gitlab-ci @@ -4,7 +4,7 @@ DATABASES = { 'NAME': 'gis', 'USER': 'gis', 'PASSWORD': 'gis', - 'HOST': 'iggdrasil-postgis-1.5', + 'HOST': 'mdillon-postgis', 'PORT': '5432', } } @@ -13,3 +13,5 @@ LOGFILE = '/tmp/ishtar.log' PROJECT_SLUG = "CI-instance" USE_SPATIALITE_FOR_TESTS = False + +SECRET_KEY = "not-so-secret-key" diff --git a/example_project/local_settings.py.sample b/example_project/local_settings.py.sample index 5a7550d9a..f49963c84 100644 --- a/example_project/local_settings.py.sample +++ b/example_project/local_settings.py.sample @@ -4,14 +4,13 @@ # rename this file to local_settings.py and overload settings in this file # Make this string unique, and don't share it with anybody. +# Don't leave it empty SECRET_KEY = '' ADMINS = ( # ('Your Name', 'your_email@domain.com'), ) -MANAGERS = ADMINS - DATABASES = { 'default': { 'NAME': 'ishtar', diff --git a/example_project/manage.py b/example_project/manage.py index 4981a4830..80114eb68 100755 --- a/example_project/manage.py +++ b/example_project/manage.py @@ -1,15 +1,12 @@ #!/usr/bin/env python -from django.core.management import execute_manager -import os, sys +import os +import sys sys.path.append(os.path.abspath('..')) -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) + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/example_project/settings.py b/example_project/settings.py index c7880d8c8..ea50daffb 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -7,10 +7,11 @@ import sys DEBUG = False DEBUG_TOOLBAR = False -TEMPLATE_DEBUG = DEBUG +DEBUG_TO_CONSOLE = False SQL_DEBUG = False DJANGO_EXTENSIONS = False -USE_SPATIALITE_FOR_TESTS = True +USE_SPATIALITE_FOR_TESTS = False +TEST_VIEWS = True if "test" in sys.argv: sys.path.insert(0, '..') @@ -31,11 +32,14 @@ BASE_URL = "/" URL_PATH = "" EXTRA_VERSION = 'git' +STATICFILES_DIRS = ( + ROOT_PATH + "../static/", +) + ODT_TEMPLATE = ROOT_PATH + "../ishtar_common/static/template.odt" LOGIN_REDIRECT_URL = "/" + URL_PATH -AUTH_PROFILE_MODULE = 'ishtar_common.IshtarUser' ACCOUNT_ACTIVATION_DAYS = 7 # change this in local_settings @@ -93,14 +97,7 @@ MEDIA_ROOT = ROOT_PATH + 'media/' # Examples: "http://media.lawrence.com", "http://example.com/media/" MEDIA_URL = '/media/' -# 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.Loader', -) - -MIDDLEWARE_CLASSES = [ +MIDDLEWARE = [ 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -109,21 +106,29 @@ MIDDLEWARE_CLASSES = [ 'django.middleware.locale.LocaleMiddleware', ] -TEMPLATE_CONTEXT_PROCESSORS = ( - 'ishtar_common.context_processors.get_base_context', - "django.contrib.auth.context_processors.auth", - "django.core.context_processors.debug", - "django.core.context_processors.i18n", - "django.core.context_processors.media", - "django.core.context_processors.static", - "django.core.context_processors.request", -) +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(ROOT_PATH, 'templates')], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + 'ishtar_common.context_processors.get_base_context', + "django.contrib.auth.context_processors.auth", + 'django.contrib.messages.context_processors.messages', + "django.template.context_processors.i18n", + "django.template.context_processors.media", + "django.template.context_processors.static", + "django.template.context_processors.csrf" + ], + }, + }, +] -ROOT_URLCONF = 'example_project.urls' -TEMPLATE_DIRS = ( - ROOT_PATH + 'templates', -) +ROOT_URLCONF = 'example_project.urls' AUTHENTICATION_BACKENDS = ( 'ishtar_common.backend.ObjectPermBackend', @@ -137,10 +142,8 @@ INSTALLED_APPS = [ 'django.contrib.sites', 'django.contrib.gis', 'django.contrib.staticfiles', - 'django.contrib.formtools', 'django.contrib.messages', 'django.contrib.humanize', - 'south', 'registration', # 'geodjangofla', 'ishtar_pdl', @@ -151,6 +154,7 @@ INSTALLED_APPS = [ 'archaeological_context_records', 'archaeological_warehouse', 'archaeological_finds', + 'ajax_select', # 'debug_toolbar', ] @@ -195,6 +199,11 @@ LOGGING = { 'level': 'ERROR', 'propagate': False, }, + 'django.server': { + 'handlers': ['console'], + 'level': 'INFO', + 'propagate': False, + }, 'ishtar_pdl': default_handler, 'ishtar_common': default_handler, 'archaeological_files_pdl': default_handler, @@ -234,9 +243,6 @@ ISHTAR_DOC_TYPES = {u"undefined": u"Undefined"} ISHTAR_DPTS = [] -PRE_APPS = [] -EXTRA_APPS = [] - TEST_RUNNER = 'ishtar_common.tests.ManagedModelTestRunner' try: @@ -246,12 +252,9 @@ except ImportError, e: TESTING = sys.argv[1:2] == ['test'] -if TESTING: - SOUTH_TESTS_MIGRATE = False - - if USE_SPATIALITE_FOR_TESTS: - DATABASES['default']['ENGINE'] = \ - 'django.contrib.gis.db.backends.spatialite' +# if TESTING and USE_SPATIALITE_FOR_TESTS: +# DATABASES['default']['ENGINE'] = \ +# 'django.contrib.gis.db.backends.spatialite' PROJECT_SLUG = locals().get('PROJECT_SLUG', 'default') @@ -269,7 +272,10 @@ JQUERY_UI_URL = STATIC_URL + "js/jquery-ui/" if DEBUG: # make all loggers use the console for logger in LOGGING['loggers']: - LOGGING['loggers'][logger]['handlers'] += ['console'] + if DEBUG_TO_CONSOLE: + LOGGING['loggers'][logger]['handlers'] = ['console'] + elif 'console' not in LOGGING['loggers'][logger]['handlers']: + LOGGING['loggers'][logger]['handlers'] += ['console'] if DJANGO_EXTENSIONS: INSTALLED_APPS.append('django_extensions') @@ -279,18 +285,21 @@ if DEBUG_TOOLBAR: sys.path.insert(0, '..') global DEBUG_TOOLBAR_PANELS global DEBUG_TOOLBAR_CONFIG - MIDDLEWARE_CLASSES += ['debug_toolbar.middleware.DebugToolbarMiddleware'] + MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware'] INSTALLED_APPS += ['debug_toolbar'] DEBUG_TOOLBAR_PANELS = ( - 'debug_toolbar.panels.version.VersionDebugPanel', - 'debug_toolbar.panels.timer.TimerDebugPanel', - 'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel', - 'debug_toolbar.panels.headers.HeaderDebugPanel', - 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel', - 'debug_toolbar.panels.template.TemplateDebugPanel', - 'debug_toolbar.panels.sql.SQLDebugPanel', - 'debug_toolbar.panels.signals.SignalDebugPanel', - 'debug_toolbar.panels.logger.LoggingPanel', + 'debug_toolbar.panels.versions.VersionsPanel', + 'debug_toolbar.panels.timer.TimerPanel', + 'debug_toolbar.panels.settings.SettingsPanel', + 'debug_toolbar.panels.headers.HeadersPanel', + 'debug_toolbar.panels.request.RequestPanel', + 'debug_toolbar.panels.sql.SQLPanel', + 'debug_toolbar.panels.staticfiles.StaticFilesPanel', + 'debug_toolbar.panels.templates.TemplatesPanel', + 'debug_toolbar.panels.cache.CachePanel', + 'debug_toolbar.panels.signals.SignalsPanel', + 'debug_toolbar.panels.logging.LoggingPanel', + 'debug_toolbar.panels.redirects.RedirectsPanel', ) DEBUG_TOOLBAR_CONFIG = {'INTERCEPT_REDIRECTS': False} @@ -303,3 +312,7 @@ if SQL_DEBUG: if 'test' in sys.argv: PROJECT_SLUG += "-test" + +if not DEBUG: + # persistent connection + DATABASES['default']['CONN_MAX_AGE'] = 600 diff --git a/example_project/urls.py b/example_project/urls.py index 62a6b1e04..79645b8ae 100644 --- a/example_project/urls.py +++ b/example_project/urls.py @@ -1,38 +1,45 @@ from django.conf import settings -from django.conf.urls.defaults import * +from django.conf.urls import include, url from django.contrib import admin +from ishtar_common.apps import admin_site +from ajax_select import urls as ajax_select_urls + +from ishtar_common.views import index + admin.autodiscover() -# admin.site.unregister(User) -urlpatterns = patterns( - '', (r'^accounts/', include('registration.urls')), -) +urlpatterns = [ + url(r'^accounts/', include('registration.urls')), + +] APP_LIST = ['archaeological_files_pdl', 'archaeological_files', 'archaeological_operations', 'archaeological_context_records', 'archaeological_warehouse', 'archaeological_finds'] for app in APP_LIST: - # filter by activated apps? - urlpatterns += patterns( - '', ('', include(app + '.urls')), - ) - -urlpatterns += patterns( - '', ('', include('ishtar_common.urls')), -) + urlpatterns += [ + url('', include(app + '.urls')), + ] -urlpatterns += patterns( - 'ishtar_common.views', url(r'^$', 'index', name='start'), -) - -urlpatterns += patterns( - '', (r'^admin/', include(admin.site.urls)), -) +urlpatterns += [ + url(r'^admin/', include(admin_site.urls)), + url(r'^ajax-select/', include(ajax_select_urls)), + url(r'', include('ishtar_common.urls')), + url(r'^$', index, name='start'), +] if settings.DEBUG: # static files (images, css, javascript, etc.) - urlpatterns += patterns( - '', (r'^media/(?P<path>.*)$', 'django.views.static.serve', - {'document_root': settings.MEDIA_ROOT})) + from django.conf.urls.static import static + from django.contrib.staticfiles.urls import staticfiles_urlpatterns + urlpatterns += staticfiles_urlpatterns() + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + +if settings.DEBUG_TOOLBAR: + import debug_toolbar + urlpatterns = [ + url(r'^__debug__/', include(debug_toolbar.urls)), + ] + urlpatterns + |