telegram_bots/aggregator/apps.py

24 lines
681 B
Python
Raw Normal View History

2019-01-27 21:20:09 +00:00
from django.apps import AppConfig
2019-01-30 20:52:05 +00:00
from django.db.models.signals import post_delete
2019-01-27 21:20:09 +00:00
class AggregatorConfig(AppConfig):
name = 'aggregator'
def ready(self):
self.register_config()
2019-01-30 20:52:05 +00:00
self.register_signals()
2019-01-27 21:20:09 +00:00
def register_config(self):
import djconfig
from .forms import AggregatorAppConfigForm
djconfig.register(AggregatorAppConfigForm)
2019-01-30 20:52:05 +00:00
def register_signals(self):
from .models import AggregationSource, Chat
from .signals import aggregation_source_deleted, chat_deleted
post_delete.connect(aggregation_source_deleted, sender=AggregationSource)
post_delete.connect(chat_deleted, sender=Chat)