コード例 #1
0
    def parse_action(self, action):
        if not all(k in action for k in ('key', 'label')):
            raise ConfigurationError(
                'Wrong configuration format for list actions element')

        if 'type' not in action.keys():
            action['type'] = self.NO_URL

        if 'credential' not in action.keys():
            action['credential'] = None

        if 'confirm' not in action.keys():
            action['confirm'] = False

        if 'confirm_message' not in action.keys():
            action['confirm_message'] = 'Are you sure?'

        if 'class' not in action.keys():
            action['class'] = 'btn btn-small'

        if 'call' not in action.keys():
            action['call'] = False

        if 'visable' not in action.keys():
            action['visable'] = True

        if 'disabled' not in action.keys():
            action['disabled'] = False

        return action
コード例 #2
0
    def parse_item(self, item):
        if 'key' not in item.keys():
            ConfigurationError('Menu items must have unique key')

        if 'type' not in item.keys():
            item['type'] = self.NO_URL

        if 'group' in item.keys():
            item['label'] = ''
            item['type'] = self.GROUP

        if 'label' not in item.keys():
            ConfigurationError('Menu items must have label')

        item['caret'] = item.get('caret', False)

        return item
コード例 #3
0
    def parse_list_action(self, list_element):
        if not all(k in list_element for k in ('url', )):
            raise ConfigurationError(
                'Wrong configuration format for list element')

        if 'type' not in list_element.keys():
            list_element['type'] = self.NO_URL

        self.list_configuration['action'] = list_element
コード例 #4
0
    def parse_list_display(self, elements):
        for element in elements:
            if not all(k in element for k in ('key', 'label')):
                raise ConfigurationError(
                    'Wrong configuration format for list display element')

            if not 'type' in element:
                element['type'] = 'string'

            self.list_configuration['display'].append(element)
コード例 #5
0
    def parse_batch(self, batch_element):
        if not all(k in batch_element for k in ('url', )):
            raise ConfigurationError(
                'Wrong configuration format for list filter element')

        if 'type' not in batch_element.keys():
            batch_element['type'] = self.NO_URL

        if 'form' not in batch_element.keys():
            batch_element['form'] = None

        self.list_configuration['batch'] = batch_element
コード例 #6
0
    def parse_filter(self, filter_element):
        if not all(k in filter_element
                   for k in ('session_name', 'display', 'url')):
            raise ConfigurationError(
                'Wrong configuration format for list filter element')

        if 'type' not in filter_element.keys():
            filter_element['type'] = self.NO_URL

        if 'form' not in filter_element.keys():
            filter_element['form'] = None

        self.list_configuration['filter'] = filter_element
コード例 #7
0
 def __check_key(self, key):
     if key in self._items:
         ConfigurationError('This key: %s is not unique' % key)
     return True
コード例 #8
0
 def get_item(self, key):
     if key not in self._items:
         ConfigurationError('This key: %s not exists' % key)
     return self._items[key]