aboutsummaryrefslogtreecommitdiff
path: root/admin.py
diff options
context:
space:
mode:
authorAlban Gruin2018-04-23 16:20:38 +0200
committerAlban Gruin2018-04-23 16:20:38 +0200
commit63ceb7ff232cd4015ae148bec31c6d72d9239c19 (patch)
tree9aee056480b5fae0c97f5e1c8be4ab1358602926 /admin.py
parentaf055dbf703af0eca03862194de1a0f34ac1fcc5 (diff)
parent9853d375d9e482c23f5fdbed9a3cf041029a92cb (diff)
Merge branch 'qsjps' into futur
Diffstat (limited to 'admin.py')
-rw-r--r--admin.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/admin.py b/admin.py
index 7739a95..def84f0 100644
--- a/admin.py
+++ b/admin.py
@@ -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",)
+ 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",)