from django.apps import AppConfig
from django.db.models.signals import post_delete


class AggregatorConfig(AppConfig):
    name = 'aggregator'

    def ready(self):
        self.register_config()
        self.register_signals()

    def register_config(self):
        import djconfig
        from .forms import AggregatorAppConfigForm

        djconfig.register(AggregatorAppConfigForm)

    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)
