""" Django settings for waveform annotation project. Generated by 'django-admin startproject' using Django 1.11.5. For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ import os from decouple import config # Basic settings based on development environment DEBUG = config('DEBUG', default=False, cast=bool) CACHE = config('CACHE', default=False, cast=bool) SESSION_COOKIE_SECURE = False SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' ALLOWED_HOSTS = ['*'] def custom_show_toolbar(request): return True DEBUG_TOOLBAR_CONFIG = { 'JQUERY_URL': '', # 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar, } # Build paths inside the project like this: os.path.join(BASE_DIR, ...) PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(PROJECT_DIR) HEAD_DIR = os.path.dirname(BASE_DIR) LOGIN_URL = 'login' # For password resets # Check output in another terminal window here: # python -m smtpd -n -c DebuggingServer localhost:1025 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = config('EMAIL_HOST', default='localhost') EMAIL_PORT = config('EMAIL_PORT', default=1025, cast=int) EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD = '' EMAIL_USE_TLS = False EMAIL_FROM = 'help@waveform-annotation.com' # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ SECRET_KEY = config('SECRET_KEY') # Application definition INSTALLED_APPS = [ 'django_crontab', 'debug_toolbar', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.staticfiles', 'django_plotly_dash.apps.DjangoPlotlyDashConfig', 'django.contrib.sessions', 'django.contrib.messages', 'graphene_django', 'export', 'waveforms', 'website' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django_plotly_dash.middleware.BaseMiddleware', 'django_plotly_dash.middleware.ExternalRedirectionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'website.middleware.thread_local_middleware' ] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(HEAD_DIR,'db','db.sqlite3') } } # Cache if CACHE: # Requires `redis-server` to be running in another terminal tab CACHES = { 'default': { 'BACKEND': 'django_redis.cache.RedisCache', 'LOCATION': 'redis://localhost:6379', 'OPTIONS': { 'CLIENT_CLASS': 'django_redis.client.DefaultClient' } } } # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed CRONJOBS = [ ('0 0 * * *', 'waveform-django.cron.update_annotations') ] ROOT_URLCONF = 'website.urls' if not DEBUG: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'timestamp': { 'format': '{asctime} {levelname} {message}', 'style': '{', }, }, 'handlers': { 'file': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'filename': os.path.join(HEAD_DIR, 'debug', 'debug.log'), 'formatter': 'timestamp' } }, 'loggers': { 'django': { 'handlers': ['file'], 'level': 'DEBUG', }, }, } TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR,'templates')], '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', ], }, }, ] X_FRAME_OPTIONS = 'SAMEORIGIN' PLOTLY_COMPONENTS = [ 'dash_core_components', 'dash_html_components', 'dash_renderer', 'dpd_components', 'dpd_static_support', 'dash_bootstrap_components' ] PLOTLY_DASH = { # Route used for the message pipe websocket connection 'ws_route': 'dpd/ws/channel', # Route used for direct http insertion of pipe messages 'http_route': 'dpd/views', # Flag controlling existince of http poke endpoint 'http_poke_enabled': True, # Insert data for the demo when migrating 'insert_demo_migrations': False, # Timeout for caching of initial arguments in seconds 'cache_timeout_initial_arguments': 60, # Name of view wrapping function 'view_decorator': None, # Flag to control location of initial argument storage 'cache_arguments': CACHE, # Flag controlling local serving of assets 'serve_locally': False } # Session management # Internationalization # https://docs.djangoproject.com/en/1.11/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'America/New_York' USE_I18N = True USE_L10N = True USE_TZ = True # Django background tasks max attempts MAX_ATTEMPTS = 5 # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ #USE_X_FORWARDED_HOST = True #FORCE_SCRIPT_NAME = '/waveform-annotation' if DEBUG: STATIC_URL = '/static/' STATIC_ROOT = 'assets' STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] else: STATIC_URL = '/waveform-annotation/static/' STATIC_ROOT = os.path.join(HEAD_DIR, 'static') STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] STATICFILE_FINDERS = [ 'django.contrib.staticfiles.finder.FileSystemFinder', 'django.contrib.staticfiles.finder.AppDirectoriesFinder', 'django_plotly_dash.finders.DashAssetFinder', 'django_plotly_dash.finders.DashComponentFinder', 'django_plotly_dash.finders.DashAppDirectoryFinder' ] STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' RECORDS_FILE = 'RECORDS_VTVF_LIMIT-5' ASSIGNMENT_FILE = 'user_assignments.csv' ALL_PROJECTS = ['sample_data'] # Projects in blacklist cannot be automatically assigned to users BLACKLIST = [] # The minimum amount of events to assign MIN_ASSIGNED = 10 # Events to be used in the practice data set PRACTICE_SET = { 'sample_data': { 'v101l': False, 'v111l': False, 'v131l': True, 'v135l': False, 'v139l': True } } # List of permitted HTML tags and attributes for rich text fields. # The 'default' configuration permits all of the tags below. Other # configurations may be added that permit different sets of tags. # Attributes that can be added to any HTML tag _generic_attributes = ['lang', 'title']