axes.py 878 Bytes
Newer Older
1 2 3
""" axes

    Fill axes table.
4

5
    It is used by the lists user interface.
6
    The table defines the relation between axis and their granularity.
7
    This table contains static data which can not be modified by the user.
8

9 10
"""
if db(db.axes).count() == 0:
11

12 13 14 15 16
    axes = ['categories',
            'countries',
            'projects',
            'publishers',
            'status',
17
            'teams']
18

19
    for axe in axes:
20 21
        granularities = set(db[axe].fields).difference(['id', 'definition'])
        for value in granularities:
22
            db.axes.insert(axis=axe,
23 24 25
                           granularity=value,
                           tr_axis=T(axe),
                           tr_granularity=T(value))
26 27

    db.axes.insert(axis='publications',
28 29 30
                   granularity='year',
                   tr_axis=T('time'),
                   tr_granularity=T('year'))
31