""" Django settings for rowsandall_app project. Generated by 'django-admin startproject' using Django 1.9.5. For more information on this file, see https://docs.djangoproject.com/en/1.9/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.9/ref/settings/ deliver erosion ivory chief exotic boring tackle auto print crawl lazy false """ # -*- coding: utf-8 -*- import os from YamJam import yamjam # from django.utils.translation import ugettext_lazy as _ # Read configuration (passwords, keys, secrets) from YamJam configuration # You have to create your own config.yaml in the project directory CFG = yamjam()['rowsandallapp'] DEFAULT_CHARSET = 'UTF-8' # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = CFG['secret_key'] DEEP_WATER_SECRET_KEY = CFG['deep_water_secret_key'] DEEP_WATER_URL = CFG['deep_water_url'] # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False TESTING = False ALLOWED_HOSTS = CFG['allowed_hosts'] # OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL = 'oauth2_provider.AccessToken' # OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application' # OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL = 'oauth2_provider.RefreshToken' # OAUTH2_PROVIDER_ACCESS_TOKEN_EXPIRE_SECONDS = 3600 DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' # data max upload fields DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000 # Application definition INSTALLED_APPS = [ 'rowers', 'survey', # 'cvkbrno', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # 'suit', # 'suit_rq', 'leaflet', 'django_rq', # 'django_rq_dashboard', # 'translation_manager', # 'django_mailbox', 'rest_framework', 'datetimewidget', 'rest_framework_swagger', 'oauth2_provider', # 'provider', # 'provider.oauth2', 'corsheaders', 'analytical', 'cookielaw', 'django_extensions', 'tz_detect', 'django_social_share', 'django_countries', 'rules', 'taggit', 'boatmovers', 'django_recaptcha', 'anymail', ] AUTHENTICATION_BACKENDS = ( #'oauth2_provider.backends.OAuth2Backend', # Uncomment following if you want to access the admin 'rowers.backends.EmailLoginBackend', 'django.contrib.auth.backends.ModelBackend', 'django.contrib.auth.backends.RemoteUserBackend', 'rowers.backends.MyObjectPermissionBackend', #'rules.permissions.ObjectPermissionBackend', ) CSRF_TRUSTED_ORIGINS = ['https://rowsandall.com', 'https://www.rowsandall.com', 'http://localhost', 'https://dunav.ngrok.io'] CSRF_COOKIE_SAMESITE = 'None' CSRF_COOKIE_SECURE = True SESSION_COOKIE_SAMESITE = 'None' SESSION_COOKIE_SECURE = True MIDDLEWARE = [ 'django.middleware.common.CommonMiddleware', 'django.middleware.common.BrokenLinkEmailsMiddleware', 'django.middleware.gzip.GZipMiddleware', # 'htmlmin.middleware.HtmlMinifyMiddleware', # 'htmlmin.middleware.MarkRequestMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', # 'django.middleware.locale.LocaleMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', # 'oauth2_provider.middleware.OAuth2TokenMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', #'provider.oauth2.middleware.Oauth2UserMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'tz_detect.middleware.TimezoneMiddleware', 'rowers.middleware.SurveyMiddleWare', 'rowers.middleware.GDPRMiddleWare', # 'rowers.middleware.PowerTimeFitnessMetricMiddleWare', 'rowers.middleware.RowerPlanMiddleWare', 'rowers.middleware.FTPMiddleWare', ] ROOT_URLCONF = 'rowsandall_app.urls' HTML_MINIFY = True # EXCLUDE_FROM_MINIFYING = ('^rowers/flexall', # '^rowers/list-workouts', # '^rowers/list-graphs', # '^admin/', # '^rowers/histo') APPEND_SLASH = True 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', 'django.template.context_processors.i18n', # 'context_processors.google_analytics', 'context_processors.warning_message', 'rowers.context_processors.braintree_merchant', ], 'libraries': { 'staticfiles': 'django.templatetags.static', }, }, }, ] CORS_ORIGIN_ALLOW_ALL = True WSGI_APPLICATION = 'rowsandall_app.wsgi.application' # Database # https://docs.djangoproject.com/en/1.9/ref/settings/#databases CONN_MAX_AGE = 0 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': CFG['db_name'], 'USER': CFG['db_user'], 'PASSWORD': CFG['db_password'], 'HOST': CFG['db_host'], 'PORT': CFG['db_port'], 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", 'charset': 'utf8mb4', } }, 'slave': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), }, 'TEST': { 'CHARSET': 'utf8', 'COLLATION': 'utf8_general_ci', }, } # Password validation # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators AUTH_USER_MLDEL = 'user.User' AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 'OPTIONS': { 'min_length': 9, } }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, { 'NAME': 'rowers.validator.LettersAndDigitsValidator', } ] # Internationalization # https://docs.djangoproject.com/en/1.9/topics/i18n/ USE_I18N = True USE_L10N = False DATE_INPUT_FORMATS = [ '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06' '%b %d %Y', '%b %d, %Y', # 'Oct 25 2006', 'Oct 25, 2006' '%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 2006' '%B %d %Y', '%B %d, %Y', # 'October 25 2006', 'October 25, 2006' '%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006' ] DATE_FORMAT = 'Y-m-d' USE_TZ = True TIME_ZONE = 'UTC' TZ_DETECT_COUNTRIES = ('US', 'DE', 'GB', 'CZ', 'FR', 'IT') LOCALE_PATHS = ( os.path.join(BASE_DIR, 'locale'), # os.path.join(BASE_DIR, 'cvkbrno/locale'), ) LANGUAGE_CODE = 'en-us' LANGUAGE_COOKIE_NAME = 'wm_lang' # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.9/howto/static-files/ STATIC_URL = '/static/' # STATIC_ROOT = BASE_DIR STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static/plots'), ] # os.path.join(BASE_DIR, 'static'), MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') # user authentication LOGIN_REDIRECT_URL = '/rowers/list-workouts/' LOGIN_URL = '/login/' LOGOUT_URL = '/logout/' LOGOUT_REDIRECT_URL = '/' # Update Cache with task progress password PROGRESS_CACHE_SECRET = CFG['progress_cache_secret'] try: UPLOAD_SERVICE_URL = CFG['upload_service_url'] except KeyError: # pragma: no cover UPLOAD_SERVICE_URL = "http://localhost:8000/rowers/workout/api/upload/" try: UPLOAD_SERVICE_SECRET = CFG['upload_service_secret'] except KeyError: # pragma: no cover UPLOAD_SERVICE_SECRET = "FoYezZWLSyfAVimumpHEeYsJjsNCerxV" try: LOG_SECRET = CFG['log_secret'] except KeyError: LOG_SECRET = "RoeiKalender" # Concept 2 C2_CLIENT_ID = CFG['c2_client_id'] C2_CLIENT_SECRET = CFG['c2_client_secret'] C2_REDIRECT_URI = CFG['c2_callback'] # C2_REDIRECT_URI = "http://localhost:8000/call_back" # Intervals.icu try: INTERVALS_CLIENT_ID = CFG['intervals_client_id'] except KeyError: INTERVALS_CLIENT_ID = '0' try: INTERVALS_CLIENT_SECRET = CFG['intervals_client_secret'] except KeyError: INTERVALS_CLIENT_SECRET = 'aa' try: INTERVALS_REDIRECT_URI = CFG['intervals_callback'] except KeyError: INTERVALS_REDIRECT_URI = 'http://localhost:8000/intervals_icu_callback' # Strava STRAVA_CLIENT_ID = CFG['strava_client_id'] STRAVA_CLIENT_SECRET = CFG['strava_client_secret'] STRAVA_REDIRECT_URI = CFG['strava_callback'] # ROJABO ROJABO_CLIENT_ID = CFG['rojabo_client_id'] ROJABO_CLIENT_SECRET = CFG['rojabo_client_secret'] ROJABO_REDIRECT_URI = CFG['rojabo_callback'] ROJABO_OAUTH_LOCATION = CFG['rojabo_oauth_location'] # Garmin GARMIN_CLIENT_KEY = CFG["garmin_client_key"] GARMIN_CLIENT_SECRET = CFG['garmin_client_secret'] GARMIN_REDIRECT_URI = CFG['garmin_callback'] # SportTracks SPORTTRACKS_CLIENT_ID = CFG['sporttracks_client_id'] SPORTTRACKS_CLIENT_SECRET = CFG['sporttracks_client_secret'] SPORTTRACKS_REDIRECT_URI = CFG['sporttracks_callback'] # Runkeeper RUNKEEPER_CLIENT_ID = CFG['runkeeper_client_id'] RUNKEEPER_CLIENT_SECRET = CFG['runkeeper_client_secret'] RUNKEEPER_REDIRECT_URI = CFG['runkeeper_callback'] # Polar Flow POLAR_CLIENT_ID = CFG['polarflow_client_id'] POLAR_CLIENT_SECRET = CFG['polarflow_client_secret'] POLAR_REDIRECT_URI = CFG['polarflow_callback'] # Under Armour UNDERARMOUR_CLIENT_ID = CFG['underarmour_client_name'] UNDERARMOUR_CLIENT_SECRET = CFG['underarmour_client_secret'] UNDERARMOUR_CLIENT_KEY = CFG['underarmour_client_key'] UNDERARMOUR_REDIRECT_URI = CFG['underarmour_callback'] # UNDERARMOUR_REDIRECT_URI = "http://rowsandall.com/underarmour_callback" # UNDERARMOUR_REDIRECT_URI = "http://localhost:8000/underarmour_callback" # TrainingPeaks TP_CLIENT_ID = CFG["tp_client_id"] TP_CLIENT_SECRET = CFG["tp_client_secret"] TP_REDIRECT_URI = CFG["tp_redirect_uri"] TP_CLIENT_KEY = TP_CLIENT_ID try: TP_API_LOCATION = CFG['tp_api_location'] except KeyError: TP_API_LOCATION = "https://api.trainingpeaks.com" try: TP_OAUTH_LOCATION = CFG['tp_oauth_location'] except KeyError: TP_OAUTH_LOCATION = "https://oauth.trainingpeaks.com/oauth/token" # RP3 RP3_CLIENT_ID = CFG["rp3_client_id"] RP3_CLIENT_SECRET = CFG["rp3_client_secret"] RP3_REDIRECT_URI = CFG["rp3_redict_uri"] RP3_CLIENT_KEY = RP3_CLIENT_ID # Nielsen-Kellerman NK_CLIENT_ID = CFG["nk_client_id"] NK_CLIENT_SECRET = CFG["nk_client_secret"] NK_REDIRECT_URI = CFG["nk_redirect_uri"] NK_API_LOCATION = CFG["nk_api_location"] NK_OAUTH_LOCATION = CFG["nk_oauth_location"] NK_VIEWER_LOCATION = CFG["nk_viewer_location"] # Full Site URL SITE_URL = CFG['site_url'] # RQ stuff RQ_QUEUES = { 'default': { 'HOST': 'localhost', 'PORT': 6379, 'DB': 0, # 'PASSWORD': 'some-password', 'DEFAULT_TIMEOUT': 360, }, 'low': { 'HOST': 'localhost', 'PORT': 6379, 'DB': 0, # 'PASSWORD': 'some-password', 'DEFAULT_TIMEOUT': 360, }, 'high': { 'HOST': 'localhost', 'PORT': 6379, 'DB': 0, # 'PASSWORD': 'some-password', 'DEFAULT_TIMEOUT': 360, }, } # SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies" # SESSION_ENGINE = "django.contrib.sessions.backends.cached_db" SESSION_ENGINE = "django.contrib.sessions.backends.cache" SESSION_SAVE_EVERY_REQUEST = True SESSION_EXPIRE_AT_BROWSER_CLOSE = True # admin stuff for error reporting SERVER_EMAIL = 'admin@rowsandall.com' ADMINS = [('Sander', 'roosendaalsander@gmail.com'),] CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', 'LOCATION': 'localhost:11211', 'TIMEOUT': 900, } } CACHE_MIDDLEWARE_ALIAS = 'default' CACHE_MIDDLEWARE_SECONDS = 900 # email stuff # EMAIL_BACKEND = CFG['email_backend'] # EMAIL_HOST = CFG['email_host'] # EMAIL_PORT = CFG['email_port'] # EMAIL_HOST_USER = CFG['email_host_user'] # EMAIL_HOST_PASSWORD = CFG['email_host_password'] # EMAIL_USE_TLS = CFG['email_use_tls'] # DEFAULT_FROM_EMAIL = 'admin@rowsandall.com' #EMAIL_BACKEND = 'django_ses.SESBackend' ANYMAIL = { 'MAILERSEND_API_TOKEN': CFG['mailersend_api_key'], } EMAIL_BACKEND = 'anymail.backends.mailersend.EmailBackend' #AWS_SES_REGION_NAME = CFG['aws_region'] #AWS_SES_REGION_ENDPOINT = CFG['aws_smtp'] #AWS_SES_ACCESS_KEY_ID = CFG['aws_access_key_id'] #AWS_SES_SECRET_ACCESS_KEY = CFG['aws_secret_access_key'] #AWS_ACCESS_KEY_ID = CFG['aws_access_key_id'] #AWS_SECRET_ACCESS_KEY = CFG['aws_secret_access_key'] #EMAIL_HOST = CFG['aws_smtp'] #EMAIL_PORT = CFG['aws_port'] #EMAIL_HOST_USER = CFG['aws_smtp_username'] #EMAIL_HOST_PASSWORD = CFG['aws_smtp_password'] #EMAIL_USE_TLS = CFG['email_use_tls'] DEFAULT_FROM_EMAIL = 'info@rowsandall.com' SERVER_EMAIL = 'support@rowsandall.com' # weather stuff FORECAST_IO_KEY = CFG['forecast_io_key'] GMAPIKEY = CFG['gmapikey'] # OAUTH2 OAUTH2_PROVIDER = { # this is the list of available scopes 'SCOPES': {'read': 'Read scope', 'write': 'Write scope', 'groups': 'Access to your groups'}, 'ALLOWED_REDIRECT_URI_SCHEMES': ["http", "https", "rowingcoachexport", "com.performancephones.crewnerd", "healthfit", "pocketcox", "activespeed", "app"], 'ACCESS_TOKEN_MODEL': 'oauth2_provider.AccessToken', 'APPLICATION_MODEL': 'oauth2_provider.Application', 'REFRESH_TOKEN_MODEL': 'oauth2_provider.RefreshToken', 'ACCESS_TOKEN_EXPIRE_SECONDS': 3600000, "PKCE_REQUIRED": False, # 'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore' } # REST Framework REST_FRAMEWORK = { # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.IsAuthenticated' # 'rest_framework.permissions.DjangoModelPermissions' ], 'DEFAULT_AUTHENTICATION_CLASSES': ( #'rest_framework.authentication.BasicAuthentication', # 'rest_framework.authentication.SessionAuthentication', # 'rest_framework.authentication.TokenAuthentication', 'oauth2_provider.contrib.rest_framework.OAuth2Authentication', 'rowers.authentication.APIKeyAuthentication', ), 'PAGE_SIZE': 20, 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema', } SWAGGER_SETTINGS = { 'SECURITY_DEFINITIONS': { 'basic': { 'type': 'basic' }, 'oauth2': { 'type': 'oauth2', 'authorizationUrl': '/rowers/o/authorize', 'flow': 'implicit', }, 'api_key': { 'type': 'apiKey', 'in': 'header', 'name': 'Authorization' }, }, 'SHOW_REQUEST_HEADERS': True, 'USE_SESSION_AUTH': True, 'JSON_EDITOR': True, } # Analytics CLICKY_SITE_ID = CFG['clicky_site_id'] GOOGLE_ANALYTICS_PROPERTY_ID = CFG['google_analytics_id'] GOOGLE_ANALYTICS_DOMAIN = CFG['google_analytics_domain'] TWEET_ACCESS_TOKEN_KEY = CFG['tweet_access_token_key'] TWEET_ACCESS_TOKEN_SECRET = CFG['tweet_access_token_secret'] TWEET_CONSUMER_KEY = CFG['tweet_consumer_key'] TWEET_CONSUMER_SECRET = CFG['tweet_consumer_secret'] # Environment try: WARNING_MESSAGE = CFG['warning_message'] except KeyError: WARNING_MESSAGE = '' SETTINGS_NAME = 'rowsandall_app.settings' # Workout email box try: workoutemailbox = CFG['workoutemailbox'] except KeyError: workoutemailbox = 'workouts@rowsandall.com' # payments try: BRAINTREE_MERCHANT_ID = CFG['braintree_merchant_id'] except KeyError: # pragma: no cover BRAINTREE_MERCHANT_ID = '' try: BRAINTREE_MERCHANT_ACCOUNT_ID = CFG['braintree_merchant_account_id'] except KeyError: # pragma: no cover BRAINTREE_MERCHANT_ACCOUNT_ID = 'rowsandallEUR' try: BRAINTREE_PUBLIC_KEY = CFG['braintree_public_key'] except KeyError: # pragma: no cover BRAINTREE_PUBLIC_KEY = '' try: BRAINTREE_PRIVATE_KEY = CFG['braintree_private_key'] except KeyError: # pragma: no cover BRAINTREE_PRIVATE_KEY = '' try: BRAINTREE_SANDBOX_MERCHANT_ID = CFG['braintree_sandbox_merchant_id'] except KeyError: # pragma: no cover BRAINTREE_SANDBOX_MERCHANT_ID = '' try: BRAINTREE_SANDBOX_PUBLIC_KEY = CFG['braintree_sandbox_public_key'] except KeyError: # pragma: no cover BRAINTREE_SANDBOX_PUBLIC_KEY = '' try: BRAINTREE_SANDBOX_PRIVATE_KEY = CFG['braintree_sandbox_private_key'] except KeyError: # pragma: no cover BRAINTREE_SANDBOX_PRIVATE_KEY = '' try: PAYMENT_PROCESSING_ON = CFG['payment_processing_on'] except KeyError: # pragma: no cover PAYMENT_PROCESSING_ON = False try: FAKTUROID_API_KEY = CFG['fakturoid_api_key'] except KeyError: # pragma: no cover FAKTUROID_API_KEY = '' try: FAKTUROID_EMAIL = CFG['fakturoid_email'] except KeyError: # pragma: no cover FAKTUROID_EMAIL = '' try: FAKTUROID_SLUG = CFG['fakturoid_slug'] except KeyError: # pragma: no cover FAKTUROID_SLUG = '' try: IDOKLAD_CLIENT_ID = CFG['idoklad_client_id'] IDOKLAD_CLIENT_SECRET = CFG['idoklad_client_secret'] IDOKLAD_REDIRECT_URI = CFG['idoklad_redirect_uri'] except KeyError: # pragma: no cover IDOKLAD_CLIENT_ID = '' IDOKLAD_CLIENT_SECRET = '' IDOKLAD_REDIRECT_URI = '' # ID obfuscation try: OPAQUE_SECRET_KEY = CFG['opaque_secret_key'] except KeyError: # pragma: no cover OPAQUE_SECRET_KEY = 0xa193443a # Celery or RQ try: CELERY = CFG['use_celery'] except KeyError: # pragma: no cover CELERY = False try: WORKOUTS_FIT_TOKEN = CFG['workouts_fit_token'] WORKOUTS_FIT_URL = CFG['workouts_fit_url'] except KeyError: # pragma: no cover WORKOUTS_FIT_TOKEN = 'aapnootmies' WORKOUTS_FIT_URL = 'http://localhost:50053/tojson' try: ROWSANDALL_CHARTS_TOKEN = CFG['rowsandall_charts_token'] ROWSANDALL_CHARTS_URL = CFG['rowsandall_charts_url'] except KeyError: ROWSANDALL_CHARTS_TOKEN = 'aapnootmies' ROWSANDALL_CHARTS_URL = 'http://localhost:3000' # Recaptcha try: RECAPTCHA_SITE_KEY = CFG['recaptcha_site_key'] RECAPTCHA_SITE_SECRET = CFG['recaptcha_site_secret'] RECAPTCHA_PUBLIC_KEY = CFG['recaptcha_site_key'] RECAPTCHA_PRIVATE_KEY = CFG['recaptcha_site_secret'] except KeyError: # pragma: no cover RECAPTCHA_SITE_KEY = '' RECAPTCHA_SITE_SECRET = '' RECAPTCHA_PUBLIC_KEY = '' RECAPTCHA_PRIVATE_KEY = '' GEOIP_PATH = STATIC_ROOT TAGGIT_CASE_INSENSITIVE = True try: MYLOGGING = CFG['logging'] except KeyError: MYLOGGING = {}