diff --git a/EduSystemServer/API/admin.py b/EduSystemServer/API/admin.py index 8c38f3f..0a3db86 100644 --- a/EduSystemServer/API/admin.py +++ b/EduSystemServer/API/admin.py @@ -1,3 +1,5 @@ from django.contrib import admin # Register your models here. + + diff --git a/EduSystemServer/API/middle.py b/EduSystemServer/API/middle.py index 183a31f..35f0270 100644 --- a/EduSystemServer/API/middle.py +++ b/EduSystemServer/API/middle.py @@ -16,6 +16,9 @@ class JWTMiddleware: if request.path == '/login': response = self.get_response(request) return response + if request.path.startswith("/admin"): + response = self.get_response(request) + return response # 从请求头中获取 Token token = request.META.get('HTTP_AUTHORIZATION', '') try: diff --git a/EduSystemServer/EduSystemServer/urls.py b/EduSystemServer/EduSystemServer/urls.py index 51e7063..2bf3b5e 100644 --- a/EduSystemServer/EduSystemServer/urls.py +++ b/EduSystemServer/EduSystemServer/urls.py @@ -20,7 +20,7 @@ from API.views import login, get_user_info urlpatterns = [ - path('Eduadmin/', admin.site.urls), + path('admin/', admin.site.urls), path('api/', include(("API.urls", "api"), namespace="api")), path('teacher/', include(("teacher.urls", "teacher"), namespace="teacher")), path('student/', include(("Student.urls", "student"), namespace="student")), diff --git a/EduSystemServer/Student/admin.py b/EduSystemServer/Student/admin.py index 8c38f3f..0b1c9ca 100644 --- a/EduSystemServer/Student/admin.py +++ b/EduSystemServer/Student/admin.py @@ -1,3 +1,14 @@ from django.contrib import admin +from django.core.paginator import Paginator + +from Student.models import Student + # Register your models here. +class StudentAdmin(admin.ModelAdmin): + list_display = ("username", "password", "name", "sex", "grade", "class_name", "major") + list_per_page = 5 + list_filter = ('sex', 'grade', 'class_name', "major") + search_fields = ("name", "sex", "grade", "class_name", "major") + +admin.site.register(Student, StudentAdmin) \ No newline at end of file diff --git a/EduSystemServer/course/admin.py b/EduSystemServer/course/admin.py index 8c38f3f..b84a80a 100644 --- a/EduSystemServer/course/admin.py +++ b/EduSystemServer/course/admin.py @@ -1,3 +1,40 @@ from django.contrib import admin - +from .models import Course, SC # Register your models here. + +admin.site.site_header = '教务系统管理端' +class CourseAdmin(admin.ModelAdmin): + '''设置列表可显示的字段''' + list_display = ('cid', 'name', 'type', 'credit', "tid") + + '''设置过滤选项''' + list_filter = ('name', 'credit', 'type') + + '''每页显示条目数''' + list_per_page = 5 + + '''设置可编辑字段''' + list_editable = ('name', 'type', 'credit', "tid") + + + '''按发布日期排序''' + ordering = ('-credit',) + + +class ScAdmin(admin.ModelAdmin): + list_display = ('student_name', 'course_name', 'middle_grade', 'end_grade') + list_per_page = 5 + def student_name(self, obj): + print(obj) + return obj.sid.name + + def course_name(self, obj): + return obj.cid.name + + list_editable = ('middle_grade', "end_grade") + + ordering = ('-end_grade',) + + +admin.site.register(Course, CourseAdmin) +admin.site.register(SC, ScAdmin) \ No newline at end of file diff --git a/EduSystemServer/course/models.py b/EduSystemServer/course/models.py index fc7381f..fd2466f 100644 --- a/EduSystemServer/course/models.py +++ b/EduSystemServer/course/models.py @@ -33,6 +33,6 @@ class SC(models.Model): class Meta: db_table = "sc" - verbose_name = "管理员" + verbose_name = "选课" verbose_name_plural = verbose_name unique_together = ("sid", "cid") diff --git a/EduSystemServer/teacher/admin.py b/EduSystemServer/teacher/admin.py index 8c38f3f..13d9891 100644 --- a/EduSystemServer/teacher/admin.py +++ b/EduSystemServer/teacher/admin.py @@ -1,3 +1,15 @@ from django.contrib import admin +from teacher.models import Teacher + + # Register your models here. + + +class TeacherAdmin(admin.ModelAdmin): + list_display = ("username", "password", "name", "sex", "title", "education", "dept") + list_per_page = 5 + list_filter = ("sex", "title", "education", "dept") + search_fields = ("name", "sex", "title", "education", "dept") + +admin.site.register(Teacher, TeacherAdmin) \ No newline at end of file