Exemplo n.º 1
0
    def execute(self, *args, **options):
        logger.info("Synchronize django permissions")

        for app in get_apps():
            create_permissions(app, [], int(options.get('verbosity', 1)))

        logger.info("Done.")

        logger.info("Synchronize mapentity permissions")

        # Make sure apps are registered at this point
        import_module(settings.ROOT_URLCONF)

        # For all models registered, add missing bits
        for model in registry.registry.keys():
            create_mapentity_model_permissions(model)

        logger.info("Done.")

        logger.info("Synchronize geotrek permissions")

        for content_type in ContentType.objects.all():
            model = content_type.model_class()
            if model and issubclass(model, BasePublishableMixin):
                Permission.objects.get_or_create(
                    codename='publish_%s' % content_type.model,
                    name='Can publish %s' % content_type.name,
                    content_type=content_type)

        logger.info("Done.")
Exemplo n.º 2
0
    def execute(self, *args, **options):
        logger.info("Synchronize django permissions")

        for app in get_apps():
            create_permissions(app, [], int(options.get('verbosity', 1)))

        logger.info("Done.")

        logger.info("Synchronize mapentity permissions")

        # Make sure apps are registered at this point
        import_module(settings.ROOT_URLCONF)

        # For all models registered, add missing bits
        for model in registry.registry.keys():
            create_mapentity_model_permissions(model)

        logger.info("Done.")

        logger.info("Synchronize geotrek permissions")

        for content_type in ContentType.objects.all():
            model = content_type.model_class()
            if model and issubclass(model, BasePublishableMixin):
                Permission.objects.get_or_create(
                    codename='publish_%s' % content_type.model,
                    name='Can publish %s' % content_type.name,
                    content_type=content_type)

        logger.info("Done.")
    def execute(self, *args, **options):
        logger.info("Synchronize django permissions")

        for app_config in apps.get_app_configs():
            create_permissions(app_config, [], int(options.get('verbosity',
                                                               1)))

        logger.info("Done.")

        logger.info("Synchronize mapentity permissions")

        # Make sure apps are registered at this point
        import_module(settings.ROOT_URLCONF)

        # Tests reset DB so we have to reset this cache too
        clear_internal_user_cache()

        # For all models registered, add missing bits
        for model in registry.registry.keys():
            create_mapentity_model_permissions(model)

        logger.info("Done.")

        logger.info("Synchronize geotrek permissions")

        for content_type in ContentType.objects.all():
            model = content_type.model_class()
            if model and issubclass(model, BasePublishableMixin):
                Permission.objects.get_or_create(
                    codename='publish_%s' % content_type.model,
                    content_type=content_type,
                    defaults={'name': 'Can publish %s' % content_type.name})

        logger.info("Done.")
    def execute(self, *args, **options):
        logger.info("Synchronize django permissions")

        for app_config in apps.get_app_configs():
            create_permissions(app_config, verbosity=options['verbosity'])

        logger.info("Done.")

        logger.info("Synchronize mapentity permissions")

        # Make sure apps are registered at this point
        import_module(settings.ROOT_URLCONF)

        # Tests reset DB so we have to reset this cache too
        clear_internal_user_cache()

        # For all models registered, add missing bits
        for model in registry.registry.keys():
            if not model._meta.abstract:
                create_mapentity_model_permissions(model)

        logger.info("Done.")

        logger.info("Synchronize geotrek permissions")

        for content_type in ContentType.objects.all():
            model = content_type.model_class()
            if model and issubclass(model, BasePublishableMixin) and not model._meta.abstract:
                Permission.objects.get_or_create(
                    codename='publish_%s' % content_type.model,
                    content_type=content_type,
                    defaults={'name': 'Can publish %s' % content_type.name}
                )

        logger.info("Done.")
    def execute(self, *args, **options):
        logger.info("Synchronize permissions of MapEntity models")

        # Make sure apps are registered at this point
        import_module(settings.ROOT_URLCONF)

        # For all models registered, add missing bits
        for model in registry.registry.keys():
            create_mapentity_model_permissions(model)

        logger.info("Done.")
    def execute(self, *args, **options):
        logger.info("Synchronize permissions of MapEntity models")

        # Make sure apps are registered at this point
        import_module(settings.ROOT_URLCONF)

        # For all models registered, add missing bits
        for model in registry.registry.keys():
            create_mapentity_model_permissions(model)

        logger.info("Done.")
Exemplo n.º 7
0
def create_mapentity_models_permissions(app, **kwargs):
    """ Create `Permission` objects for each model registered
    in MapEntity.
    """

    logger.info("Synchronize permissions of MapEntity models")

    # During tests, the database is flushed so we need to flush caches in order
    # to correctly recreate all permissions
    clear_internal_user_cache()
    ContentType.objects.clear_cache()

    for model in get_models(app):
        create_mapentity_model_permissions(model)
Exemplo n.º 8
0
def create_mapentity_models_permissions(app, **kwargs):
    """ Create `Permission` objects for each model registered
    in MapEntity.
    """

    logger.info("Synchronize permissions of MapEntity models")

    # During tests, the database is flushed so we need to flush caches in order
    # to correctly recreate all permissions
    clear_internal_user_cache()
    ContentType.objects.clear_cache()

    for model in get_models(app):
        create_mapentity_model_permissions(model)