Refonte de la base:
* utilisation de classes abstraites Django : Item et Collection * héritage de ces classes pour Game et Console * création d'un objet Timeline contenant le changement d'état des jeux * affichage de la Timeline sur l'interface Admin
This commit is contained in:
@ -1,5 +1,28 @@
|
||||
from django.apps import AppConfig
|
||||
from django.db.models import signals
|
||||
|
||||
|
||||
def call_on_class_prepared(sender, **kwargs):
|
||||
"""
|
||||
Calls the function only if it is defined in the class being prepared
|
||||
"""
|
||||
try:
|
||||
sender.on_class_prepared()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
class GamesConfig(AppConfig):
|
||||
name = 'games'
|
||||
|
||||
def ready(self):
|
||||
"""
|
||||
Add signals to the application
|
||||
"""
|
||||
from .models import Game
|
||||
from .signals import game_saved
|
||||
signals.post_save.connect(game_saved, sender='games.Game')
|
||||
|
||||
def __init__(self, app_name, app_module):
|
||||
super(GamesConfig, self).__init__(app_name, app_module)
|
||||
signals.class_prepared.connect(call_on_class_prepared)
|
||||
|
Reference in New Issue
Block a user