teamplayer: updates

Update to work with Django 1.01 since teamplayer (default) supports it now.
Also use settings.py instead of settings_local.py which I now consider an
anti-pattern.
This commit is contained in:
Albert Hopkins 2016-11-20 17:31:23 +00:00
parent 066e94c370
commit acf9ec8c91
8 changed files with 159 additions and 171 deletions

View File

@ -12,7 +12,7 @@ M4C = $(M4) $(M4_DEFS)
rcdefault := /etc/runlevels/default
post_files = bash_profile settings_local.py teamplayer-pre.service
post_files = bash_profile settings.py teamplayer-pre.service
post_files += teamplayer-wsgi.service teamplayer-spindoctor.service
post_files += issue nginx.conf teamplayer.service
@ -44,11 +44,11 @@ endif
chmod +x $(CHROOT)/$(TP_HOME)/manage.py
$(inroot) ln -sf ../manage.py $(TP_HOME)/bin/manage
cp urls.py $(CHROOT)/$(TP_HOME)/project/urls.py
$(M4C) settings_local.py >> $(CHROOT)/$(TP_HOME)/project/settings_local.py
$(M4C) settings.py >> $(CHROOT)/$(TP_HOME)/project/settings.py
ifdef SCROBBLER_AUTH
cat $(SCROBBLER_AUTH) >> $(CHROOT)/$(TP_HOME)/project/settings_local.py
cat $(SCROBBLER_AUTH) >> $(CHROOT)/$(TP_HOME)/project/settings.py
endif
$(inroot) bash -c ". $(TP_HOME)/bin/activate; cd $(TP_HOME); DJANGO_SETTINGS_MODULE=project.settings_local $(TP_HOME)/manage.py collectstatic --noinput"
$(inroot) bash -c ". $(TP_HOME)/bin/activate; cd $(TP_HOME); DJANGO_SETTINGS_MODULE=project.settings $(TP_HOME)/manage.py collectstatic --noinput"
$(inroot) $(INSTALL) -d -o $(TP_USER) -g $(TP_USER) $(TP_DB)
$(inroot) $(INSTALL) -d -o $(TP_USER) -g $(TP_USER) $(TP_DB)/songs
$(inroot) mkdir -p $(TP_HOME)/library

View File

@ -1,4 +1,4 @@
export DJANGO_SETTINGS_MODULE='project.settings_local'
export DJANGO_SETTINGS_MODULE='project.settings'
export PYTHONPATH="$HOME"
PATH="$HOME/bin:$PATH"
export LANG="en_US.UTF-8"

View File

@ -0,0 +1,143 @@
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'ej83nbqy(+nvr9&mwf8)zvz*4f)h0b@6s@%%f9tnk2ks9cfvx&'
DEBUG = False
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'haystack',
'rest_framework',
'teamplayer',
'tp_library',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'teamplayer.middleware.TeamPlayerMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'project.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'project.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'teamplayer',
'HOST': '',
'PASSWORD': '',
'PORT': '',
'CONN_MAX_AGE': 300,
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
AUTH_PROFILE_MODULE = 'teamplayer.UserProfile'
LOGIN_REDIRECT_URL = '/'
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
}
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = 'TP_HOME' + '/static/'
MEDIA_ROOT = 'TP_DB'
`TP_HOME' = 'TP_HOME'
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(`TP_HOME', 'library_index'),
},
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
HAYSTACK_CUSTOM_HIGHLIGHTER = 'tp_library.Highlighter'
TEAMPLAYER = {
'STREAM_URL': '/stream.mp3',
'MPD_HOME': 'TP_DB/mpd',
'MPD_LOG': '/dev/null',
'UPLOADED_LIBRARY_DIR': 'TP_HOME/library',
'CROSSFADE': 5,
'SHAKE_THINGS_UP': 10,
'ALWAYS_SHAKE_THINGS_UP': True,
'AUTOFILL_STRATEGY': 'mood',
'HTTP_PORT': 8000,
}

