Example #1
0
    def test_populate_table_with_defaults_and_dictize(self):
        # Register NGDS configs with pylons global config
        app_globals.mappings['ngds.publish'] = 'ngds.publish'
        app_globals.mappings['ngds.harvest'] = 'ngds.harvest'
        app_globals.mappings['ngds.edit_metadata'] = 'ngds.edit_metadata'

        # Make dictionary of configs with default values to initialize the
        # 'ngds_system_info' table
        data = {
            'ngds.publish': config.get('ngds.publish', 'True'),
            'ngds.harvest': config.get('ngds.harvest', 'True'),
            'ngds.edit_metadata': config.get('ngds.edit_metadata', 'True'),
        }

        # Populate that sucka
        db.init_table_populate(model, data)

        # Hocus pocus magic to make sure that the 'ngds_system_info' table was
        # populated with the correct values
        db_config = {}
        table = db.SysadminConfig.get(active_config=True)
        mapped_table = orm.class_mapper(table.__class__).mapped_table
        for key in mapped_table.c.keys():
            db_config[key] = getattr(table, key)

        assert db_config.get('ngds.publish') == 'True'
        assert db_config.get('ngds.harvest') == 'True'
        assert db_config.get('ngds.edit_metadata') == 'True'
Example #2
0
    def test_populate_table_with_defaults_and_dictize(self):
        # Register NGDS configs with pylons global config
        app_globals.mappings['ngds.publish'] = 'ngds.publish'
        app_globals.mappings['ngds.harvest'] = 'ngds.harvest'
        app_globals.mappings['ngds.edit_metadata'] = 'ngds.edit_metadata'

        # Make dictionary of configs with default values to initialize the
        # 'ngds_system_info' table
        data = {
            'ngds.publish': config.get('ngds.publish', 'True'),
            'ngds.harvest': config.get('ngds.harvest', 'True'),
            'ngds.edit_metadata': config.get('ngds.edit_metadata', 'True'),
        }

        # Populate that sucka
        db.init_table_populate(model, data)

        # Hocus pocus magic to make sure that the 'ngds_system_info' table was
        # populated with the correct values
        db_config = {}
        table = db.SysadminConfig.get(active_config=True)
        mapped_table = orm.class_mapper(table.__class__).mapped_table
        for key in mapped_table.c.keys():
            db_config[key] = getattr(table, key)

        assert db_config.get('ngds.publish') == 'True'
        assert db_config.get('ngds.harvest') == 'True'
        assert db_config.get('ngds.edit_metadata') == 'True'
Example #3
0
    def update_config(self, config):
        """
        Use this function to hook into the pylons global config object before
        the server starts up.  The call to read configurations from the
        'ngds_system_info' table happens after they are read from the vanilla
        CKAN 'system_info' table, therefore ensuring that custom configurations
        get used over vanilla ones.

        @config: Pylons global config object
        """

        # Register ngds admin configurations with pylons
        app_globals.mappings['ngds.publish'] = 'ngds.publish'
        app_globals.mappings['ngds.harvest'] = 'ngds.harvest'
        app_globals.mappings['ngds.edit_metadata'] = 'ngds.edit_metadata'
        app_globals.mappings['ngds.featured_data'] = 'ngds.featured_data'

        # Collect config data to populate 'ngds_system_info' table if this is
        # the first time this server is booting up with the 'sysadmin' plugin.
        # Initially, this table will be populated with either what it finds in
        # the config file or default values.
        data = {
            'ngds.publish': config.get('ngds.publish', 'True'),
            'ngds.harvest': config.get('ngds.harvest', 'True'),
            'ngds.edit_metadata': config.get('ngds.edit_metadata', 'True'),
            'ngds.featured_data': config.get('ngds.featured_data', None)
        }

        # If this is the first time booting up the server with the 'sysadmin'
        # plugin, then build the 'ngds_system_info' table, populate it with the
        # default values and build ORM.  Otherwise, just build the ORM.
        db.init_table_populate(model, data)

        # Always read the 'ngds_system_info' table upon starting the server
        db_config = db.init_config_show(model)

        # Update pylons global config object with the configs we just read from
        # the 'ngds_system_info' table.
        config.update(db_config)

        # Add custom templates directory
        p.toolkit.add_template_directory(config, 'templates')

        # Add public assets directory
        p.toolkit.add_public_directory(config, 'public')

        # Register fanstatic directory for JavaScript files
        p.toolkit.add_resource('fanstatic', 'sysadmin')
Example #4
0
    def update_config(self, config):
        """
        Use this function to hook into the pylons global config object before
        the server starts up.  The call to read configurations from the
        'ngds_system_info' table happens after they are read from the vanilla
        CKAN 'system_info' table, therefore ensuring that custom configurations
        get used over vanilla ones.

        @config: Pylons global config object
        """

        # Register ngds admin configurations with pylons
        app_globals.mappings['ngds.publish'] = 'ngds.publish'
        app_globals.mappings['ngds.harvest'] = 'ngds.harvest'
        app_globals.mappings['ngds.edit_metadata'] = 'ngds.edit_metadata'
        app_globals.mappings['ngds.featured_data'] = 'ngds.featured_data'

        # Collect config data to populate 'ngds_system_info' table if this is
        # the first time this server is booting up with the 'sysadmin' plugin.
        # Initially, this table will be populated with either what it finds in
        # the config file or default values.
        data = {
            'ngds.publish': config.get('ngds.publish', 'True'),
            'ngds.harvest': config.get('ngds.harvest', 'True'),
            'ngds.edit_metadata': config.get('ngds.edit_metadata', 'True'),
            'ngds.featured_data': config.get('ngds.featured_data', None)
        }

        # If this is the first time booting up the server with the 'sysadmin'
        # plugin, then build the 'ngds_system_info' table, populate it with the
        # default values and build ORM.  Otherwise, just build the ORM.
        db.init_table_populate(model, data)

        # Always read the 'ngds_system_info' table upon starting the server
        db_config = db.init_config_show(model)

        # Update pylons global config object with the configs we just read from
        # the 'ngds_system_info' table.
        config.update(db_config)

        # Add custom templates directory
        p.toolkit.add_template_directory(config, 'templates')

        # Add public assets directory
        p.toolkit.add_public_directory(config, 'public')

        # Register fanstatic directory for JavaScript files
        p.toolkit.add_resource('fanstatic', 'sysadmin')