123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- """
- Django settings for TestLaboratory project.
- Generated by 'django-admin startproject' using Django 3.2.
- For more information on this file, see
- https://docs.djangoproject.com/en/3.2/topics/settings/
- For the full list of settings and their values, see
- https://docs.djangoproject.com/en/3.2/ref/settings/
- """
- import datetime
- from pathlib import Path
- import sys
- import os
- BASE_DIR = Path(__file__).resolve().parent.parent
- sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
- MEDIA_ROOT = os.path.join(BASE_DIR, 'static')
- MEDIA_URL = '/media/'
- SOFTWARE_ROOT = "static/software/"
- PLAN_ROOT = "static/plan-statement/"
- TASK_ROOT = 'static/task-statement/'
- CASE_TEMPLATE_ROOT = 'static/case-template/测试用例模版.xlsx'
- CASE_FILE_ROOT = 'static/case-file/'
- CASE_FILE_EXPORT = 'static/case-file-export/'
- USER_FILE_ROOT = 'static/user-file-export/'
- HTTP_HEAD = 'http://172.26.0.14:8003/'
- SECRET_KEY = 'django-insecure-zo64fvv02msf-se7!dek5*w$17#3nh6zta#!i=79bt9d#f88@i'
- DEBUG = True
- ALLOWED_HOSTS = ['*']
- INSTALLED_APPS = [
- 'simpleui',
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'rest_framework',
- 'corsheaders',
- 'user',
- 'software',
- 'plan',
- 'apps.task',
- 'file',
- 'log',
- 'group'
- ]
- MIDDLEWARE = [
- 'django.middleware.security.SecurityMiddleware',
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.middleware.common.CommonMiddleware',
-
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.middleware.clickjacking.XFrameOptionsMiddleware',
- 'corsheaders.middleware.CorsMiddleware',
- 'django.middleware.common.CommonMiddleware',
- ]
- ROOT_URLCONF = 'TestLaboratory.urls'
- 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',
- ],
- },
- },
- ]
- WSGI_APPLICATION = 'TestLaboratory.wsgi.application'
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.mysql',
- 'OPTIONS': {
- 'read_default_file': 'Config/database_mysql.cnf',
- },
- }
- }
- AUTH_PASSWORD_VALIDATORS = [
- {
- 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
- },
- ]
- REST_FRAMEWORK = {
- 'DEFAULT_PERMISSION_CLASSES': (
- 'rest_framework.permissions.IsAuthenticated'
- ),
- 'DEFAULT_AUTHENTICATION_CLASSES': (
- 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
- 'rest_framework.authentication.BasicAuthentication',
- 'rest_framework.authentication.SessionAuthentication'
- )
- }
- JWT_AUTH = {
-
- 'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=60 * 60 * 2)
- }
- LANGUAGE_CODE = 'en-us'
- TIME_ZONE = 'Asia/Shanghai'
- USE_I18N = True
- USE_L10N = True
- USE_TZ = False
- STATIC_URL = '/static/'
- STATICFILES_DIRS = [
- os.path.join(BASE_DIR, "static"),
- ]
- DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
- REST_FRAMEWORK = {
- "DEFAULT_AUTHENTICATION_CLASSES": ["apps.user.middleware.authentication.JwtAutentication"]
- }
- CORS_ALLOW_CREDENTIALS = True
- CORS_ORIGIN_ALLOW_ALL = True
- CORS_ALLOW_METHODS = (
- 'GET',
- 'POST',
- 'PUT',
- 'PATCH',
- 'DELETE',
- 'OPTIONS'
- )
- CORS_ALLOW_HEADERS = (
- 'x-requested-with',
- 'content-type',
- 'accept',
- 'origin',
- 'authorization',
- 'x-csrftoken'
- )
- import time
- cur_path = os.path.dirname(os.path.realpath(__file__))
- log_path = os.path.join(os.path.dirname(cur_path), 'logs')
- if not os.path.exists(log_path): os.mkdir(log_path)
- LOGGING = {
- 'version': 1,
- 'disable_existing_loggers': False,
- 'formatters': {
-
- 'standard': {
- 'format': '[%(levelname)s] [%(asctime)s] [%(filename)s:%('
- 'lineno)d] [%(module)s:%(funcName)s] '
- '- %(message)s'},
- 'simple': {
- 'format': '%(levelname)s %(message)s'
- },
- },
-
- 'filters': {
- 'require_debug_true': {
- '()': 'django.utils.log.RequireDebugTrue',
- },
- },
-
- 'handlers': {
-
- 'default': {
- 'level': 'INFO',
- 'class': 'logging.handlers.RotatingFileHandler',
- 'filename': os.path.join(log_path, 'all-{}.log'.format(
- time.strftime('%Y-%m-%d'))),
- 'maxBytes': 1024 * 1024 * 300,
- 'backupCount': 10,
- 'formatter': 'standard',
- 'encoding': 'utf-8',
- },
-
- 'error': {
- 'level': 'ERROR',
- 'class': 'logging.handlers.RotatingFileHandler',
- 'filename': os.path.join(log_path, 'error-{}.log'.format(
- time.strftime('%Y-%m-%d'))),
- 'maxBytes': 1024 * 1024 * 5,
- 'backupCount': 5,
- 'formatter': 'standard',
- 'encoding': 'utf-8',
- },
-
- 'console': {
- 'level': 'DEBUG',
- 'class': 'logging.StreamHandler',
- 'formatter': 'standard'
- },
-
- 'info': {
- 'level': 'INFO',
- 'class': 'logging.handlers.RotatingFileHandler',
- 'filename': os.path.join(log_path, 'info-{}.log'.format(
- time.strftime('%Y-%m-%d'))),
- 'maxBytes': 1024 * 1024 * 5,
- 'backupCount': 5,
- 'formatter': 'standard',
- 'encoding': 'utf-8',
- },
- },
-
- 'loggers': {
-
- 'django': {
- 'handlers': ['default', 'console'],
- 'level': 'INFO',
- 'propagate': False
- },
-
- 'log': {
- 'handlers': ['error', 'info', 'console', 'default'],
- 'level': 'INFO',
- 'propagate': True
- },
- }
- }
- """
- python manage.py runserver 172.16.100.180:8000
- """
|