Example #1
0
def _generate_item_list_part(tag, data_seq):
    tbl = tag.table()
    tr = tbl.tr()
    for name in ['Task', 'Assigned', 'Estimated', 'Left', 'On track-o-meter', 'Projection']:
        tr.th(name)

    for data in data_seq:
        spent = dm.get_time_spent(data)
        remaining = dm.get_remaining_time(data)
        estimate = dm.get_estimate(data)
        time_projection = dm.get_projected_time_diff(data)

        tr = tbl.tr()
        _add_link(tr.td(), data)
        tr.td(dm.get(data, 'ASSIGNED', '-'))
        tr.td(str(estimate))
        tr.td('%d' % (remaining,))
        _make_relative_meter(tr.td(), -time_projection, estimate)
        tr.td('%+d' % (time_projection,))
Example #2
0
def _generate_item_page(state, data):
    name = dm.get(data, 'NAME', '?')
    logging.debug('Generating "%s"', name)
    root, tag = _make_page_base(name)

    # basic
    tag.h2('Basics')
    tbl = tag.table()
    for key in ['NAME', 'ID', 'PRIORITY']:
        title = key[0] + key[1:].lower()
        tr = tbl.tr()
        tr.th(title)
        tr.td(dm.get(data, key, '?'))
    tr = tbl.tr()
    tr.th('Status')
    tr.td(dm.get_status(data))
    tr = tbl.tr()
    tr.th('Assigned')
    tr.td(', '.join(filter(len, data.get('ASSIGNED', []))))

    # links
    tag.h2('Links')
    tbl = tag.table()
    tr = tbl.tr()
    for header in ['Parent', 'Child', 'Related']:
        tr.th(header, width='33%')

    parents = [state.get(key)
               for key in dm.get_links(data, 'PARENT')]
    children = state.children(dm.get(data, 'ID'))
    related = [state.get(key)
               for key in dm.get_links(data, 'LINK')]

    for i in range(max(map(len, [parents, children, related]))):
        tr = tbl.tr()
        for items in [parents, children, related]:
            if len(items) > i:
                _add_link(tr.td(), items[i])
            else:
                tr.td()

    # description
    tag.h2('Description')
    if not dm.null(data, 'DESCRIPTION'):
        div = tag.div(klass='description')
        for line in data.get('DESCRIPTION', []):
            div.text(line)
            div.br()

    # time
    tag.h2('Time')

    tbl = tag.table(klass='small')
    for key, value in [('Original estimate', dm.get_estimate(data)),
                       ('Total time spent', dm.get_time_spent(data)),
                       ('Current remaining time', dm.get_remaining_time(data))]:
        tr = tbl.tr()
        tr.th(key)
        tr.td(str(value))
    tr = tbl.tr()
    tr.th('Status')
    _make_relative_meter(tr.td(),
                         -dm.get_projected_time_diff(data),
                         dm.get_estimate(data))

    tag.br()

    tbl = tag.table()
    tr = tbl.tr()
    for header in ['Reported', 'User', 'Spent', 'Remaining']:
        tr.th(header)
    for rep in dm.get_time_reports(data):
        tr = tbl.tr()
        for key in ['time', 'user', 'spent', 'remaining']:
            tr.td(rep[key])

    return root