Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2022-03-15 10:01:47 +01:00
parent ded96b4ccd
commit 94967e4ada
9 changed files with 190 additions and 292 deletions

View File

@@ -1 +0,0 @@

View File

@@ -1,5 +1 @@
from django import forms from django import forms

View File

@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import models from django.db import models

View File

@@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/1.9/ref/settings/
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
from YamJam import yamjam from YamJam import yamjam
#from django.utils.translation import ugettext_lazy as _ # from django.utils.translation import ugettext_lazy as _
# Read configuration (passwords, keys, secrets) from YamJam configuration # Read configuration (passwords, keys, secrets) from YamJam configuration
# You have to create your own config.yaml in the project directory # You have to create your own config.yaml in the project directory
@@ -20,8 +20,6 @@ CFG = yamjam()['rowsandallapp']
DEFAULT_CHARSET = 'UTF-8' DEFAULT_CHARSET = 'UTF-8'
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -39,10 +37,10 @@ TESTING = False
ALLOWED_HOSTS = CFG['allowed_hosts'] ALLOWED_HOSTS = CFG['allowed_hosts']
#OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL = 'oauth2_provider.AccessToken' # OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL = 'oauth2_provider.AccessToken'
#OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application' # OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'
#OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL = 'oauth2_provider.RefreshToken' # OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL = 'oauth2_provider.RefreshToken'
#OAUTH2_PROVIDER_ACCESS_TOKEN_EXPIRE_SECONDS = 3600 # OAUTH2_PROVIDER_ACCESS_TOKEN_EXPIRE_SECONDS = 3600
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
@@ -51,20 +49,20 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
INSTALLED_APPS = [ INSTALLED_APPS = [
'rowers', 'rowers',
'survey', 'survey',
# 'cvkbrno', # 'cvkbrno',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
# 'suit', # 'suit',
# 'suit_rq', # 'suit_rq',
'leaflet', 'leaflet',
'django_rq', 'django_rq',
# 'django_rq_dashboard', # 'django_rq_dashboard',
# 'translation_manager', # 'translation_manager',
# 'django_mailbox', # 'django_mailbox',
'rest_framework', 'rest_framework',
'datetimewidget', 'datetimewidget',
'rest_framework_swagger', 'rest_framework_swagger',
@@ -91,12 +89,12 @@ MIDDLEWARE = [
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.common.BrokenLinkEmailsMiddleware', 'django.middleware.common.BrokenLinkEmailsMiddleware',
'django.middleware.gzip.GZipMiddleware', 'django.middleware.gzip.GZipMiddleware',
# 'htmlmin.middleware.HtmlMinifyMiddleware', # 'htmlmin.middleware.HtmlMinifyMiddleware',
# 'htmlmin.middleware.MarkRequestMiddleware', # 'htmlmin.middleware.MarkRequestMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
# 'django.middleware.locale.LocaleMiddleware', # 'django.middleware.locale.LocaleMiddleware',
'corsheaders.middleware.CorsMiddleware', 'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
@@ -106,14 +104,14 @@ MIDDLEWARE = [
'tz_detect.middleware.TimezoneMiddleware', 'tz_detect.middleware.TimezoneMiddleware',
'rowers.middleware.SurveyMiddleWare', 'rowers.middleware.SurveyMiddleWare',
'rowers.middleware.GDPRMiddleWare', 'rowers.middleware.GDPRMiddleWare',
# 'rowers.middleware.PowerTimeFitnessMetricMiddleWare', # 'rowers.middleware.PowerTimeFitnessMetricMiddleWare',
'rowers.middleware.RowerPlanMiddleWare', 'rowers.middleware.RowerPlanMiddleWare',
] ]
ROOT_URLCONF = 'rowsandall_app.urls' ROOT_URLCONF = 'rowsandall_app.urls'
HTML_MINIFY = True HTML_MINIFY = True
#EXCLUDE_FROM_MINIFYING = ('^rowers/flexall', # EXCLUDE_FROM_MINIFYING = ('^rowers/flexall',
# '^rowers/list-workouts', # '^rowers/list-workouts',
# '^rowers/list-graphs', # '^rowers/list-graphs',
# '^admin/', # '^admin/',
@@ -124,7 +122,7 @@ APPEND_SLASH = True
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR,'templates')], 'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
@@ -132,19 +130,18 @@ TEMPLATES = [
'django.template.context_processors.request', 'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'django.template.context_processors.i18n', 'django.template.context_processors.i18n',
# 'context_processors.google_analytics', # 'context_processors.google_analytics',
'context_processors.warning_message', 'context_processors.warning_message',
'rowers.context_processors.braintree_merchant', 'rowers.context_processors.braintree_merchant',
], ],
'libraries' : { 'libraries': {
'staticfiles': 'django.templatetags.static', 'staticfiles': 'django.templatetags.static',
} }
# 'loaders': [ # 'loaders': [
# 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.app_directories.Loader',
# ], # ],
}, },
}, },
] ]
@@ -177,8 +174,8 @@ DATABASES = {
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}, },
'TEST': { 'TEST': {
'CHARSET': 'utf8', 'CHARSET': 'utf8',
'COLLATION': 'utf8_general_ci', 'COLLATION': 'utf8_general_ci',
}, },
} }
@@ -192,9 +189,9 @@ AUTH_PASSWORD_VALIDATORS = [
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
'OPTIONS': { 'OPTIONS': {
'min_length': 9, 'min_length': 9,
} }
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
@@ -203,7 +200,7 @@ AUTH_PASSWORD_VALIDATORS = [
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
}, },
{ {
'NAME': 'rowers.validator.LettersAndDigitsValidator', 'NAME': 'rowers.validator.LettersAndDigitsValidator',
} }
] ]
@@ -217,11 +214,11 @@ USE_I18N = True
USE_L10N = False USE_L10N = False
DATE_INPUT_FORMATS = [ DATE_INPUT_FORMATS = [
'%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06' '%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' '%b %d %Y', '%b %d, %Y', # 'Oct 25 2006', 'Oct 25, 2006'
'%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 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' '%B %d %Y', '%B %d, %Y', # 'October 25 2006', 'October 25, 2006'
'%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006' '%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006'
] ]
DATE_FORMAT = 'Y-m-d' DATE_FORMAT = 'Y-m-d'
@@ -229,12 +226,12 @@ DATE_FORMAT = 'Y-m-d'
USE_TZ = True USE_TZ = True
TIME_ZONE = 'UTC' TIME_ZONE = 'UTC'
TZ_DETECT_COUNTRIES = ('US','DE','GB','CZ','FR','IT') TZ_DETECT_COUNTRIES = ('US', 'DE', 'GB', 'CZ', 'FR', 'IT')
LOCALE_PATHS = ( LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'), os.path.join(BASE_DIR, 'locale'),
# os.path.join(BASE_DIR, 'cvkbrno/locale'), # os.path.join(BASE_DIR, 'cvkbrno/locale'),
) )
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'en-us'
@@ -244,19 +241,16 @@ LANGUAGE_COOKIE_NAME = 'wm_lang'
# https://docs.djangoproject.com/en/1.9/howto/static-files/ # https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = '/static/'
#STATIC_ROOT = BASE_DIR # STATIC_ROOT = BASE_DIR
STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static/plots'),] STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static/plots'), ]
# os.path.join(BASE_DIR, 'static'), # os.path.join(BASE_DIR, 'static'),
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# user authentication
# user authentication # user authentication
LOGIN_REDIRECT_URL = '/rowers/list-workouts/' LOGIN_REDIRECT_URL = '/rowers/list-workouts/'
LOGIN_URL = '/login/' LOGIN_URL = '/login/'
@@ -268,18 +262,18 @@ LOGOUT_REDIRECT_URL = '/'
PROGRESS_CACHE_SECRET = CFG['progress_cache_secret'] PROGRESS_CACHE_SECRET = CFG['progress_cache_secret']
try: try:
UPLOAD_SERVICE_URL = CFG['upload_service_url'] UPLOAD_SERVICE_URL = CFG['upload_service_url']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
UPLOAD_SERVICE_URL = "http://localhost:8000/rowers/workout/api/upload/" UPLOAD_SERVICE_URL = "http://localhost:8000/rowers/workout/api/upload/"
try: try:
UPLOAD_SERVICE_SECRET = CFG['upload_service_secret'] UPLOAD_SERVICE_SECRET = CFG['upload_service_secret']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
UPLOAD_SERVICE_SECRET = "FoYezZWLSyfAVimumpHEeYsJjsNCerxV" UPLOAD_SERVICE_SECRET = "FoYezZWLSyfAVimumpHEeYsJjsNCerxV"
# Concept 2 # Concept 2
C2_CLIENT_ID = CFG['c2_client_id'] C2_CLIENT_ID = CFG['c2_client_id']
C2_CLIENT_SECRET = CFG['c2_client_secret'] C2_CLIENT_SECRET = CFG['c2_client_secret']
C2_REDIRECT_URI = CFG['c2_callback'] C2_REDIRECT_URI = CFG['c2_callback']
#C2_REDIRECT_URI = "http://localhost:8000/call_back" # C2_REDIRECT_URI = "http://localhost:8000/call_back"
# Strava # Strava
@@ -316,8 +310,8 @@ UNDERARMOUR_CLIENT_ID = CFG['underarmour_client_name']
UNDERARMOUR_CLIENT_SECRET = CFG['underarmour_client_secret'] UNDERARMOUR_CLIENT_SECRET = CFG['underarmour_client_secret']
UNDERARMOUR_CLIENT_KEY = CFG['underarmour_client_key'] UNDERARMOUR_CLIENT_KEY = CFG['underarmour_client_key']
UNDERARMOUR_REDIRECT_URI = CFG['underarmour_callback'] UNDERARMOUR_REDIRECT_URI = CFG['underarmour_callback']
#UNDERARMOUR_REDIRECT_URI = "http://rowsandall.com/underarmour_callback" # UNDERARMOUR_REDIRECT_URI = "http://rowsandall.com/underarmour_callback"
#UNDERARMOUR_REDIRECT_URI = "http://localhost:8000/underarmour_callback" # UNDERARMOUR_REDIRECT_URI = "http://localhost:8000/underarmour_callback"
# TrainingPeaks # TrainingPeaks
TP_CLIENT_ID = CFG["tp_client_id"] TP_CLIENT_ID = CFG["tp_client_id"]
@@ -349,56 +343,56 @@ RQ_QUEUES = {
'HOST': 'localhost', 'HOST': 'localhost',
'PORT': 6379, 'PORT': 6379,
'DB': 0, 'DB': 0,
# 'PASSWORD': 'some-password', # 'PASSWORD': 'some-password',
'DEFAULT_TIMEOUT': 360, 'DEFAULT_TIMEOUT': 360,
}, },
'low': { 'low': {
'HOST': 'localhost', 'HOST': 'localhost',
'PORT': 6379, 'PORT': 6379,
'DB': 0, 'DB': 0,
# 'PASSWORD': 'some-password', # 'PASSWORD': 'some-password',
'DEFAULT_TIMEOUT': 360, 'DEFAULT_TIMEOUT': 360,
}, },
'high': { 'high': {
'HOST': 'localhost', 'HOST': 'localhost',
'PORT': 6379, 'PORT': 6379,
'DB': 0, 'DB': 0,
# 'PASSWORD': 'some-password', # 'PASSWORD': 'some-password',
'DEFAULT_TIMEOUT': 360, 'DEFAULT_TIMEOUT': 360,
}, },
} }
#SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies" # SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
#SESSION_ENGINE = "django.contrib.sessions.backends.cached_db" # SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
SESSION_ENGINE = "django.contrib.sessions.backends.cache" SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_SAVE_EVERY_REQUEST = True SESSION_SAVE_EVERY_REQUEST = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_EXPIRE_AT_BROWSER_CLOSE = True
# admin stuff for error reporting # admin stuff for error reporting
SERVER_EMAIL='admin@rowsandall.com' SERVER_EMAIL = 'admin@rowsandall.com'
ADMINS = [('Sander','roosendaalsander@gmail.com')] ADMINS = [('Sander', 'roosendaalsander@gmail.com')]
CACHES = { CACHES = {
'default': { 'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'localhost:11211', 'LOCATION': 'localhost:11211',
'TIMEOUT': 900, 'TIMEOUT': 900,
}
} }
}
CACHE_MIDDLEWARE_ALIAS = 'default' CACHE_MIDDLEWARE_ALIAS = 'default'
CACHE_MIDDLEWARE_SECONDS = 900 CACHE_MIDDLEWARE_SECONDS = 900
# email stuff # email stuff
#EMAIL_BACKEND = CFG['email_backend'] # EMAIL_BACKEND = CFG['email_backend']
#EMAIL_HOST = CFG['email_host'] # EMAIL_HOST = CFG['email_host']
#EMAIL_PORT = CFG['email_port'] # EMAIL_PORT = CFG['email_port']
#EMAIL_HOST_USER = CFG['email_host_user'] # EMAIL_HOST_USER = CFG['email_host_user']
#EMAIL_HOST_PASSWORD = CFG['email_host_password'] # EMAIL_HOST_PASSWORD = CFG['email_host_password']
#EMAIL_USE_TLS = CFG['email_use_tls'] # EMAIL_USE_TLS = CFG['email_use_tls']
#DEFAULT_FROM_EMAIL = 'admin@rowsandall.com' # DEFAULT_FROM_EMAIL = 'admin@rowsandall.com'
EMAIL_BACKEND = 'django_ses.SESBackend' EMAIL_BACKEND = 'django_ses.SESBackend'
@@ -407,7 +401,7 @@ AWS_SES_REGION_ENDPOINT = CFG['aws_smtp']
AWS_SES_ACCESS_KEY_ID = CFG['aws_access_key_id'] AWS_SES_ACCESS_KEY_ID = CFG['aws_access_key_id']
AWS_SES_SECRET_ACCESS_KEY = CFG['aws_secret_access_key'] AWS_SES_SECRET_ACCESS_KEY = CFG['aws_secret_access_key']
AWS_ACCESS_KEY_ID = CFG['aws_access_key_id'] AWS_ACCESS_KEY_ID = CFG['aws_access_key_id']
AWS_SECRET_ACCESS_KEY = CFG['aws_secret_access_key'] AWS_SECRET_ACCESS_KEY = CFG['aws_secret_access_key']
EMAIL_HOST = CFG['aws_smtp'] EMAIL_HOST = CFG['aws_smtp']
@@ -435,7 +429,7 @@ OAUTH2_PROVIDER = {
'APPLICATION_MODEL': 'oauth2_provider.Application', 'APPLICATION_MODEL': 'oauth2_provider.Application',
'REFRESH_TOKEN_MODEL': 'oauth2_provider.RefreshToken', 'REFRESH_TOKEN_MODEL': 'oauth2_provider.RefreshToken',
'ACCESS_TOKEN_EXPIRE_SECONDS': 36000, 'ACCESS_TOKEN_EXPIRE_SECONDS': 36000,
#'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore' # 'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore'
} }
@@ -446,38 +440,38 @@ REST_FRAMEWORK = {
# or allow read-only access for unauthenticated users. # or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [ 'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated' 'rest_framework.permissions.IsAuthenticated'
# 'rest_framework.permissions.DjangoModelPermissions' # 'rest_framework.permissions.DjangoModelPermissions'
], ],
'DEFAULT_AUTHENTICATION_CLASSES': ( 'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.BasicAuthentication',
# 'rest_framework.authentication.SessionAuthentication', # 'rest_framework.authentication.SessionAuthentication',
# 'rest_framework.authentication.TokenAuthentication', # 'rest_framework.authentication.TokenAuthentication',
'oauth2_provider.contrib.rest_framework.OAuth2Authentication', 'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
), ),
'PAGE_SIZE': 20, 'PAGE_SIZE': 20,
'DEFAULT_PAGINATION_CLASS':'rest_framework.pagination.LimitOffsetPagination', 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
} }
SWAGGER_SETTINGS = { SWAGGER_SETTINGS = {
'SECURITY_DEFINITIONS': { 'SECURITY_DEFINITIONS': {
'basic': { 'basic': {
'type':'basic' 'type': 'basic'
}, },
'oauth2': { 'oauth2': {
'type':'oauth2', 'type': 'oauth2',
'authorizationUrl':'/rowers/o/authorize', 'authorizationUrl': '/rowers/o/authorize',
'flow': 'implicit', 'flow': 'implicit',
}, },
'api_key': { 'api_key': {
'type': 'apiKey', 'type': 'apiKey',
'in': 'header', 'in': 'header',
'name': 'Authorization' 'name': 'Authorization'
}, },
}, },
'SHOW_REQUEST_HEADERS': True, 'SHOW_REQUEST_HEADERS': True,
'USE_SESSION_AUTH': True, 'USE_SESSION_AUTH': True,
'JSON_EDITOR': True, 'JSON_EDITOR': True,
} }
# Analytics # Analytics
@@ -511,75 +505,75 @@ except KeyError:
try: try:
BRAINTREE_MERCHANT_ID = CFG['braintree_merchant_id'] BRAINTREE_MERCHANT_ID = CFG['braintree_merchant_id']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
BRAINTREE_MERCHANT_ID = '' BRAINTREE_MERCHANT_ID = ''
try: try:
BRAINTREE_MERCHANT_ACCOUNT_ID = CFG['braintree_merchant_account_id'] BRAINTREE_MERCHANT_ACCOUNT_ID = CFG['braintree_merchant_account_id']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
BRAINTREE_MERCHANT_ACCOUNT_ID = 'rowsandallEUR' BRAINTREE_MERCHANT_ACCOUNT_ID = 'rowsandallEUR'
try: try:
BRAINTREE_PUBLIC_KEY = CFG['braintree_public_key'] BRAINTREE_PUBLIC_KEY = CFG['braintree_public_key']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
BRAINTREE_PUBLIC_KEY = '' BRAINTREE_PUBLIC_KEY = ''
try: try:
BRAINTREE_PRIVATE_KEY = CFG['braintree_private_key'] BRAINTREE_PRIVATE_KEY = CFG['braintree_private_key']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
BRAINTREE_PRIVATE_KEY = '' BRAINTREE_PRIVATE_KEY = ''
try: try:
BRAINTREE_SANDBOX_MERCHANT_ID = CFG['braintree_sandbox_merchant_id'] BRAINTREE_SANDBOX_MERCHANT_ID = CFG['braintree_sandbox_merchant_id']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
BRAINTREE_SANDBOX_MERCHANT_ID = '' BRAINTREE_SANDBOX_MERCHANT_ID = ''
try: try:
BRAINTREE_SANDBOX_PUBLIC_KEY = CFG['braintree_sandbox_public_key'] BRAINTREE_SANDBOX_PUBLIC_KEY = CFG['braintree_sandbox_public_key']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
BRAINTREE_SANDBOX_PUBLIC_KEY = '' BRAINTREE_SANDBOX_PUBLIC_KEY = ''
try: try:
BRAINTREE_SANDBOX_PRIVATE_KEY = CFG['braintree_sandbox_private_key'] BRAINTREE_SANDBOX_PRIVATE_KEY = CFG['braintree_sandbox_private_key']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
BRAINTREE_SANDBOX_PRIVATE_KEY = '' BRAINTREE_SANDBOX_PRIVATE_KEY = ''
try: try:
PAYMENT_PROCESSING_ON = CFG['payment_processing_on'] PAYMENT_PROCESSING_ON = CFG['payment_processing_on']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
PAYMENT_PROCESSING_ON = False PAYMENT_PROCESSING_ON = False
try: try:
FAKTUROID_API_KEY = CFG['fakturoid_api_key'] FAKTUROID_API_KEY = CFG['fakturoid_api_key']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
FAKTUROID_API_KEY = '' FAKTUROID_API_KEY = ''
try: try:
FAKTUROID_EMAIL = CFG['fakturoid_email'] FAKTUROID_EMAIL = CFG['fakturoid_email']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
FAKTUROID_EMAIL = '' FAKTUROID_EMAIL = ''
try: try:
FAKTUROID_SLUG = CFG['fakturoid_slug'] FAKTUROID_SLUG = CFG['fakturoid_slug']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
FAKTUROID_SLUG = '' FAKTUROID_SLUG = ''
# ID obfuscation # ID obfuscation
try: try:
OPAQUE_SECRET_KEY = CFG['opaque_secret_key'] OPAQUE_SECRET_KEY = CFG['opaque_secret_key']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
OPAQUE_SECRET_KEY = 0xa193443a OPAQUE_SECRET_KEY = 0xa193443a
# Celery or RQ # Celery or RQ
try: try:
CELERY = CFG['use_celery'] CELERY = CFG['use_celery']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
CELERY = False CELERY = False
try: try:
WORKOUTS_FIT_TOKEN = CFG['workouts_fit_token'] WORKOUTS_FIT_TOKEN = CFG['workouts_fit_token']
WORKOUTS_FIT_URL = CFG['workouts_fit_url'] WORKOUTS_FIT_URL = CFG['workouts_fit_url']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
WORKOUTS_FIT_TOKEN = 'aapnootmies' WORKOUTS_FIT_TOKEN = 'aapnootmies'
WORKOUTS_FIT_URL = 'http://localhost:50053/tojson' WORKOUTS_FIT_URL = 'http://localhost:50053/tojson'
@@ -588,7 +582,7 @@ except KeyError: # pragma: no cover
try: try:
RECAPTCHA_SITE_KEY = CFG['recaptcha_site_key'] RECAPTCHA_SITE_KEY = CFG['recaptcha_site_key']
RECAPTCHA_SITE_SECRET = CFG['recaptcha_site_secret'] RECAPTCHA_SITE_SECRET = CFG['recaptcha_site_secret']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
RECAPTCHA_SITE_KEY = '' RECAPTCHA_SITE_KEY = ''
RECAPTCHA_SITE_SECRET = '' RECAPTCHA_SITE_SECRET = ''

