settings.py 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. # coding=utf-8
  2. """
  3. Django settings for ly_baoxiu_admin project.
  4. Generated by 'django-admin startproject' using Django 2.2.5.
  5. For more information on this file, see
  6. https://docs.djangoproject.com/en/2.2/topics/settings/
  7. For the full list of settings and their values, see
  8. https://docs.djangoproject.com/en/2.2/ref/settings/
  9. """
  10. import os, datetime
  11. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  12. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  13. # Quick-start development settings - unsuitable for production
  14. # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
  15. # SECURITY WARNING: keep the secret key used in production secret!
  16. SECRET_KEY = 'c+)5afbc(m&qe^8t7gc54w6f-*==b2(l0(8rqef-cbwtv*3n$w'
  17. # SECURITY WARNING: don't run with debug turned on in production!
  18. DEBUG = True
  19. ALLOWED_HOSTS = ['*']
  20. # Application definition
  21. INSTALLED_APPS = [
  22. # 'django.contrib.admin',
  23. 'django.contrib.auth',
  24. 'django.contrib.contenttypes',
  25. 'django.contrib.sessions',
  26. 'django.contrib.messages',
  27. 'django.contrib.staticfiles',
  28. 'corsheaders',
  29. 'rest_framework',
  30. 'rest_framework_jwt',
  31. 'django_filters',
  32. 'apps.account',
  33. 'apps.log',
  34. 'apps.WechatApplet',
  35. 'apps.WechatTp',
  36. 'apps.api',
  37. 'apps.tenant.employee',
  38. 'apps.tenant',
  39. 'apps.upload',
  40. 'apps.tenant.option',
  41. 'apps.tenant.area',
  42. 'apps.tenant.config',
  43. 'apps.tenant.building',
  44. 'apps.tenant.equipment',
  45. 'apps.tenant.device',
  46. 'apps.tenant.repair_order',
  47. 'apps.tenant.inspection_order',
  48. 'apps.wxapp',
  49. 'apps.tenant.notices'
  50. ]
  51. MIDDLEWARE = [
  52. 'django.middleware.security.SecurityMiddleware',
  53. 'django.contrib.sessions.middleware.SessionMiddleware',
  54. 'django.middleware.common.CommonMiddleware',
  55. 'django.middleware.csrf.CsrfViewMiddleware',
  56. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  57. 'django.contrib.messages.middleware.MessageMiddleware',
  58. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  59. 'corsheaders.middleware.CorsMiddleware',
  60. ]
  61. CORS_ALLOW_CREDENTIALS = True # 允许携带cookie
  62. CORS_ORIGIN_ALLOW_ALL = True
  63. CORS_ALLOW_METHODS = (
  64. 'DELETE',
  65. 'GET',
  66. 'OPTIONS',
  67. 'PATCH',
  68. 'POST',
  69. 'PUT',
  70. 'VIEW',
  71. )
  72. CORS_ALLOW_HEADERS = (
  73. 'XMLHttpRequest',
  74. 'X_FILENAME',
  75. 'accept-encoding',
  76. 'authorization',
  77. 'content-type',
  78. 'dnt',
  79. 'origin',
  80. 'token',
  81. 'user-agent',
  82. 'x-csrftoken',
  83. 'x-requested-with',
  84. 'Pragma',
  85. )
  86. ROOT_URLCONF = 'ly_baoxiu_admin.urls'
  87. AUTH_USER_MODEL = "account.User"
  88. AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.AllowAllUsersModelBackend']
  89. TEMPLATES = [
  90. {
  91. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  92. 'DIRS': [],
  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. WSGI_APPLICATION = 'ly_baoxiu_admin.wsgi.application'
  105. # Database
  106. # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
  107. DATABASES = {
  108. 'default': {
  109. 'ENGINE': 'django.db.backends.mysql',
  110. 'NAME': 'ly_report_repair',
  111. 'USER': 'carwin',
  112. 'PASSWORD': 'carwin!@#',
  113. 'HOST': '192.168.2.45',
  114. 'PORT': 3306,
  115. },
  116. # 'default': {
  117. # 'ENGINE': 'django.db.backends.mysql',
  118. # 'NAME': 'baoxiu',
  119. # 'USER': 'baoxiu',
  120. # 'PASSWORD': 'baoxiu!@#',
  121. # 'HOST': '106.12.149.71',
  122. # 'PORT': 3306,
  123. # }
  124. }
  125. # Password validation
  126. # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
  127. AUTH_PASSWORD_VALIDATORS = [
  128. {
  129. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  130. },
  131. {
  132. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  133. },
  134. {
  135. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  136. },
  137. {
  138. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  139. },
  140. ]
  141. UNKNOW = 0
  142. FEMALE = 1
  143. MALE = 2
  144. GENDER_CHOICES = (
  145. (UNKNOW, u'未知'),
  146. (FEMALE, u'女'),
  147. (MALE, u'男'),
  148. )
  149. DEFAULT = 0
  150. PASS = 1
  151. REJECT = 2
  152. CHECK_STATE_CHOICES = (
  153. (DEFAULT, u'未审核'),
  154. (PASS, u'已通过'),
  155. (REJECT, u'未通过'),
  156. )
  157. NOT_CHECKED = 1
  158. CHECKED = 2
  159. DISPATCH = 3
  160. HANG_UP = 4
  161. TURN_EMPLOYEE = 5
  162. FINISH = 6
  163. APPRAISE = 7
  164. INVALID = 8
  165. CANCEL_HANG_UP = 9
  166. REPAIR_STATUS_CHOICES = (
  167. (NOT_CHECKED, '待审核'),
  168. (CHECKED, '已审核,待派单'),
  169. (DISPATCH, '已派单'),
  170. (HANG_UP, '已挂起'),
  171. (TURN_EMPLOYEE, '转单'),
  172. (FINISH, '已完工,待评价'),
  173. (APPRAISE, '已评价'),
  174. (INVALID, '作废'),
  175. (CANCEL_HANG_UP, '取消挂起'),
  176. )
  177. # Internationalization
  178. # https://docs.djangoproject.com/en/2.2/topics/i18n/
  179. LANGUAGE_CODE = 'zh-hans'
  180. TIME_ZONE = 'Asia/Shanghai'
  181. USE_I18N = True
  182. USE_L10N = True
  183. USE_TZ = False
  184. # Static files (CSS, JavaScript, Images)
  185. # https://docs.djangoproject.com/en/2.2/howto/static-files/
  186. STATIC_URL = '/static/'
  187. STATIC_ROOT = os.path.join(BASE_DIR, "uis/static/")
  188. STATICFILES_DIRS = (
  189. os.path.join(BASE_DIR, "static"),
  190. )
  191. MEDIA_URL = '/up/'
  192. MEDIA_ROOT = os.path.join(BASE_DIR, "uis/up/")
  193. UIS_URL = '/'
  194. UIS_ROOT = os.path.join(BASE_DIR, "uis/")
  195. # SERVER_DOMAIN = 'https://baoxiu360.top'
  196. SERVER_DOMAIN = 'http://192.168.2.45:8887'
  197. JWT_AUTH = {
  198. 'JWT_EXPIRATION_DELTA': datetime.timedelta(days=30),
  199. 'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=360),
  200. 'JWT_ALLOW_REFRESH': True,
  201. }
  202. REST_FRAMEWORK = {
  203. 'DEFAULT_PERMISSION_CLASSES': (
  204. 'rest_framework.permissions.AllowAny',
  205. ),
  206. 'DEFAULT_AUTHENTICATION_CLASSES': (
  207. 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
  208. # 'rest_framework.authentication.SessionAuthentication',
  209. # 'rest_framework.authentication.BasicAuthentication',
  210. ),
  211. 'DEFAULT_PARSER_CLASSES': (
  212. 'rest_framework.parsers.JSONParser',
  213. 'rest_framework.parsers.FormParser',
  214. 'rest_framework.parsers.MultiPartParser'
  215. ),
  216. 'DEFAULT_RENDERER_CLASSES': (
  217. 'rest_framework.renderers.JSONRenderer',
  218. # 'rest_framework.renderers.BrowsableAPIRenderer',
  219. ),
  220. 'DEFAULT_FILTER_BACKENDS': (
  221. 'django_filters.rest_framework.DjangoFilterBackend',
  222. ),
  223. # 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
  224. 'DEFAULT_PAGINATION_CLASS': 'utils.pagination.CustomPagination',
  225. # 'EXCEPTION_HANDLER': 'rest_framework.views.exception_handler',
  226. 'EXCEPTION_HANDLER': 'utils.handler.custom_exception_handler',
  227. 'PAGE_SIZE': 10,
  228. 'DATETIME_FORMAT': "%Y-%m-%d %H:%M:%S",
  229. 'NON_FIELD_ERRORS_KEY': "error", # 序列化器错误KEY名称
  230. }
  231. WEAPP = {
  232. 'nick_name': '燎原云报修', # 燎原云报修小程序
  233. 'appid': 'wx0a4ed500a98c0507',
  234. 'secret': '0700bb3a58cd09505e78d7c7d1781042',
  235. 'message_template': 'V-b3rOtf47SbxsIoN1o2IdAL7cNjfrCnrlD6m-XEeYs',
  236. }
  237. # 导入本地设置
  238. try:
  239. from ly_baoxiu_admin.local_settings import *
  240. except ImportError:
  241. pass