Coverage for pear\settings.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

38 statements  

1""" 

2Django settings for this project. 

3 

4Generated by 'django-admin startproject' using Django 3,2,4. 

5 

6For more information on this file, see 

7https://docs.djangoproject.com/en/3.2/topics/settings/ 

8 

9For the full list of settings and their values, see 

10https://docs.djangoproject.com/en/3.2/ref/settings/ 

11""" 

12 

13from pathlib import Path 

14import os 

15 

16# Build paths inside the project like this: os.path.join(BASE_DIR, ...) 

17BASE_DIR = Path(__file__).resolve().parent.parent 

18 

19SETTINGS_PATH = Path(__file__).resolve().parent 

20 

21 

22# Quick-start development settings - unsuitable for production 

23# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ 

24 

25# SECURITY WARNING: keep the secret key used in production secret! 

26# The SECRET_KEY is provided via an environment variable in OpenShift 

27SECRET_KEY = os.getenv( 

28 'DJANGO_SECRET_KEY', 

29 # safe value used for development when DJANGO_SECRET_KEY might not be set 

30 '9e4@&tw46$l31)zrqe3wi+-slqm(ruvz&se0^%9#6(_w3ui!c0' 

31) 

32 

33# SECURITY WARNING: don't run with debug turned on in production! 

34DEBUG = True 

35 

36ALLOWED_HOSTS = ['*'] 

37 

38 

39# Application definition 

40 

41INSTALLED_APPS = [ 

42 'django.contrib.admin', 

43 'django.contrib.auth', 

44 'django.contrib.contenttypes', 

45 'django.contrib.sessions', 

46 'django.contrib.messages', 

47 'django.contrib.staticfiles', 

48 'debug_toolbar', 

49 

50 # 3rd party apps 

51 'rest_framework', # new 

52 'rest_framework.authtoken', # new 

53 'rest_auth', # new 

54 'django.contrib.sites', # new 

55 'allauth', # new 

56 'allauth.account', # new 

57 'allauth.socialaccount', # new 

58 'rest_auth.registration', # new 

59 'corsheaders', # new 

60 'magic', 

61 

62 # local apps 

63 'dashboard', 

64 'users' 

65] 

66 

67 

68 

69MIDDLEWARE = [ 

70 'corsheaders.middleware.CorsMiddleware', 

71 'django.middleware.security.SecurityMiddleware', 

72 'django.contrib.sessions.middleware.SessionMiddleware', 

73 'django.middleware.common.CommonMiddleware', 

74 'django.middleware.csrf.CsrfViewMiddleware', 

75 'django.contrib.auth.middleware.AuthenticationMiddleware', 

76 'django.contrib.messages.middleware.MessageMiddleware', 

77 'django.middleware.clickjacking.XFrameOptionsMiddleware', 

78 'whitenoise.middleware.WhiteNoiseMiddleware', 

79 'debug_toolbar.middleware.DebugToolbarMiddleware', 

80] 

81 

82CORS_ORIGIN_ALLOW_ALL = True 

83 

84 

85 

86ROOT_URLCONF = 'pear.urls' 

87 

88TEMPLATES = [ 

89 { 

90 'BACKEND': 'django.template.backends.django.DjangoTemplates', 

91 'DIRS': ["templates", 

92 "dashboard/templates"], 

93 'APP_DIRS': True, 

94 'OPTIONS': { 

95 'context_processors': [ 

96 'django.template.context_processors.debug', 

97 'django.template.context_processors.request', 

98 'django.contrib.auth.context_processors.auth', 

99 'django.contrib.messages.context_processors.messages', 

100 ], 

101 }, 

102 }, 

103] 

104 

105WSGI_APPLICATION = 'pear.wsgi.application' 

106 

107 

108# Database 

109# https://docs.djangoproject.com/en/3.2/ref/settings/#databases 

110 

111 

112DATABASES = { 

113 'default': { 

114 'ENGINE': 'django.db.backends.postgresql_psycopg2', 

115 # 'NAME': os.getenv('DJANGO_DB_NAME', 'django_db'), 

116 # 'USER': os.getenv('DATABASE_USER', 'django'), 

117 # 'PASSWORD': os.getenv('DATABASE_PASSWORD', 'afiLQho3r50iSoKb'), 

118 # 'HOST': os.getenv('DJANGO_DB_HOST', '172.30.186.143'), 

119 'NAME': os.getenv('DJANGO_DB_NAME', 'postgres'), 

120 'USER': os.getenv('DATABASE_USER', 'postgres'), 

121 'PASSWORD': os.getenv('DATABASE_PASSWORD', 'postgres'), 

122 'HOST': os.getenv('DJANGO_DB_HOST', 'localhost'), 

123 'PORT': os.getenv('DJANGO_DB_PORT', '5432'), 

124 } 

125} 

126 

127# https://docs.djangoproject.com/en/3.2/releases/3.2/#customizing-type-of-auto-created-primary-keys 

128DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' 

129 

130# Password validation 

131# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators 

132 

133AUTH_PASSWORD_VALIDATORS = [ 

134 { 

135 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 

136 }, 

137 { 

138 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 

139 }, 

140 { 

141 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 

142 }, 

143 { 

144 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 

145 }, 

146] 

147 

148EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' 

149 

150AUTHENTICATION_BACKENDS = [ 

151 "django.contrib.auth.backends.ModelBackend", 

152 "allauth.account.auth_backends.AuthenticationBackend", 

153] 

154 

155SITE_ID = 1 

156ACCOUNT_EMAIL_REQUIRED = True 

157ACCOUNT_USERNAME_REQUIRED = False 

158ACCOUNT_SESSION_REMEMBER = True 

159ACCOUNT_AUTHENTICATION_METHOD = 'email' 

160ACCOUNT_UNIQUE_EMAIL = True 

161 

162REST_FRAMEWORK = { 

163 'DATETIME_FORMAT': "%m/%d/%Y %I:%M%P", 

164 'DEFAULT_AUTHENTICATION_CLASSES': [ 

165 'rest_framework.authentication.BasicAuthentication', 

166 'rest_framework.authentication.TokenAuthentication', 

167 'rest_framework.authentication.SessionAuthentication', 

168 ], 

169 # 'DEFAULT_PERMISSION_CLASSES': [ 

170 # 'rest_framework.permissions.IsAuthenticated', 

171 # ] 

172} 

173 

174# Internationalization 

175# https://docs.djangoproject.com/en/3.2/topics/i18n/ 

176 

177LANGUAGE_CODE = 'en-us' 

178 

179TIME_ZONE = 'UTC' 

180 

181USE_I18N = True 

182 

183USE_L10N = True 

184 

185USE_TZ = True 

186 

187 

188# Static files (CSS, JavaScript, Images) 

189# https://docs.djangoproject.com/en/3.2/howto/static-files/ 

190 

191STATIC_URL = '/static/' 

192STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') 

193 

194STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' 

195 

196STATIC_URL = '/static/' 

197 

198AUTH_USER_MODEL = 'users.CustomUser' 

199 

200DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' 

201 

202ACCEPTABLE_FILE_TYPES = {'.xlsx', '.csv'} 

203 

204INTERNAL_IPS = ['127.0.0.1']