aboutsummaryrefslogtreecommitdiff
path: root/admin.py
blob: d49c1233f01b8a4c5d0d457c8bfac2531e7d299c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from django.contrib import admin
from edt.models import Timetable, LastUpdate, Group, Room, Course


@admin.register(Timetable)
class TimetableAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("name",)}
    list_display = ("name", "url",)


@admin.register(LastUpdate)
class LastUpdateAdmin(admin.ModelAdmin):
    list_display = ("timetable", "week", "year", "date",)
    list_filter = ("timetable__name",)


@admin.register(Group)
class GroupAdmin(admin.ModelAdmin):
    fieldsets = (
        (None, {"fields": ("name", "timetable",)}),
        ("Groupes", {"fields": ("mention", "subgroup", "td", "tp",)}),)
    list_display = ("name", "timetable",)
    list_filter = ("timetable__name",)
    readonly_fields = ("mention", "subgroup", "td", "tp",)


@admin.register(Room)
class RoomAdmin(admin.ModelAdmin):
    pass


@admin.register(Course)
class CourseAdmin(admin.ModelAdmin):
    fieldsets = (
        (None, {"fields": ("name", "type", "timetable", "groups", "rooms",)}),
        ("Horaires", {"fields": ("begin", "end",)}),
        ("Remarques", {"fields": ("notes",)}),)
    list_display = ("name", "type", "timetable", "begin", "end",)
    list_filter = ("type", "timetable__name", "groups",)
    ordering = ("begin",)