Example #1
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
    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
 def test_get_vocabularies(self):
     """tests if getVocabularyValues is returning the correct vocabulary
        values in the correct format
     """
     registry = self.createRegistry(td.test_vocabulary_xml)
     reader = IQuerystringRegistryReader(registry)
     result = reader.parseRegistry()
     result = reader.getVocabularyValues(result)
     vocabulary_result = result.get("plone.app.querystring.field.reviewState.values")
     self.assertEqual(vocabulary_result, {"foo": {"title": u"bar"}})
 def test_get_vocabularies(self):
     """tests if getVocabularyValues is returning the correct vocabulary
        values in the correct format
     """
     registry = self.createRegistry(td.test_vocabulary_xml)
     reader = IQuerystringRegistryReader(registry)
     result = reader.parseRegistry()
     result = reader.getVocabularyValues(result)
     vocabulary_result = result.get(
         'plone.app.querystring.field.reviewState.values')
     self.assertEqual(vocabulary_result, {'foo': {'title': u'bar'}})
Example #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)
     config = {"indexes": config.get(self.prefix + ".field"), "sortable_indexes": config.get("sortable")}
     return json.dumps(config)
Example #6
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'),
     }
Example #7
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
Example #8
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