def getConfig(self):
        """get the config"""
        registry = getUtility(IRegistry)
        # First grab the base config, so we can use the operations
        registryreader = IQuerystringRegistryReader(registry)
        registryreader.prefix = "plone.app.querystring.operation"
        op_config = registryreader.parseRegistry()
        # Then combine our fields
        registryreader = IQuerystringRegistryReader(registry)
        registryreader.prefix = "bika.lims.analysisrequestquery"
        config = registryreader.parseRegistry()
        config = registryreader.getVocabularyValues(config)
        config.update(op_config)
        registryreader.mapOperations(config)
        registryreader.mapSortableIndexes(config)
        config = {
            "indexes": config.get("bika.lims.analysisrequestquery.field"),
            "sortable_indexes": config.get("sortable"),
        }

        # Group indices by "group", order alphabetically
        groupedIndexes = {}
        for indexName in config["indexes"]:
            index = config["indexes"][indexName]
            if index["enabled"]:
                group = index["group"]
                if group not in groupedIndexes:
                    groupedIndexes[group] = []
                groupedIndexes[group].append((index["title"], indexName))

        # Sort each index list
        [a.sort() for a in groupedIndexes.values()]

        config["groupedIndexes"] = groupedIndexes
        return config
Esempio n. 2
0
    def getConfig(self):
        """get the config"""
        registry = getUtility(IRegistry)
        # First grab the base config, so we can use the operations
        registryreader = IQuerystringRegistryReader(registry)
        registryreader.prefix = "plone.app.querystring.operation"
        op_config = registryreader.parseRegistry()
        # Then combine our fields
        registryreader = IQuerystringRegistryReader(registry)
        registryreader.prefix = "bika.lims.analysisrequestquery"
        config = registryreader.parseRegistry()
        config = registryreader.getVocabularyValues(config)
        config.update(op_config)
        registryreader.mapOperations(config)
        registryreader.mapSortableIndexes(config)
        config = {
            'indexes': config.get('bika.lims.analysisrequestquery.field'),
            'sortable_indexes': config.get('sortable'),
        }

        # Group indices by "group", order alphabetically
        groupedIndexes = {}
        for indexName in config['indexes']:
            index = config['indexes'][indexName]
            if index['enabled']:
                group = index['group']
                if group not in groupedIndexes:
                    groupedIndexes[group] = []
                groupedIndexes[group].append((index['title'], indexName))

        # Sort each index list
        [a.sort() for a in groupedIndexes.values()]

        config['groupedIndexes'] = groupedIndexes
        return config
Esempio n. 3
0
 def __call__(self):
     """Return the registry configuration in JSON format"""
     registry = getUtility(IRegistry)
     # First grab the base config, so we can use the operations
     registryreader = IQuerystringRegistryReader(registry)
     registryreader.prefix = "plone.app.querystring.operation"
     op_config = registryreader.parseRegistry()
     # Then combine our fields
     registryreader = IQuerystringRegistryReader(registry)
     registryreader.prefix = self.prefix
     config = registryreader.parseRegistry()
     config = registryreader.getVocabularyValues(config)
     config.update(op_config)
     registryreader.mapOperations(config)
     registryreader.mapSortableIndexes(config)
     config = {"indexes": config.get(self.prefix + ".field"), "sortable_indexes": config.get("sortable")}
     return json.dumps(config)
 def test_map_operations_missing(self):
     """tests if nonexisting referenced operations are properly skipped"""
     registry = self.createRegistry(td.test_missing_operator_xml)
     reader = IQuerystringRegistryReader(registry)
     result = reader.parseRegistry()
     result = reader.mapOperations(result)
     operators = result.get("plone.app.querystring.field.created.operators").keys()
     self.assertTrue("plone.app.querystring.operation.date.lessThan" in operators)
     self.assertFalse("plone.app.querystring.operation.date.largerThan" in operators)
