Issues (109)

tests/helpers.py (1 issue)

1
def create_dt_params(columns, search='', start=0, length=10, order=None):
0 ignored issues
show
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
    """Create DataTables input parameters."""
3
    params = {
4
        'draw': '1',
5
        'start': str(start),
6
        'length': str(length),
7
        'search[value]': str(search),
8
        'search[regex]': 'false'
9
    }
10
11
    for i, item in enumerate(columns):
12
        cols = 'columns[%s]' % i
13
        params['%s%s' % (cols, '[data]')] = i
14
        params['%s%s' % (cols, '[name]')] = ''
15
        params['%s%s' % (cols, '[searchable]')] = 'true'
16
        params['%s%s' % (cols, '[orderable]')] = 'true'
17
        params['%s%s' % (cols, '[search][value]')] = ''
18
        params['%s%s' % (cols, '[search][regex]')] = 'false'
19
20
    for i, item in enumerate(order or [{'column': 0, 'dir': 'asc'}]):
21
        for key, value in item.items():
22
            params['order[%s][%s]' % (i, key)] = str(value)
23
24
    return params
25