91 lines
2.2 KiB
Python
91 lines
2.2 KiB
Python
from django.contrib import admin
|
|
from django.utils.translation import gettext_lazy as _
|
|
from colloscope.models import *
|
|
|
|
|
|
@admin.register(School)
|
|
class LyceeAdmin(admin.ModelAdmin):
|
|
list_display = ('uai', 'description', 'vacation')
|
|
|
|
|
|
admin.site.register(Class)
|
|
admin.site.register(Term)
|
|
admin.site.register(Subject)
|
|
admin.site.register(GroupType)
|
|
admin.site.register(Group)
|
|
|
|
|
|
@admin.register(Student)
|
|
class StudentAdmin(admin.ModelAdmin):
|
|
list_display = ("cls", "first_name", "last_name")
|
|
list_filter = ("cls",)
|
|
|
|
|
|
admin.site.register(Member)
|
|
admin.site.register(Colleur)
|
|
|
|
|
|
class ColleInline(admin.StackedInline):
|
|
model = Colle
|
|
raw_id_fields = ("slot",)
|
|
|
|
|
|
@admin.register(Slot)
|
|
class SlotAdmin(admin.ModelAdmin):
|
|
list_display = ('subject', 'colleur', "term", 'get_day', "time", "duration")
|
|
list_filter = ("subject", "colleur", "term")
|
|
inlines = [ColleInline]
|
|
|
|
def get_day(self, obj):
|
|
jours = ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]
|
|
return jours[obj.day]
|
|
|
|
get_day.short_description = _('Day')
|
|
|
|
|
|
class SwapInline(admin.StackedInline):
|
|
model = Swap
|
|
raw_id_fields = ("colle",)
|
|
|
|
|
|
@admin.register(Colle)
|
|
class ColleAdmin(admin.ModelAdmin):
|
|
list_display = ('get_subject', 'get_colleur', 'get_room', 'datetime',)
|
|
list_filter = ('slot',)
|
|
inlines = [SwapInline]
|
|
|
|
def get_subject(self, obj):
|
|
return obj.slot.subject
|
|
|
|
def get_colleur(self, obj):
|
|
return obj.slot.colleur
|
|
|
|
def get_room(self, obj):
|
|
return obj.slot.room
|
|
|
|
get_subject.short_description = _('Subject')
|
|
get_colleur.short_description = _('Colleur')
|
|
get_room.short_description = _('Room')
|
|
|
|
|
|
@admin.register(Swap)
|
|
class SwapAdmin(admin.ModelAdmin):
|
|
list_display = ('get_subject', 'get_colleur', 'get_datetime', 'enroll', 'student')
|
|
list_filter = ('enroll', 'student')
|
|
|
|
def get_subject(self, obj):
|
|
return obj.colle.slot.subject
|
|
get_subject.short_description = _('Subject')
|
|
|
|
def get_colleur(self, obj):
|
|
return obj.colle.slot.colleur
|
|
get_subject.short_description = _('Colleur')
|
|
|
|
def get_datetime(self, obj):
|
|
return obj.colle.datetime
|
|
get_subject.short_description = _('Heure')
|
|
|
|
|
|
admin.site.register(Profile)
|
|
admin.site.register(CalendarLink)
|