Esempio n. 5
0
 def __call__(self):
     """Return the registry configuration in JSON format"""
     registry = getUtility(IRegistry)
     # First grab the base config, so we can use the operations
     registryreader = IQuerystringRegistryReader(registry)
     registryreader.prefix = "plone.app.querystring.operation"
     op_config = registryreader.parseRegistry()
     # Then combine our fields
     registryreader = IQuerystringRegistryReader(registry)
     registryreader.prefix = self.prefix
     config = registryreader.parseRegistry()
     config = registryreader.getVocabularyValues(config)
     config.update(op_config)
     registryreader.mapOperations(config)
     registryreader.mapSortableIndexes(config)
     return {
         'indexes': config.get(self.prefix + '.field'),
         'sortable_indexes': config.get('sortable'),
     }
 def test_map_operations_clean(self):
     """tests if mapOperations is getting all operators correctly"""
     registry = self.createRegistry(td.minimal_correct_xml)
     reader = IQuerystringRegistryReader(registry)
     result = reader.parseRegistry()
     result = reader.mapOperations(result)
     operations = result.get("plone.app.querystring.field.created.operations")
     operators = result.get("plone.app.querystring.field.created.operators")
     for operation in operations:
         self.assertTrue(operation in operators)
 def test_map_operations_clean(self):
     """tests if mapOperations is getting all operators correctly"""
     registry = self.createRegistry(td.minimal_correct_xml)
     reader = IQuerystringRegistryReader(registry)
     result = reader.parseRegistry()
     result = reader.mapOperations(result)
     operations = result.get(
         'plone.app.querystring.field.created.operations')
     operators = result.get('plone.app.querystring.field.created.operators')
     for operation in operations:
         self.assertTrue(operation in operators)
 def test_map_operations_missing(self):
     """tests if nonexisting referenced operations are properly skipped"""
     registry = self.createRegistry(td.test_missing_operator_xml)
     reader = IQuerystringRegistryReader(registry)
     result = reader.parseRegistry()
     result = reader.mapOperations(result)
     operators = result.get(
         'plone.app.querystring.field.created.operators').keys()
     self.assertTrue(
         'plone.app.querystring.operation.date.lessThan' in operators)
     self.assertFalse(
         'plone.app.querystring.operation.date.largerThan' in operators)
    def test_sortable_indexes(self):
        """tests if sortable indexes from the registry will be available in
           the parsed registry
        """
        registry = self.createRegistry(td.minimal_correct_xml)
        reader = IQuerystringRegistryReader(registry)
        result = reader.parseRegistry()
        result = reader.mapOperations(result)
        result = reader.mapSortableIndexes(result)
        sortables = result['sortable']

        # there should be one sortable index
        self.assertEqual(len(sortables), 1)

        # confirm that every sortable really is sortable
        for field in sortables.values():
            self.assertEqual(field['sortable'], True)
    def test_sortable_indexes(self):
        """tests if sortable indexes from the registry will be available in
           the parsed registry
        """
        registry = self.createRegistry(td.minimal_correct_xml)
        reader = IQuerystringRegistryReader(registry)
        result = reader.parseRegistry()
        result = reader.mapOperations(result)
        result = reader.mapSortableIndexes(result)
        sortables = result['sortable']

        # there should be one sortable index
        self.assertEqual(len(sortables), 1)

        # confirm that every sortable really is sortable
        for field in sortables.values():
            self.assertEqual(field['sortable'], True)
Esempio n. 11
0
    def getConfig(self):
        """get the config"""
        registry = getUtility(IRegistry)
        prefix = self.registry_prefix
        if prefix:
            # First grab the base config's operations
            registryreader = IQuerystringRegistryReader(registry)
            registryreader.prefix = "plone.app.querystring.operation"
            plone_config = registryreader.parseRegistry()
            # then merge custom fields
            registryreader = IQuerystringRegistryReader(registry)
            registryreader.prefix = prefix
            config = registryreader.parseRegistry()
            config = registryreader.getVocabularyValues(config)
            config.update(plone_config)
            config = registryreader.mapOperations(config)
            config = registryreader.mapSortableIndexes(config)
            config = {
                'indexes': config.get(prefix + '.field'),
                'sortable_indexes': config.get('sortable'),
            }
        else:
            # First grab the base config's operations
            registryreader = IQuerystringRegistryReader(registry)
            registryreader.prefix = "plone.app.querystring"
            config = registryreader()

        # Group indices by "group", order alphabetically
        groupedIndexes = {}
        for indexName in config['indexes']:
            index = config['indexes'][indexName]
            if index['enabled']:
                group = index['group']
                if group not in groupedIndexes:
                    groupedIndexes[group] = []
                groupedIndexes[group].append((index['title'], indexName))

        # Sort each index list
        [a.sort() for a in groupedIndexes.values()]

        config['groupedIndexes'] = groupedIndexes
        return config
Esempio n. 12
0
    def getConfig(self):
        """get the config"""
        registry = getUtility(IRegistry)
        prefix = self.registry_prefix
        if prefix is not None:
            # First grab the base config's operations
            registryreader = IQuerystringRegistryReader(registry)
            registryreader.prefix = "plone.app.querystring.operation"
            plone_config = registryreader.parseRegistry()
            # then merge custom fields
            registryreader = IQuerystringRegistryReader(registry)
            registryreader.prefix = prefix
            config = registryreader.parseRegistry()
            config = registryreader.getVocabularyValues(config)
            config.update(plone_config)
            config = registryreader.mapOperations(config)
            config = registryreader.mapSortableIndexes(config)
            config = {
                'indexes': config.get(prefix + '.field'),
                'sortable_indexes': config.get('sortable'),
            }
        else:
            # First grab the base config's operations
            registryreader = IQuerystringRegistryReader(registry)
            registryreader.prefix = "plone.app.querystring"
            config = registryreader()

        # Group indices by "group", order alphabetically
        groupedIndexes = {}
        for indexName in config['indexes']:
            index = config['indexes'][indexName]
            if index['enabled']:
                group = index['group']
                if group not in groupedIndexes:
                    groupedIndexes[group] = []
                groupedIndexes[group].append((index['title'], indexName))

        # Sort each index list
        [a.sort() for a in groupedIndexes.values()]

        config['groupedIndexes'] = groupedIndexes
        return config