openbackloggery/collection/games/apps.py
Olivier DOSSMANN 242b0edff0 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
2017-08-22 21:02:43 +02:00

29 lines
742 B
Python

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)