first commit

This commit is contained in:
renjianbo
2026-01-09 18:28:10 +08:00
parent 8ca573e948
commit 5cc088a210
134 changed files with 8730 additions and 0 deletions

2
config/__init__.py Normal file
View File

@@ -0,0 +1,2 @@
import pymysql
pymysql.install_as_MySQLdb()

View File

@@ -0,0 +1,31 @@
DEBUG = True
DOMAIN = ''
ALLOWED_HOSTS = ['*']
BANK_REPO = 'F:/PythonProject/exam/backup' # 设置题库上传路径
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'exam',
'USER': 'root',
'PASSWORD': 'root'
}
}
# send e-mail
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
EMAIL_HOST = 'smtp.qq.com'
EMAIL_PORT = 25
EMAIL_HOST_USER = '694798056@qq.com'
EMAIL_HOST_PASSWORD = 'iggdmwmarjvebccg'
# Email address that error messages come from.
# Default email address to use for various automated correspondence from
# the site managers.
SERVER_EMAIL = DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
# People who get code error notifications.
# In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')]
ADMINS = [('zhang8680@outlook.com'),]
# Not-necessarily-technical managers of the site. They get broken link
# notifications and other various emails.
MANAGERS = ADMINS

256
config/settings.py Normal file
View File

@@ -0,0 +1,256 @@
"""
Django settings for exam project.
Generated by 'django-admin startproject' using Django 1.11.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
WEB_DIR = os.path.join(BASE_DIR, 'web')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'n@dmhs9)21$mzj7an@_89q_fusqws@p+qy(np0vmcdmgk7c$@i'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = ['http://127.0.0.1:8000/']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'account',
'business',
'competition',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'utils.processors.UserAgentDetectionMiddleware',
]
ROOT_URLCONF = 'config.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(WEB_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',
],
'loaders': [
('django.template.loaders.cached.Loader', [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]),
],
},
},
]
WSGI_APPLICATION = 'config.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'exam',
'USER': 'root',
'PASSWORD': ''
}
}
# Redis配置
REDIS = {
'default': {
'HOST': '127.0.0.1',
'PORT': 6379,
'USER': '',
'PASSWORD': '',
'db': 0,
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
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',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'zh-Hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = True
SESSION_COOKIE_AGE = 60 * 60 * 24
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(WEB_DIR, 'static'),
)
STATIC_ROOT = os.path.join(BASE_DIR, 'collect_static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
BANK_REPO = '/home/hugo/bank_backup'
# Extension Configuration
BASE_NUM_ID = 100000
INIT_PASSWORD = 'p@ssw0rd'
DOMAIN = "http://127.0.0.1:8000"
WEB_INDEX_URI = "{}/web/index".format(DOMAIN)
WEB_LOGIN_REDIRECT_URI = "{}/auth/login_redirect"
# send e-mail
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
EMAIL_SSL_CERTFILE = None
EMAIL_SSL_KEYFILE = None
EMAIL_TIMEOUT = None
EMAIL_HOST = ''
EMAIL_PORT = 465
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = 'check from local_settings'
# 错误信息邮件设置
# Email address that error messages come from.
SERVER_EMAIL = EMAIL_HOST_USER
# Default email address to use for various automated correspondence from
# the site managers.
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
# People who get code error notifications.
# In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')]
ADMINS = [(),]
# Not-necessarily-technical managers of the site. They get broken link
# notifications and other various emails.
MANAGERS = ADMINS
WXWEB_LOGIN_PARAMS = {
"appid": "xx",
"token": "",
"appsecret": "",
"scope": "snsapi_login",
"redirect_uri": WEB_INDEX_URI,
"domain": DOMAIN,
"state": "wxweblogin"
}
# logger 设置
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'email': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
'formatter':'verbose'
},
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'tmp/test.log',
'formatter': 'verbose',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
},
},
'loggers': {
'file': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
'console': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
'email': {
'handlers': ['email'],
'level': 'ERROR',
'propagate': True,
}
},
}
# 引入外部settings文件
try:
from config.local_settings import *
except ImportError:
pass

50
config/urls.py Normal file
View File

@@ -0,0 +1,50 @@
"""exam URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic import TemplateView
from django.urls import path
from account import login_render
urlpatterns = [
path('admin/', admin.site.urls),
path('', login_render.web_index, name='web_index'),
path('index', login_render.web_index, name='web_index'),
path('login', login_render.web_login, name='web_login'),
path('logout', login_render.web_logout, name='web_logout'),
]
urlpatterns += [
path('bs/', include(('competition.urls','competition'), namespace='bs')), # 比赛
path('api/', include(('api.urls','api'), namespace='api')), # 接口
path('biz/', include(('business.urls','business'), namespace='biz')), # 机构
]
urlpatterns += [
path('auth/', include(('account.urls','account'), namespace='auth')),
]
handler403 = login_render.error
handler404 = login_render.error
handler500 = login_render.error
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
admin.site.site_header = "[智慧校园测评系统]"

16
config/wsgi.py Normal file
View File

@@ -0,0 +1,16 @@
"""
WSGI config for exam project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
application = get_wsgi_application()