Beispiel #1
0
    def rest(self):
        rest = {'type': self.rest_type}
        # From the datatype
        datatype = self.get_datatype()
        for key in 'multiple', 'multilingual', 'indexed', 'stored':
            value = getattr(datatype, key)
            rest[key] = Boolean.encode(value)

        # Default value
        default = self.get_default()
        if default is not None:
            rest['default'] = datatype.encode(default)

        # Other
        for key in 'required', 'readonly':
            value = getattr(self, key)
            rest[key] = Boolean.encode(value)

        # Ok
        return rest
Beispiel #2
0
    def rest(self):
        rest = {'type': self.rest_type}
        # From the datatype
        datatype = self.get_datatype()
        for key in 'multiple', 'multilingual', 'indexed', 'stored':
            value = getattr(datatype, key)
            rest[key] = Boolean.encode(value)

        # Default value
        default = self.get_default()
        if default is not None:
            rest['default'] = datatype.encode(default)

        # Other
        for key in 'required', 'readonly':
            value = getattr(self, key)
            rest[key] = Boolean.encode(value)

        # Ok
        return rest
Beispiel #3
0
    def get_table_head(self, resource, context, items):
        actions = self.actions_namespace

        # Get from the query
        query = context.query
        sort_by = query['sort_by']
        reverse = query['reverse']

        columns = self._get_table_columns(resource, context)
        columns_ns = []
        for name, title, sortable, css in columns:
            if name == 'checkbox':
                # Type: checkbox
                if actions:
                    columns_ns.append({'is_checkbox': True})
            elif title is None:
                # Type: nothing
                continue
            elif not sortable:
                # Type: nothing or not sortable
                columns_ns.append({
                    'is_checkbox': False,
                    'title': title,
                    'href': None
                })
            else:
                # Type: normal
                kw = {'sort_by': name}
                if name == sort_by:
                    col_reverse = (not reverse)
                    order = 'up' if reverse else 'down'
                else:
                    col_reverse = False
                    order = 'none'
                kw['reverse'] = Boolean.encode(col_reverse)
                columns_ns.append({
                    'is_checkbox': False,
                    'title': title,
                    'order': order,
                    'href': context.uri.replace(**kw),
                })
Beispiel #4
0
    def get_table_head(self, resource, context, items):
        actions = self.actions_namespace

        # Get from the query
        query = context.query
        sort_by = query['sort_by']
        reverse = query['reverse']

        columns = self._get_table_columns(resource, context)
        columns_ns = []
        for name, title, sortable, css in columns:
            if name == 'checkbox':
                # Type: checkbox
                if  actions:
                    columns_ns.append({'is_checkbox': True})
            elif title is None:
                # Type: nothing
                continue
            elif not sortable:
                # Type: nothing or not sortable
                columns_ns.append({
                    'is_checkbox': False,
                    'title': title,
                    'href': None})
            else:
                # Type: normal
                kw = {'sort_by': name}
                if name == sort_by:
                    col_reverse = (not reverse)
                    order = 'up' if reverse else 'down'
                else:
                    col_reverse = False
                    order = 'none'
                kw['reverse'] = Boolean.encode(col_reverse)
                columns_ns.append({
                    'is_checkbox': False,
                    'title': title,
                    'order': order,
                    'href': context.uri.replace(**kw),
                    })
Beispiel #5
0
 def test_Boolean(self):
     for x in [True, False]:
         data = Boolean.encode(x)
         self.assertEqual(x, Boolean.decode(data))