Example #1
0
        from south.signals import pre_migrate, post_migrate
        from ..compat import get_app_package

        def import_flows(app, **kwargs):
            try:
                __import__('{}.flows'.format(get_app_package(app)))
            except ImportError:
                pass

        pre_migrate.connect(import_flows, dispatch_uid="viewflow.management.import_flows")

        from django.conf import settings
        if 'django.contrib.auth' in settings.INSTALLED_APPS:
            def create_permissions_compat(app, **kwargs):
                from django.db.models import get_app
                from django.contrib.auth.management import create_permissions
                create_permissions(get_app(app), (), 0)
            post_migrate.connect(create_permissions_compat)

    except ImportError:
        from django.db.models.signals import pre_syncdb

        def import_flows(sender, **kwargs):
            """Pre-import flows to allow permissions auto-creation."""
            try:
                __import__('{}.flows'.format(sender.__package__))
            except ImportError:
                pass

        pre_syncdb.connect(import_flows, dispatch_uid="viewflow.management.import_flows")
Example #2
0
    pass


if hasattr(models, 'SubfieldBase'):
    CITextField = six.add_metaclass(models.SubfieldBase)(CITextField)
    CICharField = six.add_metaclass(models.SubfieldBase)(CICharField)
    CIEmailField = six.add_metaclass(models.SubfieldBase)(CIEmailField)

if 'south' in settings.INSTALLED_APPS:
    from south.modelsinspector import add_introspection_rules

    add_introspection_rules([], ["^sentry\.db\.models\.fields\.citext\.CITextField"])
    add_introspection_rules([], ["^sentry\.db\.models\.fields\.citext\.CICharField"])
    add_introspection_rules([], ["^sentry\.db\.models\.fields\.citext\.CIEmailField"])


def create_citext_extension(db, **kwargs):
    from sentry.utils.db import is_postgres

    # We always need the citext extension installed for Postgres,
    # and for tests, it's not always guaranteed that we will have
    # run full migrations which installed it.
    if is_postgres(db):
        cursor = connections[db].cursor()
        try:
            cursor.execute('CREATE EXTENSION IF NOT EXISTS citext')
        except Exception:
            pass

pre_syncdb.connect(create_citext_extension)
Example #3
0
    load_sql_files(app_label)


def check_srid_has_meter_unit(sender, **kwargs):
    if not hasattr(check_srid_has_meter_unit, '_checked'):
        cursor = connection.cursor()
        cursor.execute("""
            SELECT * FROM spatial_ref_sys
            WHERE srtext ILIKE '%%meter%%' AND srid=%s;""", [settings.SRID])
        results = cursor.fetchall()
        if len(results) == 0:
            err_msg = 'Unit of SRID EPSG:%s is not meter.' % settings.SRID
            raise ImproperlyConfigured(err_msg)
    check_srid_has_meter_unit._checked = True


if settings.TEST and not settings.SOUTH_TESTS_MIGRATE:
    pre_syncdb.connect(check_srid_has_meter_unit, dispatch_uid="geotrek.core.checksrid")
    post_syncdb.connect(run_initial_sql_post_syncdb, dispatch_uid="geotrek.core.sqlautoload")
    # During tests, the signal is received twice unfortunately
    # https://code.djangoproject.com/ticket/17977
else:
    pre_migrate.connect(check_srid_has_meter_unit, dispatch_uid="geotrek.core.checksrid")
    post_migrate.connect(run_initial_sql_post_migrate, dispatch_uid="geotrek.core.sqlautoload")


"""
    Computed client-side setting.
"""
settings.LEAFLET_CONFIG['SPATIAL_EXTENT'] = api_bbox(settings.SPATIAL_EXTENT, buffer=0.5)
Example #4
0
def check_srid_has_meter_unit(sender, **kwargs):
    if not hasattr(check_srid_has_meter_unit, '_checked'):
        cursor = connection.cursor()
        cursor.execute(
            """
            SELECT * FROM spatial_ref_sys
            WHERE srtext ILIKE '%%meter%%' AND srid=%s;""", [settings.SRID])
        results = cursor.fetchall()
        if len(results) == 0:
            err_msg = 'Unit of SRID EPSG:%s is not meter.' % settings.SRID
            raise ImproperlyConfigured(err_msg)
    check_srid_has_meter_unit._checked = True


if settings.TEST and not settings.SOUTH_TESTS_MIGRATE:
    pre_syncdb.connect(check_srid_has_meter_unit,
                       dispatch_uid="geotrek.core.checksrid")
    post_syncdb.connect(run_initial_sql_post_syncdb,
                        dispatch_uid="geotrek.core.sqlautoload")
    # During tests, the signal is received twice unfortunately
    # https://code.djangoproject.com/ticket/17977
