diff options
Diffstat (limited to 'admin.py')
-rw-r--r-- | admin.py | 36 |
1 files changed, 23 insertions, 13 deletions
@@ -1,4 +1,4 @@ -# Copyright (C) 2017 Alban Gruin +# Copyright (C) 2017-2018 Alban Gruin # # celcatsanitizer is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published @@ -14,14 +14,18 @@ # along with celcatsanitizer. If not, see <http://www.gnu.org/licenses/>. from django.contrib import admin -from .models import Timetable, Group, Room, Course, Year +from .models import Course, Group, Room, Source, Timetable, Year + def make_hidden(modeladmin, request, queryset): queryset.update(hidden=True) -make_hidden.short_description = "Cacher les groupes sélectionnés" + def make_visible(modeladmin, request, queryset): queryset.update(hidden=False) + + +make_hidden.short_description = "Cacher les groupes sélectionnés" make_visible.short_description = "Afficher les groupes sélectionnés" @@ -32,10 +36,15 @@ class YearAdmin(admin.ModelAdmin): ordering = ("name",) +@admin.register(Source) +class SourceAdmin(admin.ModelAdmin): + list_display = ("url", "last_update_date",) + + @admin.register(Timetable) class TimetableAdmin(admin.ModelAdmin): prepopulated_fields = {"slug": ("name",)} - list_display = ("name", "year", "url",) + list_display = ("name", "year", "source",) list_filter = ("year__name",) ordering = ("year", "name",) @@ -43,27 +52,28 @@ class TimetableAdmin(admin.ModelAdmin): @admin.register(Group) class GroupAdmin(admin.ModelAdmin): fieldsets = ( - (None, {"fields": ("name", "celcat_name", "timetable", "hidden",)}), + (None, {"fields": ("name", "celcat_name", "source", "hidden",)}), ("Groupes", {"fields": ("mention", "semester", "subgroup",)}),) - list_display = ("name", "timetable", "hidden",) + list_display = ("name", "source", "hidden",) list_editable = ("hidden",) - list_filter = ("timetable",) - ordering = ("timetable",) - readonly_fields = ("celcat_name", "mention",) + list_filter = ("source__timetables",) + ordering = ("source", "name",) + readonly_fields = ("celcat_name", "mention", "semester", "subgroup",) actions = (make_hidden, make_visible,) @admin.register(Room) class RoomAdmin(admin.ModelAdmin): - pass + prepopulated_fields = {"slug": ("name",)} @admin.register(Course) class CourseAdmin(admin.ModelAdmin): fieldsets = ( - (None, {"fields": ("name", "type", "timetable", "groups", "rooms", "last_update",)}), + (None, {"fields": ("name", "type", "source", "groups", "rooms", + "last_update",)}), ("Horaires", {"fields": ("begin", "end",)}), ("Remarques", {"fields": ("notes",)}),) - list_display = ("name", "type", "timetable", "begin", "end",) - list_filter = ("type", "timetable", "groups",) + list_display = ("name", "type", "source", "begin", "end",) + list_filter = ("type", "source__timetables", "groups",) ordering = ("begin",) |