View File

@@ -14,15 +14,13 @@ import sys
try: try:
use_sqlite = CFG['use_sqlite'] use_sqlite = CFG['use_sqlite']
except KeyError: # pragma: no cover except KeyError: # pragma: no cover
use_sqlite = False use_sqlite = False
for element in sys.argv: for element in sys.argv:
if 'test' in element: if 'test' in element:
TESTING = True TESTING = True
if TESTING or use_sqlite: if TESTING or use_sqlite:
DATABASES = { DATABASES = {
'default': { 'default': {
@@ -31,7 +29,8 @@ if TESTING or use_sqlite:
'HOST': 'localhost', 'HOST': 'localhost',
'USER': '', 'USER': '',
'PASSWORD': 'roeidata', 'PASSWORD': 'roeidata',
'PORT': '3306', }, 'PORT': '3306',
},
# 'TEST': { # 'TEST': {
# 'CHARSET': 'utf8', # 'CHARSET': 'utf8',
# 'COLLATION': 'utf8_general_ci', # 'COLLATION': 'utf8_general_ci',
@@ -42,7 +41,7 @@ if TESTING or use_sqlite:
# 'NAME': 'rowsanda_107501', # 'NAME': 'rowsanda_107501',
# 'USER': 'rowsanda_107501', # 'USER': 'rowsanda_107501',
# } # }
} }
@@ -63,10 +62,10 @@ DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
ALLOWED_HOSTS = ['localhost','127.0.0.1','dunav.ngrok.io'] ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'dunav.ngrok.io']
# INSTALLED_APPS += ['debug_toolbar',] # INSTALLED_APPS += ['debug_toolbar',]
#INSTALLED_APPS += ["sslserver"] # INSTALLED_APPS += ["sslserver"]
# MIDDLEWARE_CLASSES += ['debug_toolbar.middleware.DebugToolbarMiddleware',] # MIDDLEWARE_CLASSES += ['debug_toolbar.middleware.DebugToolbarMiddleware',]
@@ -74,18 +73,20 @@ CACHES = {
'default': { 'default': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': os.path.join(BASE_DIR, 'django_cache'), 'LOCATION': os.path.join(BASE_DIR, 'django_cache'),
}
} }
}
# Application definition # Application definition
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR STATIC_ROOT = BASE_DIR
#STATIC_ROOT = os.path.join(BASE_DIR, 'static') # STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static/plots'),] os.path.join(BASE_DIR, 'static'),
os.path.join(BASE_DIR, 'static/plots'),
]
INTERNAL_IPS = ['127.0.0.1'] INTERNAL_IPS = ['127.0.0.1']
@@ -99,10 +100,10 @@ SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
SITE_URL = "http://localhost:8000" SITE_URL = "http://localhost:8000"
#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
#EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend' # EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
#EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_BACKEND = 'django_ses.SESBackend' EMAIL_BACKEND = 'django_ses.SESBackend'

