From 2748ab6978bf96ef2674fc013f424588b5b9ae90 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 2 Nov 2011 23:29:20 +0100 Subject: [PATCH] cleanup settings.py/local_settings.py/config.json --- pandora/0xdb.jsonc | 7 ++- pandora/app/config.py | 16 +++++-- pandora/app/views.py | 5 +- pandora/padma.jsonc | 8 ++-- pandora/settings.py | 91 +++++++++++++++++------------------- pandora/templates/index.html | 2 +- 6 files changed, 68 insertions(+), 61 deletions(-) diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index 4e5a3067..9c66451c 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -556,10 +556,9 @@ // E-mail address uses by the system (from) "system": "0xdb@0xdb.org" }, - // fixme: there should be no magic applied to this file - "id": "{{settings.SITEID}}", - "name": "{{settings.SITENAME}}", - "url": "{{settings.URL}}", + "id": "oxdb", + "name": "0xDb", + "url": "0xdb.org", "videoprefix": "" }, "sitePages": [ diff --git a/pandora/app/config.py b/pandora/app/config.py index a0de8188..04d27eac 100644 --- a/pandora/app/config.py +++ b/pandora/app/config.py @@ -9,6 +9,8 @@ import time import thread from django.conf import settings +from django.contrib.auth.models import User + import ox.jsonc from ox.utils import json @@ -24,10 +26,11 @@ def load_config(): config = None if config: - config['site']['id'] = settings.SITEID - config['site']['name'] = settings.SITENAME - config['site']['sectionName'] = settings.SITENAME - config['site']['url'] = settings.URL + settings.SITENAME = config['site']['name'] + settings.URL = config['site']['url'] + settings.EMAIL_SUBJECT_PREFIX = '[%s]'%settings.SITENAME + settings.DEFAULT_FROM_EMAIL = config['site']['email']['system'] + settings.SERVER_EMAIL = config['site']['email']['system'] config['site']['videoprefix'] = settings.VIDEO_PREFIX config['keys'] = {} @@ -36,6 +39,11 @@ def load_config(): settings.CONFIG = config + admin = len(settings.CONFIG['userLevels']) - 1 + settings.ADMIN = tuple([(u.username, u.email) + for u in User.objects.filter(profile__level=admin)]) + settings.MANAGERS = settings.ADMINS + def reloader_thread(): _config_mtime = 0 while RUN_RELOADER: diff --git a/pandora/app/views.py b/pandora/app/views.py index 71decff8..a5c9250f 100644 --- a/pandora/app/views.py +++ b/pandora/app/views.py @@ -21,7 +21,10 @@ def intro(request): def index(request): - context = RequestContext(request, {'settings': settings}) + context = RequestContext(request, { + 'base_url': request.build_absolute_uri('/'), + 'settings': settings + }) return render_to_response('index.html', context) diff --git a/pandora/padma.jsonc b/pandora/padma.jsonc index 043f087b..21a4c5d9 100644 --- a/pandora/padma.jsonc +++ b/pandora/padma.jsonc @@ -351,10 +351,10 @@ "importPosterFrames": false }, "site": { - "id": "{{settings.SITEID}}", - "name": "{{settings.SITENAME}}", - "sectionName": "{{settings.SITENAME}}", - "url": "{{settings.URL}}" + "id": "padma", + "name": "Pad.ma", + "url": "pad.ma", + "videoprefix": "" }, "sitePages": [ {"id": "about", "title": "About"}, diff --git a/pandora/settings.py b/pandora/settings.py index 1848c0b7..b9084054 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -2,52 +2,21 @@ # vi:si:et:sw=4:sts=4:ts=4 # Django settings for pan.do/ra project defaults, # create local_settings.py to overwrite +# check pan.do/ra section below for relevant settings + import os from os.path import join, normpath -SITENAME = 'Pan.do/ra' -SITEID = 'pandora' -URL = 'pan.do/ra' - PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__)) -DEBUG = True +DEBUG = False TEMPLATE_DEBUG = DEBUG JSON_DEBUG = True -#with apache x-sendfile or lighttpd set this to True -XSENDFILE = False - -#with nginx X-Accel-Redirect set this to True -XACCELREDIRECT = False - -ADMINS = ( - #('admin', 'admin@example.com'), -) - -DEFAULT_FROM_EMAIL='system@' + URL.split('/')[0] -#DEFAULT_FROM_EMAIL='admin@example.com' -SERVER_EMAIL=DEFAULT_FROM_EMAIL - +#this gets set to all users in highest userLevel (app/config.py) +ADMINS = () MANAGERS = ADMINS -DATABASES = { - 'default': { - 'NAME': 'pandora', - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'USER': 'pandora', - 'PASSWORD': '' - } -} - -#rabbitmq connection settings -CELERY_RESULT_BACKEND = "database" -BROKER_HOST = "127.0.0.1" -BROKER_PORT = 5672 -BROKER_USER = "pandora" -BROKER_PASSWORD = "box" -BROKER_VHOST = "/pandora" -SEND_CELERY_ERROR_EMAILS=False # Local time zone for this installation. Choices can be found here: @@ -75,9 +44,6 @@ MEDIA_ROOT = normpath(join(PROJECT_ROOT, '..', 'data')) STATIC_ROOT = normpath(join(PROJECT_ROOT, '..', 'static')) TESTS_ROOT = join(PROJECT_ROOT, 'tests') -#if videos are served from another subdomain -VIDEO_PREFIX = '' - # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). # Examples: "http://media.lawrence.com", "http://example.com/media/" @@ -166,18 +132,41 @@ LOGGING = { AUTH_PROFILE_MODULE = 'user.UserProfile' +#========================================================================= +#Pan.do/ra related settings settings +#to customize, create local_settings.py and overwrite keys + +DATABASES = { + 'default': { + 'NAME': 'pandora', + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'USER': 'pandora', + 'PASSWORD': '' + } +} + +#rabbitmq connection settings +CELERY_RESULT_BACKEND = "database" +BROKER_HOST = "127.0.0.1" +BROKER_PORT = 5672 +BROKER_USER = "pandora" +BROKER_PASSWORD = "box" +BROKER_VHOST = "/pandora" +SEND_CELERY_ERROR_EMAILS=False + +#with apache x-sendfile or lighttpd set this to True +XSENDFILE = False + +#with nginx X-Accel-Redirect set this to True +XACCELREDIRECT = False SITE_CONFIG = join(PROJECT_ROOT, '0xdb.jsonc') - - +#used if CONFIG['video']['download'] is set TRACKER_URL="http://url2torrent.net:6970/announce" - - DATA_SERVICE = '' POSTER_PRECEDENCE = ( 'piratecinema.org', - 'local', 'criterion.com', 'wikipedia.org', 'impawards.com', @@ -187,8 +176,12 @@ POSTER_PRECEDENCE = ( 'other' ) -#0xdb.org -USE_IMDB = True +USE_IMDB = False + +#if you set PAROT in VIDEO_PREFIX make sure cookies work accros subsomains +VIDEO_PREFIX='' +#VIDEO_PREFIX='videoPART.example.com' +#SESSION_COOKIE_DOMAIN=*.example.com" #copy scripts and adjust to customize ITEM_POSTER = join('scripts', 'oxdb_poster') @@ -196,7 +189,11 @@ ITEM_POSTER = join('scripts', 'oxdb_poster') ITEM_ICON = join('scripts', 'item_icon') LIST_ICON = join('scripts', 'list_icon') -#overwrite default settings with local settings + +#you can ignore things below this line +#========================================================================= + +#load installation specific settings from local_settings.py try: from local_settings import * except ImportError: diff --git a/pandora/templates/index.html b/pandora/templates/index.html index 4ed5aa6f..4c441bf7 100644 --- a/pandora/templates/index.html +++ b/pandora/templates/index.html @@ -7,7 +7,7 @@ - +