Sith/pedagogy/admin.py

56 lines
1.7 KiB
Python
Raw Normal View History

2023-04-06 11:08:42 +00:00
# -*- coding:utf-8 -*-
2019-05-16 14:51:30 +00:00
#
2023-04-06 11:08:42 +00:00
# Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr
# All contributors are listed in the CONTRIBUTORS file.
2019-05-16 14:51:30 +00:00
#
2023-04-06 11:08:42 +00:00
# This file is part of the website of the UTBM Student Association (AE UTBM),
# https://ae.utbm.fr.
2019-05-16 14:51:30 +00:00
#
2023-04-06 11:08:42 +00:00
# You can find the whole source code at https://github.com/ae-utbm/sith3
2019-05-16 14:51:30 +00:00
#
2023-04-06 11:08:42 +00:00
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
# OR WITHIN THE LOCAL FILE "LICENSE"
2019-05-16 14:51:30 +00:00
#
2023-04-06 11:08:42 +00:00
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
# OR WITHIN THE LOCAL FILE "LICENSE.old"
2019-05-16 14:51:30 +00:00
#
2022-12-19 19:55:33 +00:00
from ajax_select import make_ajax_form
2019-05-16 14:51:30 +00:00
from django.contrib import admin
2022-12-19 19:55:33 +00:00
from haystack.admin import SearchModelAdmin
from pedagogy.models import UV, UVComment, UVCommentReport
@admin.register(UV)
class UVAdmin(admin.ModelAdmin):
list_display = ("code", "title", "credit_type", "credits", "department")
search_fields = ("code", "title", "department")
form = make_ajax_form(UV, {"author": "users"})
@admin.register(UVComment)
class UVCommentAdmin(admin.ModelAdmin):
list_display = ("author", "uv", "grade_global", "publish_date")
search_fields = (
"author__username",
"author__first_name",
"author__last_name",
"uv__code",
)
form = make_ajax_form(UVComment, {"author": "users"})
2019-05-16 14:51:30 +00:00
2022-12-19 19:55:33 +00:00
@admin.register(UVCommentReport)
class UVCommentReportAdmin(SearchModelAdmin):
list_display = ("reporter", "uv")
search_fields = (
"reporter__username",
"reporter__first_name",
"reporter__last_name",
"comment__uv__code",
)
form = make_ajax_form(UVCommentReport, {"reporter": "users"})