View File

@ -1,156 +0,0 @@
from .settings import *
#############################################################################
# Local Settings
#
# New/Overriden settings from settings_local.py
#############################################################################
import os
DEBUG = False
TEMPLATE_DEBUG = DEBUG
TIME_ZONE = 'UTC'
USE_TZ = False
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = False
# 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/"
MEDIA_URL = ''
STATIC_ROOT = 'static'
STATIC_URL = '/static/'
STATICFILE_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
# 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',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'teamplayer.middleware.TeamPlayerMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'haystack',
'rest_framework',
'teamplayer',
'tp_library',
)
AUTH_PROFILE_MODULE = 'teamplayer.UserProfile'
LOGIN_REDIRECT_URL = '/'
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
}
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'verbose': {
'format': '%(levelname)s:%(name)s:%(asctime)s %(message)s'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'teamplayer': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
}
}
}
ALLOWED_HOSTS = ['*']
TIME_ZONE = 'UTC'
FORCE_SCRIPT_NAME = ''
MEDIA_ROOT = 'TP_DB'
TEMPLATE_DIRS = (
'TP_HOME/web/teamplayer/templates',
)
`TP_HOME' = 'TP_HOME'
TEAMPLAYER = {
'STREAM_URL': '/stream.mp3',
'MPD_HOME': 'TP_DB/mpd',
'MPD_LOG': '/dev/null',
'UPLOADED_LIBRARY_DIR': 'TP_HOME/library',
'CROSSFADE': 5,
'SHAKE_THINGS_UP': 10,
'ALWAYS_SHAKE_THINGS_UP': True,
'AUTOFILL_STRATEGY': 'mood',
'HTTP_PORT': 8000,
}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'teamplayer',
'HOST': '',
'PASSWORD': '',
'PORT': '',
'CONN_MAX_AGE': 300,
}
}
# haystack
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(`TP_HOME', 'library_index'),
},
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
HAYSTACK_CUSTOM_HIGHLIGHTER = 'tp_library.Highlighter'

View File

@ -8,7 +8,7 @@ After=postgresql-PGVER.service
Type=oneshot
User=TP_USER
Environment=PYTHONPATH=TP_HOME
Environment=DJANGO_SETTINGS_MODULE=project.settings_local
Environment=DJANGO_SETTINGS_MODULE=project.settings
WorkingDirectory=TP_HOME
ExecStart=-/usr/bin/createuser -U postgres -D -S -R TP_USER
ExecStart=-/usr/bin/createdb -U postgres TP_USER

View File

@ -8,7 +8,7 @@ After=teamplayer-wsgi.service
[Service]
User=TP_USER
Environment=PYTHONPATH=TP_HOME
Environment=DJANGO_SETTINGS_MODULE=project.settings_local
Environment=DJANGO_SETTINGS_MODULE=project.settings
WorkingDirectory=TP_HOME
ExecStart=TP_HOME/bin/python manage.py spindoctor --verbosity=2

View File

@ -10,7 +10,7 @@ Type=notify
User=teamplayer
WorkingDirectory=/opt/teamplayer
Environment=PYTHONPATH=/opt/teamplayer
Environment=DJANGO_SETTINGS_MODULE=project.settings_local
Environment=DJANGO_SETTINGS_MODULE=project.settings
WorkingDirectory=/opt/teamplayer
ExecStart=/opt/teamplayer/bin/uwsgi --master -p 4 \
--socket=TP_DB/teamplayer.sock \

View File

@ -1,8 +1,9 @@
from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
urlpatterns = patterns(
'',
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
url('^library/', include('tp_library.urls')),
url('', include('teamplayer.urls')),
)
from django.contrib.auth.views import login as django_login
urlpatterns = [
url(r'^accounts/login/$', django_login),
url(r'^library/', include('tp_library.urls')),
url(r'', include('teamplayer.urls')),
]