· 5 years ago · Jan 14, 2020, 08:44 AM
1from datetime import timedelta
2from celery.schedules import crontab
3import logging
4import sys
5import sentry_sdk
6from sentry_sdk.integrations.celery import CeleryIntegration
7from sentry_sdk.integrations.django import DjangoIntegration
8from sentry_sdk.integrations.logging import LoggingIntegration
9from .base import *
10
11
12# Sentry config
13# sentry_logging = LoggingIntegration(
14# level=logging.INFO, # Capture info and above as breadcrumbs
15# event_level=logging.ERROR # Send errors as events
16# )
17# sentry_sdk.init(
18# dsn="http://bfbba0935b274da7956ba72472fb9aa5:3ab70251ffd04e54847cfb3a70e3c691@aba3ee3a7140511e9a24a02d221fcdf5-1522747028.ap-southeast-1.elb.amazonaws.com:9000/2",
19# integrations=[sentry_logging, CeleryIntegration(), DjangoIntegration()],
20# debug=False,
21# environment="local"
22# )
23
24# SECURITY WARNING: keep the secret key used in production secret!
25SECRET_KEY = "&yb$1r3@c5vw)#okdp)rur@qx80#tfnz1(daq(40w2m@b^x)hq"
26
27# SECURITY WARNING: don't run with debug turned on in production!
28DEBUG = True
29
30ALLOWED_HOSTS = []
31INTERNAL_IPS = ["127.0.0.1", "localhost", ]
32
33# Application definition
34INSTALLED_APPS = [
35 "django.contrib.admin",
36 "django.contrib.auth",
37 "django.contrib.contenttypes",
38 "django.contrib.sessions",
39 "django.contrib.messages",
40 "django.contrib.staticfiles",
41 "django_celery_results",
42 "django_filters",
43 "rest_framework",
44 "rest_framework.authtoken",
45 "simple_history",
46 "account",
47 "analytics",
48 "device_fraud",
49 "fraud",
50 "meta",
51 "tracker",
52]
53
54MIDDLEWARE = [
55 "django.middleware.security.SecurityMiddleware",
56 "django.contrib.sessions.middleware.SessionMiddleware",
57 "django.middleware.common.CommonMiddleware",
58 "django.middleware.csrf.CsrfViewMiddleware",
59 "django.contrib.auth.middleware.AuthenticationMiddleware",
60 "account.middleware.service_user_middleware",
61 "django.contrib.messages.middleware.MessageMiddleware",
62 "django.middleware.clickjacking.XFrameOptionsMiddleware",
63 "simple_history.middleware.HistoryRequestMiddleware",
64]
65
66# Database
67# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
68
69DATABASES = {
70 "default": {
71 "ENGINE": "django.db.backends.mysql",
72 "HOST": os.getenv('DB_HOST', "127.0.0.1"),
73 "NAME": os.getenv("DB_NAME", "sherlock_db"),
74 "USER": os.getenv("DB_USER", "root"),
75 "PASSWORD": os.getenv("DB_PASSWORD", "")
76 },
77 # "momma": {
78 # "ENGINE": "django.db.backends.mysql",
79 # "HOST": "area51.pathaointernal.com",
80 # "NAME": "pathao_rides_api",
81 # "USER": "webapp",
82 # "PASSWORD": "6faf199ab2105857c1e43974d66b1680",
83 # }
84}
85
86if "test" in sys.argv:
87 DATABASES = {
88 "default": {
89 "ENGINE": "django.db.backends.sqlite3",
90 "NAME": ":memory:",
91 }
92 }
93
94# EMAIL BACKEND
95# https://docs.djangoproject.com/en/2.1/topics/email/
96EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
97
98# Password validation
99# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
100
101AUTH_PASSWORD_VALIDATORS = [
102 {
103 "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
104 },
105 {
106 "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
107 },
108 {
109 "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
110 },
111 {
112 "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
113 },
114]
115
116# DRF settings
117
118REST_FRAMEWORK = {
119 "DEFAULT_AUTHENTICATION_CLASSES": (
120 "rest_framework.authentication.SessionAuthentication",
121 "rest_framework.authentication.TokenAuthentication",
122 ),
123 "DEFAULT_FILTER_BACKENDS": (
124 "django_filters.rest_framework.DjangoFilterBackend",
125 ),
126 "DEFAULT_PAGINATION_CLASS": "base.api_pagination.PageNumberPagination",
127 "ORDERING_PARAM": "-id",
128 "PAGE_SIZE": REST_FRAMEWORK_PAGE_SIZE,
129 "DEFAULT_PERMISSION_CLASSES": (
130 "account.api_permissions.IsInternalApp",
131 ),
132}
133
134# Celery settings
135CELERY_BROKER_URL = "redis://localhost:6379"
136CELERY_RESULT_BACKEND = "redis://localhost:6379"
137CELERY_ACCEPT_CONTENT = ["application/json"]
138CELERY_TASK_SERIALIZER = "json"
139CELERY_RESULT_SERIALIZER = "json"
140CELERY_TIMEZONE = "UTC"
141CELERY_BEAT_SCHEDULE = {
142 "every_10_minutes": {
143 "task": "tracker.schedule_query",
144 "schedule": timedelta(minutes=10)
145 },
146 "auto_un_suspend_everyday": {
147 "task": "fraud.auto_un_suspend",
148 "schedule": crontab(hour=11, minute=30) # Executes everyday at 11:30 A.M.
149 }
150}
151
152# Dependent Services Configs
153
154PAYOUT_API_URL = "https://dev-payouts-api.pathaointernal.com"
155PAYOUT_APP_KEY = "1e12c2dc6f9c41cba7af30a6ae013973"
156
157RIDE_API_URL = "https://dev-rides.pathaointernal.com"
158RIDE_APP_KEY = "28d9ae1dad44d34eddc54d5a8c69143c"
159
160QUEST_API_URL = "http://35.229.155.30"
161QUEST_APP_KEY = "1f67c742c96d84a56b32f6b7f08af30a"
162
163SUSPENSION_API_URL = ""
164SUSPENSION_APP_KEY = ""
165SUSPENSION_APP_TOKEN = ""
166
167CLONE_SUSPENSION_APP_KEY = ""
168CLONE_SUSPENSION_APP_TOKEN = ""
169
170IN_APP_NOTIFICATION_API_URL = "http://35.221.168.94:80"
171IN_APP_NOTIFICATION_API_AUTH_USER = "pathao_username"
172IN_APP_NOTIFICATION_API_AUTH_PASS = "pathao_password"
173
174PUSH_NOTIFICATION_API_URL = "http://35.201.190.94:80"
175PUSH_NOTIFICATION_API_AUTH_USER = "pathao_user"
176PUSH_NOTIFICATION_API_AUTH_PASS = "pathao_password"
177
178AUTH_API_URL = ""