add javascript file

master
bettleChen 1 year ago
parent b0f0292c62
commit 41e76a2742

@ -1,5 +1,5 @@
from functools import wraps from functools import wraps
from django.http import HttpResponseForbidden, JsonResponse from django.http import JsonResponse
def permission(allowed_roles): def permission(allowed_roles):

@ -1,8 +1,11 @@
from django.contrib import admin from django.contrib import admin
from .models import Course, SC from .models import Course, SC
# Register your models here. # Register your models here.
admin.site.site_header = '教务系统管理端' admin.site.site_header = '教务系统管理端'
class CourseAdmin(admin.ModelAdmin): class CourseAdmin(admin.ModelAdmin):
'''设置列表可显示的字段''' '''设置列表可显示的字段'''
list_display = ('cid', 'name', 'type', 'credit', "tid") list_display = ('cid', 'name', 'type', 'credit', "tid")
@ -16,15 +19,16 @@ class CourseAdmin(admin.ModelAdmin):
'''设置可编辑字段''' '''设置可编辑字段'''
list_editable = ('name', 'type', 'credit', "tid") list_editable = ('name', 'type', 'credit', "tid")
'''按发布日期排序''' '''按发布日期排序'''
ordering = ('-credit',) ordering = ('-credit',)
search_fields = ('name', 'type', 'credit', "tid") search_fields = ('name', 'type', 'credit', "tid")
class ScAdmin(admin.ModelAdmin): class ScAdmin(admin.ModelAdmin):
list_display = ('student_name', 'course_name', 'middle_grade', 'end_grade') list_display = ('student_name', 'course_name', 'middle_grade', 'end_grade')
list_per_page = 5 list_per_page = 5
def student_name(self, obj): def student_name(self, obj):
print(obj) print(obj)
return obj.sid.name return obj.sid.name
@ -38,4 +42,4 @@ class ScAdmin(admin.ModelAdmin):
admin.site.register(Course, CourseAdmin) admin.site.register(Course, CourseAdmin)
admin.site.register(SC, ScAdmin) admin.site.register(SC, ScAdmin)

@ -44,6 +44,7 @@ def search_course(request):
result["pageNum"] = paginator.num_pages result["pageNum"] = paginator.num_pages
return JsonResponse(result) return JsonResponse(result)
@permission(allowed_roles=["student"]) @permission(allowed_roles=["student"])
def get_course_by_student_id(request): def get_course_by_student_id(request):
""" """
@ -61,6 +62,7 @@ def get_course_by_student_id(request):
result = ResponseUtil.ok(data) result = ResponseUtil.ok(data)
return JsonResponse(result) return JsonResponse(result)
@permission(allowed_roles=["student"]) @permission(allowed_roles=["student"])
def delete_select_course(request): def delete_select_course(request):
""" """
@ -77,6 +79,7 @@ def delete_select_course(request):
except Exception as E: except Exception as E:
return JsonResponse(ResponseUtil.error(E)) return JsonResponse(ResponseUtil.error(E))
@csrf_exempt @csrf_exempt
@permission(allowed_roles=["teacher", "admin"]) @permission(allowed_roles=["teacher", "admin"])
def get_student_select_course(request): def get_student_select_course(request):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

@ -12,4 +12,5 @@ class TeacherAdmin(admin.ModelAdmin):
list_filter = ("sex", "title", "education", "dept") list_filter = ("sex", "title", "education", "dept")
search_fields = ("name", "sex", "title", "education", "dept") search_fields = ("name", "sex", "title", "education", "dept")
admin.site.register(Teacher, TeacherAdmin) admin.site.register(Teacher, TeacherAdmin)
Loading…
Cancel
Save