View File

@@ -1,104 +0,0 @@
"""
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/
"""
import os
from .settings import *
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# 'HOST': 'localhost',
},
# 'TEST': {
# 'CHARSET': 'utf8',
# 'COLLATION': 'utf8_general_ci',
# },
# 'slave': {
# 'ENGINE': 'django.db.backends.mysql',
# 'NAME': 'rowsanda_107501',
# 'USER': 'rowsanda_107501',
# 'PASSWORD': 'roeidata',
# 'HOST': 'store3.rosti.cz',
# 'PORT': '3306',
# }
}
#BROKER_URL = 'redis://localhost:6379/0'
#CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
#CELERY_IGNORE_RESULT = False
#CELERY_ACCEPT_CONTENT = ['json']
#CELERY_TASK_SERIALIZER = 'json'
#CELERY_RESULT_SERIALIZER = 'json'
#CELERY_TRACK_STARTED = True
#CELERY_SEND_TASK_SENT_EVENT = True
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
ALLOWED_HOSTS = []
INSTALLED_APPS += ['debug_toolbar',]
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware',]
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': os.path.join(BASE_DIR, 'django_cache'),
}
}
# Application definition
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR
STATICFILES_DIRS = [os.path.join(BASE_DIR,'static/plots'),os.path.join(BASE_DIR,'static'),]
# INTERNAL_IPS = ['127.0.0.1']
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
LOGIN_REDIRECT_URL = '/rowers/list-workouts/'
SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
SITE_URL = "http://localhost:8000"
#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
#EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
#EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
#EMAIL_BACKEND = 'django_ses.SESBackend'
AWS_SES_REGION_NAME = 'eu-west-1'
AWS_SES_REGION_ENDPOINT = 'email.eu-west-1.amazonaws.com'
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'
SETTINGS_NAME = 'rowsandall_app.settings_thinkpad'

