创赢未来评分系统 - 初始化提交(移除大文件)

This commit is contained in:
爽哒哒
2026-03-18 22:28:45 +08:00
commit f26d35da66
315 changed files with 36043 additions and 0 deletions

View File

16
backend/config/asgi.py Normal file
View File

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

404
backend/config/settings.py Normal file
View File

@@ -0,0 +1,404 @@
"""
Django settings for config project.
Generated by 'django-admin startproject' using Django 6.0.1.
For more information on this file, see
https://docs.djangoproject.com/en/6.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/6.0/ref/settings/
"""
import os
from pathlib import Path
from dotenv import load_dotenv
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Load .env file
load_dotenv(BASE_DIR / '.env')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-9hwh_v44(3n)61g)tiwkvm1k0h&5c+u=68&z*!$e0ujpd-6^1o'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ["*"]
# Application definition
INSTALLED_APPS = [
'unfold', # django-unfold必须在admin之前
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'django_filters',
'drf_spectacular', # Swagger文档生成
'drf_spectacular_sidecar',
# 'adminsortable2', # 暂时禁用,改用手动设置
'shop',
'community',
'competition',
'ai_services',
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'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',
]
CORS_ALLOW_ALL_ORIGINS = True
CSRF_TRUSTED_ORIGINS = [
"https://market.quant-speed.com",
"http://market.quant-speed.com",
"http://localhost:8000",
]
ROOT_URLCONF = 'config.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'config.wsgi.application'
# Database
# https://docs.djangoproject.com/en/6.0/ref/settings/#databases
# 数据库配置:默认使用 SQLite如果有环境变量配置则使用 PostgreSQL
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
#从环境变量获取数据库配置 (Docker 环境会自动注入这些变量。
# 只有当 DB_HOST 被明确设置且不为空时才使用 PostgreSQL
DB_HOST = os.environ.get('DB_HOST', '')
if DB_HOST and DB_HOST != '6.6.6.66':
DATABASES['default'] = {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('DB_NAME', 'market'),
'USER': os.environ.get('DB_USER', 'market'),
'PASSWORD': os.environ.get('DB_PASSWORD', '123market'),
'HOST': DB_HOST,
'PORT': os.environ.get('DB_PORT', '5432'),
}
# DB_HOST = os.environ.get('DB_HOST', '121.43.104.161')
# if DB_HOST:
# DATABASES['default'] = {
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': os.environ.get('DB_NAME', 'market'),
# 'USER': os.environ.get('DB_USER', 'market'),
# 'PASSWORD': os.environ.get('DB_PASSWORD', '123market'),
# 'HOST': DB_HOST,
# 'PORT': os.environ.get('DB_PORT', '6433'),
# }
# Password validation
# https://docs.djangoproject.com/en/6.0/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/6.0/topics/i18n/
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/6.0/howto/static-files/
STATIC_URL = 'static/'
STATIC_ROOT = BASE_DIR / 'staticfiles'
# 静态文件配置
STATICFILES_DIRS = [
BASE_DIR / 'static',
]
# 媒体文件配置
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'
# Django REST Framework配置
REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
'DEFAULT_AUTHENTICATION_CLASSES': [],
'DEFAULT_PERMISSION_CLASSES': [],
}
# drf-spectacular配置
SPECTACULAR_SETTINGS = {
'TITLE': '科技公司产品购买API',
'DESCRIPTION': '科技公司产品购买官网的API文档',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': True,
'SERVE_PERMISSIONS': ['rest_framework.permissions.AllowAny'],
'COMPONENT_SPLIT_REQUEST': True,
'SWAGGER_UI_DIST': 'SIDECAR',
'SWAGGER_UI_FAVICON_HREF': 'SIDECAR',
'REDOC_DIST': 'SIDECAR',
}
from django.urls import reverse_lazy
# django-unfold配置
UNFOLD = {
"SITE_TITLE": "创赢未来",
"SITE_HEADER": "创赢未来评分管理后台",
"SITE_URL": "/",
"COLORS": {
"primary": {
"50": "rgb(236 254 255)",
"100": "rgb(207 250 254)",
"200": "rgb(165 243 252)",
"300": "rgb(103 232 249)",
"400": "rgb(34 211 238)",
"500": "rgb(6 182 212)",
"600": "rgb(8 145 178)",
"700": "rgb(14 116 144)",
"800": "rgb(21 94 117)",
"900": "rgb(22 78 99)",
"950": "rgb(8 51 68)",
},
},
"SIDEBAR": {
"show_search": True,
"show_all_applications": False,
"navigation": [
{
"title": "用户管理",
"separator": True,
"items": [
{
"title": "微信用户",
"icon": "people",
"link": reverse_lazy("admin:shop_wechatuser_changelist"),
},
],
},
{
"title": "首页管理",
"separator": True,
"items": [
{
"title": "首页配置",
"icon": "home",
"link": reverse_lazy("admin:competition_homepageconfig_changelist"),
},
{
"title": "轮播图管理",
"icon": "image",
"link": reverse_lazy("admin:competition_carouselitem_changelist"),
},
],
},
{
"title": "比赛管理",
"separator": True,
"items": [
{
"title": "比赛列表",
"icon": "emoji_events",
"link": reverse_lazy("admin:competition_competition_changelist"),
},
{
"title": "比赛人员/报名",
"icon": "group_add",
"link": reverse_lazy("admin:competition_competitionenrollment_changelist"),
},
{
"title": "参赛项目",
"icon": "lightbulb",
"link": reverse_lazy("admin:competition_project_changelist"),
},
{
"title": "评分记录",
"icon": "score",
"link": reverse_lazy("admin:competition_score_changelist"),
},
{
"title": "评委评语",
"icon": "rate_review",
"link": reverse_lazy("admin:competition_comment_changelist"),
},
],
},
{
"title": "系列活动",
"separator": True,
"items": [
{
"title": "活动管理",
"icon": "calendar_today",
"link": reverse_lazy("admin:community_activity_changelist"),
},
{
"title": "活动报名",
"icon": "how_to_reg",
"link": reverse_lazy("admin:community_activitysignup_changelist"),
},
],
},
{
"title": "课程培训",
"separator": True,
"items": [
{
"title": "课程管理",
"icon": "school",
"link": reverse_lazy("admin:shop_vccourse_changelist"),
},
{
"title": "课程报名",
"icon": "menu_book",
"link": reverse_lazy("admin:shop_courseenrollment_changelist"),
},
],
},
{
"title": "身份标签",
"separator": True,
"items": [
{
"title": "标签管理",
"icon": "label",
"link": reverse_lazy("admin:shop_identitytag_changelist"),
},
{
"title": "用户身份",
"icon": "person_pin",
"link": reverse_lazy("admin:shop_useridentity_changelist"),
},
],
},
{
"title": "AI 听悟",
"separator": True,
"items": [
{
"title": "转写与总结任务",
"icon": "record_voice_over",
"link": reverse_lazy("admin:ai_services_transcriptiontask_changelist"),
},
{
"title": "AI 评估模板",
"icon": "rule",
"link": reverse_lazy("admin:ai_services_aievaluationtemplate_changelist"),
},
{
"title": "AI 评估结果",
"icon": "psychology",
"link": reverse_lazy("admin:ai_services_aievaluation_changelist"),
},
],
},
{
"title": "系统配置",
"separator": True,
"items": [
{
"title": "微信支付配置",
"icon": "payment",
"link": reverse_lazy("admin:shop_wechatpayconfig_changelist"),
},
{
"title": "管理员通知手机号",
"icon": "contact_phone",
"link": reverse_lazy("admin:shop_adminphonenumber_changelist"),
},
{
"title": "用户认证",
"icon": "security",
"link": reverse_lazy("admin:auth_user_changelist"),
},
],
},
],
},
}
# 重新启用自动补齐斜杠,方便 Admin 使用
# 微信支付回调接口已在 urls.py 中配置 re_path 兼容无斜杠的情况
APPEND_SLASH = True
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'root': {
'handlers': ['console'],
'level': 'INFO',
},
}
# 阿里云配置
ALIYUN_ACCESS_KEY_ID = os.environ.get('ALIYUN_ACCESS_KEY_ID', '')
ALIYUN_ACCESS_KEY_SECRET = os.environ.get('ALIYUN_ACCESS_KEY_SECRET', '')
ALIYUN_OSS_BUCKET_NAME = os.environ.get('ALIYUN_OSS_BUCKET_NAME', '')
ALIYUN_OSS_ENDPOINT = os.environ.get('ALIYUN_OSS_ENDPOINT', 'oss-cn-shanghai.aliyuncs.com')
ALIYUN_OSS_INTERNAL_ENDPOINT = os.environ.get('ALIYUN_OSS_INTERNAL_ENDPOINT', '')
ALIYUN_TINGWU_APP_KEY = os.environ.get('ALIYUN_TINGWU_APP_KEY', '') # 听悟AppKey
DASHSCOPE_API_KEY = os.environ.get('DASHSCOPE_API_KEY', '')

29
backend/config/urls.py Normal file
View File

@@ -0,0 +1,29 @@
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView, SpectacularRedocView
from competition import judge_views
urlpatterns = [
path('admin/', admin.site.urls),
# Judge System Routes
path('judge/', include('competition.judge_urls')),
path('competition/admin/', judge_views.admin_entry, name='judge_admin_entry_root'),
path('api/', include('shop.urls')),
path('api/community/', include('community.urls')),
path('api/competition/', include('competition.urls')),
path('api/ai/', include('ai_services.urls')),
# Swagger文档路由
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
path('api/docs/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
path('api/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
]
# 静态文件配置(开发环境)
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

16
backend/config/wsgi.py Normal file
View File

@@ -0,0 +1,16 @@
"""
WSGI config for config 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/6.0/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()