# -*- coding: utf-8 -*-

from django.apps import AppConfig
from django.conf import settings
from django.db.models.signals import m2m_changed, post_migrate, post_save, pre_delete

from neomodel import config

config.AUTO_INSTALL_LABELS = False


class ChemTrailsConfig(AppConfig):
    name = 'chemtrails'

    def ready(self):
        from .signals.handlers import (
            m2m_changed_handler, post_migrate_handler,
            post_save_handler, pre_delete_handler
        )

        m2m_changed.connect(receiver=m2m_changed_handler,
                            dispatch_uid='chemtrails.signals.handlers.m2m_changed_handler')
        post_save.connect(receiver=post_save_handler,
                          dispatch_uid='chemtrails.signals.handlers.post_save_handler')
        pre_delete.connect(receiver=pre_delete_handler,
                           dispatch_uid='chemtrails.signals.handlers.pre_delete_handler')

        post_migrate.connect(receiver=post_migrate_handler,
                             dispatch_uid='neomodel.core.install_all_labels')

        # Neo4j config
        config.DATABASE_URL = getattr(settings, 'NEOMODEL_NEO4J_BOLT_URL', config.DATABASE_URL)
        config.FORCE_TIMEZONE = getattr(settings, 'NEOMODEL_FORCE_TIMEZONE', False)

@@ -18,16 +18,27 @@
 -8 -*-%0A%0A
+import os%0A%0A
 from dja
@@ -1161,16 +1161,96 @@
 LT_URL',
+%0A                                      os.environ.get('NEOMODEL_NEO4J_BOLT_URL',
  config.
@@ -1262,16 +1262,17 @@
 ASE_URL)
+)
 %0A       
@@ -1344,12 +1344,95 @@
 NE',
+%0A                                        os.environ.get('NEOMODEL_FORCE_TIMEZONE',
  False)
+)
 %0A

Read Neo4j config from ENV if present