else:
    pre_migrate.connect(check_srid_has_meter_unit,
                        dispatch_uid="geotrek.core.checksrid")
    post_migrate.connect(run_initial_sql_post_migrate,
                         dispatch_uid="geotrek.core.sqlautoload")
"""
    Computed client-side setting.
"""
settings.LEAFLET_CONFIG['SPATIAL_EXTENT'] = api_bbox(
    settings.SPATIAL_EXTENT, buffer=settings.VIEWPORT_MARGIN)
Example #5
0
            try:
                __import__('{}.flows'.format(get_app_package(app)))
            except ImportError:
                pass

        pre_migrate.connect(import_flows,
                            dispatch_uid="viewflow.management.import_flows")

        from django.conf import settings
        if 'django.contrib.auth' in settings.INSTALLED_APPS:

            def create_permissions_compat(app, **kwargs):
                from django.db.models import get_app
                from django.contrib.auth.management import create_permissions
                create_permissions(get_app(app), (), 0)

            post_migrate.connect(create_permissions_compat)

    except ImportError:
        from django.db.models.signals import pre_syncdb

        def import_flows(sender, **kwargs):
            """Pre-import flows to allow permissions auto-creation."""
            try:
                __import__('{}.flows'.format(sender.__package__))
            except ImportError:
                pass

        pre_syncdb.connect(import_flows,
                           dispatch_uid="viewflow.management.import_flows")
Example #6
0
from django.db.models.signals import pre_syncdb
from ..enum import sync_enums


pre_syncdb.connect(sync_enums)
Example #7
0
from stream_django.conf import FEED_MANAGER_CLASS
from stream_django.conf import DJANGO_MAJOR_VERSION
from django.db.models.signals import class_prepared
from stream_django.utils import get_class_from_string

feed_manager_class = get_class_from_string(FEED_MANAGER_CLASS)
feed_manager = feed_manager_class()

class_prepared = class_prepared.connect(feed_manager.bind_model)


def disable_model_tracking(sender, **kwargs):
    feed_manager.disable_model_tracking()


if DJANGO_MAJOR_VERSION == 1.6:
    from django.db.models.signals import pre_syncdb

    pre_syncdb.connect(disable_model_tracking)
elif DJANGO_MAJOR_VERSION > 1.6:
    from django.db.models.signals import pre_migrate

    pre_migrate.connect(disable_model_tracking)
    CITextField = six.add_metaclass(models.SubfieldBase)(CITextField)
    CICharField = six.add_metaclass(models.SubfieldBase)(CICharField)
    CIEmailField = six.add_metaclass(models.SubfieldBase)(CIEmailField)

if 'south' in settings.INSTALLED_APPS:
    from south.modelsinspector import add_introspection_rules

    add_introspection_rules(
        [], ["^sentry\.db\.models\.fields\.citext\.CITextField"])
    add_introspection_rules(
        [], ["^sentry\.db\.models\.fields\.citext\.CICharField"])
    add_introspection_rules(
        [], ["^sentry\.db\.models\.fields\.citext\.CIEmailField"])


def create_citext_extension(db, **kwargs):
    from sentry.utils.db import is_postgres

    # We always need the citext extension installed for Postgres,
    # and for tests, it's not always guaranteed that we will have
    # run full migrations which installed it.
    if is_postgres(db):
        cursor = connections[db].cursor()
        try:
            cursor.execute('CREATE EXTENSION IF NOT EXISTS citext')
        except Exception:
            pass


pre_syncdb.connect(create_citext_extension)
Example #9
0
from django.db.models.signals import pre_syncdb
from ..enum import sync_enums

pre_syncdb.connect(sync_enums)
Example #10
0
def connect():
    pre_syncdb.connect(db_processor.disable_changes_signal_processor)
    post_syncdb.connect(db_processor.enable_changes_signal_processor)
    post_save.connect(db_processor.my_callback_save)
    post_delete.connect(db_processor.my_callback_delete)
Example #11
0
from stream_django.conf import FEED_MANAGER_CLASS
from stream_django.conf import DJANGO_MAJOR_VERSION
from django.db.models.signals import class_prepared
from stream_django.utils import get_class_from_string


feed_manager_class = get_class_from_string(FEED_MANAGER_CLASS)
feed_manager = feed_manager_class()

class_prepared = class_prepared.connect(feed_manager.bind_model)


def disable_model_tracking(sender, **kwargs):
    feed_manager.disable_model_tracking()


if DJANGO_MAJOR_VERSION == 1.6:
    from django.db.models.signals import pre_syncdb
    pre_syncdb.connect(disable_model_tracking)
elif DJANGO_MAJOR_VERSION > 1.6:
    from django.db.models.signals import pre_migrate
    pre_migrate.connect(disable_model_tracking)