2019-08-02 12:57:53 +00:00
|
|
|
# -*- mode: python; coding: utf-8 -*-
|
|
|
|
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2019-08-02 12:57:53 +00:00
|
|
|
from reversion.admin import VersionAdmin
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2019-08-10 06:04:46 +00:00
|
|
|
from med.admin import admin_site
|
2019-08-09 21:22:20 +00:00
|
|
|
from .models import Auteur, Emprunt, Jeu, Media
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2019-08-02 12:57:53 +00:00
|
|
|
|
2017-06-30 01:25:07 +00:00
|
|
|
class AuteurAdmin(VersionAdmin):
|
|
|
|
list_display = ('nom',)
|
2019-08-10 08:44:17 +00:00
|
|
|
search_fields = ('nom',)
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2019-08-02 12:57:53 +00:00
|
|
|
|
2017-06-30 01:25:07 +00:00
|
|
|
class MediaAdmin(VersionAdmin):
|
2019-08-08 19:08:24 +00:00
|
|
|
list_display = ('titre', 'authors', 'cote')
|
2019-08-10 08:44:17 +00:00
|
|
|
search_fields = ('titre', 'authors', 'cote')
|
2019-08-10 09:42:27 +00:00
|
|
|
autocomplete_fields = ('auteur',)
|
2019-08-08 19:08:24 +00:00
|
|
|
|
|
|
|
def authors(self, obj):
|
|
|
|
return ", ".join([a.nom for a in obj.auteur.all()])
|
2019-08-02 12:57:53 +00:00
|
|
|
|
2017-06-30 01:25:07 +00:00
|
|
|
|
|
|
|
class EmpruntAdmin(VersionAdmin):
|
2019-08-08 19:08:24 +00:00
|
|
|
list_display = ('media', 'user', 'date_emprunt', 'date_rendu',
|
|
|
|
'permanencier_emprunt', 'permanencier_rendu')
|
2019-08-10 08:44:17 +00:00
|
|
|
search_fields = ('media', 'user', 'date_emprunt', 'date_rendu')
|
|
|
|
date_hierarchy = 'date_emprunt'
|
2019-08-10 09:42:27 +00:00
|
|
|
autocomplete_fields = ('media', 'user', 'permanencier_emprunt',
|
|
|
|
'permanencier_rendu')
|
2019-08-02 12:57:53 +00:00
|
|
|
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2017-07-03 16:33:24 +00:00
|
|
|
class JeuAdmin(VersionAdmin):
|
2019-08-08 19:08:24 +00:00
|
|
|
list_display = ('nom', 'proprietaire', 'duree', 'nombre_joueurs_min',
|
|
|
|
'nombre_joueurs_max', 'comment')
|
2019-08-10 08:44:17 +00:00
|
|
|
search_fields = ('nom', 'proprietaire', 'duree', 'comment')
|
2019-08-10 09:42:27 +00:00
|
|
|
autocomplete_fields = ('proprietaire',)
|
2019-08-02 12:57:53 +00:00
|
|
|
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2019-08-10 06:04:46 +00:00
|
|
|
admin_site.register(Auteur, AuteurAdmin)
|
|
|
|
admin_site.register(Media, MediaAdmin)
|
|
|
|
admin_site.register(Emprunt, EmpruntAdmin)
|
|
|
|
admin_site.register(Jeu, JeuAdmin)
|