修复选项不显示

This commit is contained in:
awin-x 2024-10-22 00:38:59 +08:00
parent e99ab0f7f9
commit 033ba6bdb0
9 changed files with 264 additions and 0 deletions

8
.idea/CyberExam.iml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

0
CyberExam/__init__.py Normal file
View File

16
CyberExam/asgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
ASGI config for 不夜城考试 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/5.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CyberExam.settings')
application = get_asgi_application()

137
CyberExam/settings.py Normal file
View File

@ -0,0 +1,137 @@
"""
Django settings for CyberExam project.
Generated by 'django-admin startproject' using Django 5.0.7.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-!78yd6se#zw2x9##j$x@$j9+q)cf!7%pham38azqz+p3j)chwe'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'exam',
]
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',
]
ROOT_URLCONF = 'CyberExam.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [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',
'django.template.context_processors.media',
],
},
},
]
WSGI_APPLICATION = 'CyberExam.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/5.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/5.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/5.0/howto/static-files/
STATIC_URL = 'static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static/'),
os.path.join(BASE_DIR, 'media/'),
]
# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
MEDIA_URL = 'media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
AUTH_USER_MODEL = 'exam.CyberUser'

25
CyberExam/urls.py Normal file
View File

@ -0,0 +1,25 @@
"""
URL configuration for 不夜城考试 project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the "include()" function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from . import settings
urlpatterns = [
path('admin/', admin.site.urls),
path('exam/', include(('exam.urls', 'exam'), namespace='exam')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

26
CyberExam/wsgi.py Normal file
View File

@ -0,0 +1,26 @@
"""
WSGI config for 不夜城考试 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/5.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
from os.path import join,dirname,abspath
PROJECT_DIR = dirname(dirname(abspath(__file__)))#3
import sys # 4
sys.path.insert(0,PROJECT_DIR) # 5
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CyberExam.settings')
application = get_wsgi_application()

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

52
templates/banner.html Normal file
View File

@ -0,0 +1,52 @@
<nav class="navbar navbar-expand-lg navbar-transparent navbar-dark bg-dark py-4">
<div class="container">
<a class="navbar-brand" href="{% url 'exam:home' %}"><strong>不夜城考试中心</strong><small>请勿通过旧网访问</small></a>
<button class="navbar-toggler" type="button" data-action="offcanvas-open" data-target="#navbar_main" aria-controls="navbar_main" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse offcanvas-collapse" id="navbar_main">
<ul class="navbar-nav ml-auto align-items-lg-center">
<h6 class="dropdown-header font-weight-600 d-lg-none px-0">菜单</h6>
<li class="nav-item active">
<a class="nav-link" href="{% url 'exam:home' %}">主页</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbar_main_dropdown_1" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">信息库</a>
<div class="dropdown-menu" aria-labelledby="navbar_1_dropdown_1">
<a class="dropdown-item" href="#">关于不夜城</a>
<a class="dropdown-item" href="#">科技公司</a>
<a class="dropdown-item" href="#">关于旧网</a>
<a class="dropdown-item" href="#">关于帮派</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'exam:get_question' %}">前往答题</a>
</li>
<li class="nav-item">
<a href="{% url 'exam:about' %}" target="_blank" class="nav-link d-lg-none">关于这个网站</a>
<a href="{% url 'exam:about' %}" target="_blank" class="btn btn-sm bg-white d-none d-lg-inline-flex">关于这个网站</a>
</li>
<div class="dropdown-divider d-lg-none my-4"></div>
{% if user.is_active %}
欢迎,{{ user.username }}
<li class="nav-item">
<a class="nav-link" href="{% url 'exam:logout' %}">退出</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'exam:history' %}">历史答题</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'exam:create' %}">贡献题目</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'exam:login' %}">登陆</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'exam:register' %}">注册</a>
</li>
{% endif %}
</ul>
</div>
</div>
</nav>