View File

@@ -25,69 +25,80 @@ from rowers import views as rowersviews
from survey import views as surveyviews from survey import views as surveyviews
import django import django
import django.views.i18n
# admin look # admin look
admin.site.enable_nav_sidebar = False admin.site.enable_nav_sidebar = False
import django.views.i18n
urlpatterns = [ urlpatterns = [
re_path('^', include('django.contrib.auth.urls')), re_path('^', include('django.contrib.auth.urls')),
re_path(r'^password_change_done/$',auth_views.PasswordChangeDoneView.as_view(),name='password_change_done'), re_path(
re_path(r'^password_change/$',auth_views.PasswordChangeView.as_view(),name='password_change'), r'^password_change_done/$',
re_path(r'^password_reset/$', auth_views.PasswordChangeDoneView.as_view(),
name='password_change_done'),
re_path(
r'^password_change/$',
auth_views.PasswordChangeView.as_view(),
name='password_change'),
re_path(
r'^password_reset/$',
auth_views.PasswordResetView.as_view(), auth_views.PasswordResetView.as_view(),
{'template_name': 'rowers/templates/registration/password_reset.html'}, {'template_name': 'rowers/templates/registration/password_reset.html'},
name='password_reset'), name='password_reset'),
re_path(r'^password_reset/done/$', re_path(
r'^password_reset/done/$',
auth_views.PasswordResetDoneView.as_view(), auth_views.PasswordResetDoneView.as_view(),
name='password_reset_done'), name='password_reset_done'),
re_path(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$', re_path(
r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
auth_views.PasswordResetConfirmView.as_view(), auth_views.PasswordResetConfirmView.as_view(),
name='password_reset_confirm'), name='password_reset_confirm'),
re_path(r'^reset/done/$', re_path(
r'^reset/done/$',
auth_views.PasswordResetCompleteView.as_view(), auth_views.PasswordResetCompleteView.as_view(),
name='password_reset_complete'), name='password_reset_complete'),
] ]
urlpatterns += [ urlpatterns += [
re_path(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt', re_path(r'^robots\.txt$', TemplateView.as_view(
content_type='text/plain')), template_name='robots.txt',
content_type='text/plain')),
re_path(r'^admin/', admin.site.urls), re_path(r'^admin/', admin.site.urls),
re_path(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework2')), re_path(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework2')),
re_path(r'^$',landingview), re_path(r'^$', landingview),
re_path(r'^landing/$',landingview), re_path(r'^landing/$', landingview),
re_path(r'^getblogs/$',rowersviews.get_blog_posts), re_path(r'^getblogs/$', rowersviews.get_blog_posts),
re_path(r'^login/', re_path(r'^login/',
# auth_views.LoginView, # auth_views.LoginView,
auth_views.LoginView.as_view(), auth_views.LoginView.as_view(),
name='login'), name='login'),
re_path(r'^logout/$', re_path(r'^logout/$',
auth_views.LogoutView.as_view(), auth_views.LogoutView.as_view(),
{'next_page': '/'}, {'next_page': '/'},
name='logout',), name='logout',),
re_path(r'^rowers/',include('rowers.urls')), re_path(r'^rowers/', include('rowers.urls')),
# re_path(r'^survey/',include('survey.urls')), # re_path(r'^survey/',include('survey.urls')),
# re_path(r'^cvkbrno/',include('cvkbrno.urls')), # re_path(r'^cvkbrno/',include('cvkbrno.urls')),
# re_path(r'^admin/rq/',include('django_rq_dashboard.urls')), # re_path(r'^admin/rq/',include('django_rq_dashboard.urls')),
re_path(r'^call\_back',rowersviews.rower_process_callback), re_path(r'^call\_back', rowersviews.rower_process_callback),
re_path(r'^nk\_callback',rowersviews.rower_process_nkcallback), re_path(r'^nk\_callback', rowersviews.rower_process_nkcallback),
re_path(r'^stravacall\_back',rowersviews.rower_process_stravacallback), re_path(r'^stravacall\_back', rowersviews.rower_process_stravacallback),
re_path(r'^garmin\_callback',rowersviews.rower_process_garmincallback), re_path(r'^garmin\_callback', rowersviews.rower_process_garmincallback),
re_path(r'^sporttracks\_callback',rowersviews.rower_process_sporttrackscallback), re_path(r'^sporttracks\_callback', rowersviews.rower_process_sporttrackscallback),
re_path(r'^polarflowcallback',rowersviews.rower_process_polarcallback), re_path(r'^polarflowcallback', rowersviews.rower_process_polarcallback),
re_path(r'^tp\_callback',rowersviews.rower_process_tpcallback), re_path(r'^tp\_callback', rowersviews.rower_process_tpcallback),
re_path(r'^rp3\_callback',rowersviews.rower_process_rp3callback), re_path(r'^rp3\_callback', rowersviews.rower_process_rp3callback),
re_path(r'^twitter\_callback',rowersviews.rower_process_twittercallback), re_path(r'^twitter\_callback', rowersviews.rower_process_twittercallback),
re_path(r'^i18n/', include('django.conf.urls.i18n')), re_path(r'^i18n/', include('django.conf.urls.i18n')),
re_path(r'^tz_detect/', include('tz_detect.urls')), re_path(r'^tz_detect/', include('tz_detect.urls')),
re_path(r'^logo/',logoview), re_path(r'^logo/', logoview),
re_path(r'^media/(?P<filename>.*\.fit)$',rowersviews.download_fit), re_path(r'^media/(?P<filename>.*\.fit)$', rowersviews.download_fit),
path('django-rq/', include('django_rq.urls')), path('django-rq/', include('django_rq.urls')),
# path('500/', rowersviews.error500_view), # path('500/', rowersviews.error500_view),
# re_path(r'^jsi18n/', django.views.i18n.javascript_catalog,name='jsi18n'), # re_path(r'^jsi18n/', django.views.i18n.javascript_catalog,name='jsi18n'),
] ]
js_info_dict = { js_info_dict = {
'packages': ('recurrence', ), 'packages': ('recurrence', ),
@@ -100,7 +111,7 @@ urlpatterns += [
# monkey patch workaround for bug in recurrence library # monkey patch workaround for bug in recurrence library
django.views.i18n.javascript_catalog = None django.views.i18n.javascript_catalog = None
if settings.DEBUG: # pragma: no cover if settings.DEBUG: # pragma: no cover
import debug_toolbar import debug_toolbar
import django import django
urlpatterns += [ urlpatterns += [
@@ -109,10 +120,13 @@ if settings.DEBUG: # pragma: no cover
kwargs={'document_root': settings.STATIC_ROOT+'plots/'}) kwargs={'document_root': settings.STATIC_ROOT+'plots/'})
] ]
urlpatterns += [ urlpatterns += [
# re_path(r'^__debug__/','debug_toolbar.urls'), # re_path(r'^__debug__/','debug_toolbar.urls'),
re_path(r'^static/(?P<path>.*)$', re_path(
r'^static/(?P<path>.*)$',
django.views.static.serve, django.views.static.serve,
kwargs={'document_root': settings.STATIC_ROOT, kwargs={
'show_indexes': True} 'document_root': settings.STATIC_ROOT,
'show_indexes': True
}
) )
] ]

View File

@@ -9,65 +9,64 @@ from rowingdata import main as rmain
import random import random
def landingview(request):
loginform = LoginForm()
return render(request, def landingview(request):
'landingpage.html', return render(
request,
'landingpage.html',
) )
def logoview(request): # pragma: no cover
def logoview(request): # pragma: no cover
image_data = open(settings.STATIC_ROOT+"/img/apple-icon-144x144.png", "rb").read() image_data = open(settings.STATIC_ROOT+"/img/apple-icon-144x144.png", "rb").read()
return HttpResponse(image_data, content_type="image/png") return HttpResponse(image_data, content_type="image/png")
def rootview(request): # pragma: no cover def rootview(request): # pragma: no cover
magicsentence = rmain() magicsentence = rmain()
loginform = LoginForm() loginform = LoginForm()
planoffering = { planoffering = {
'name': 'PLAN', 'name': 'PLAN',
'image':'/static/img/Plan.png', 'image': '/static/img/Plan.png',
'text':'We offer a fully integrated way for you or your coach to set up a training plan. Compare plan vs execution based on time, distance, heart rate or power.' 'text': 'We offer a fully integrated way for you or your coach to set up a training plan. Compare plan vs execution based on time, distance, heart rate or power.'
} }
uploadoffering = { uploadoffering = {
'name': 'SYNC', 'name': 'SYNC',
'image':'/static/img/upload.png', 'image': '/static/img/upload.png',
'text':'Easily upload data from the most popular devices and apps' 'text': 'Easily upload data from the most popular devices and apps'
} }
logoffering = { logoffering = {
'name': 'LOG', 'name': 'LOG',
'image':'/static/img/log.png', 'image': '/static/img/log.png',
'text':'Maintain a consistent log for all your rowing (indoor and on the water)' 'text': 'Maintain a consistent log for all your rowing (indoor and on the water)'
} }
analyzeoffering = { analyzeoffering = {
'name': 'ANALYZE', 'name': 'ANALYZE',
'image':'/static/img/analyze.png', 'image': '/static/img/analyze.png',
'text':'Analyze your workouts with a consistent set of tools' 'text': 'Analyze your workouts with a consistent set of tools'
} }
compareoffering = { compareoffering = {
'name': 'COMPARE', 'name': 'COMPARE',
'image':'/static/img/compare.png', 'image': '/static/img/compare.png',
'text':'Compare your results between workouts and with other rowers in your team' 'text': 'Compare your results between workouts and with other rowers in your team'
} }
raceoffering = { raceoffering = {
'name': 'RACE', 'name': 'RACE',
'image':'/static/img/Race 01.png', 'image': '/static/img/Race 01.png',
'text':'Virtual regattas are an informal way to add a competitive element to your training and can be used as a quick way to set up small regattas' 'text': 'Virtual regattas are an informal way to add a competitive element to your training and can be used as a quick way to set up small regattas'
} }
coachoffering = { coachoffering = {
'name': 'COACHING', 'name': 'COACHING',
'image':'/static/img/Remote coaching.png', 'image': '/static/img/Remote coaching.png',
'text':'Rowsandall.com is the ideal platform for remote rowing coaching. As a coach, you can easily manage your athletes, set up plans and monitor execution and technique' 'text': 'Rowsandall.com is the ideal platform for remote rowing coaching. As a coach, you can easily manage your athletes, set up plans and monitor execution and technique'
} }
allofferings = [ allofferings = [
planoffering, planoffering,
@@ -77,7 +76,7 @@ def rootview(request): # pragma: no cover
raceoffering, raceoffering,
compareoffering, compareoffering,
coachoffering, coachoffering,
] ]
aux = list(allofferings) aux = list(allofferings)
random.shuffle(aux) random.shuffle(aux)
@@ -88,6 +87,6 @@ def rootview(request): # pragma: no cover
'frontpage.html', 'frontpage.html',
{ {
'versionstring': magicsentence, 'versionstring': magicsentence,
'form':loginform, 'form': loginform,
'offerings':offerings, 'offerings': offerings,
}) })